[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH 1/3] stinst: extract RBParser/RBScanner tests to
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] [PATCH 1/3] stinst: extract RBParser/RBScanner tests to new files |
Date: |
Tue, 7 Jan 2014 12:35:55 +0100 |
packages/stinst/parser:
2014-01-07 Paolo Bonzini <address@hidden>
* RBParserTests.st: New, extracted from RewriteTests.st.
* RBScannerTests.st: New, extracted from RewriteTests.st.
* RewriteTests.st: Remove code extracted to new files.
---
packages/stinst/parser/ChangeLog | 6 +++
packages/stinst/parser/RBParserTests.st | 71 ++++++++++++++++++++++++++++++++
packages/stinst/parser/RBScannerTests.st | 50 ++++++++++++++++++++++
packages/stinst/parser/RewriteTests.st | 64 ----------------------------
packages/stinst/parser/package.xml | 2 +
5 files changed, 129 insertions(+), 64 deletions(-)
create mode 100644 packages/stinst/parser/RBParserTests.st
create mode 100644 packages/stinst/parser/RBScannerTests.st
diff --git a/packages/stinst/parser/ChangeLog b/packages/stinst/parser/ChangeLog
index 2bd7eeb..4add5b9 100644
--- a/packages/stinst/parser/ChangeLog
+++ b/packages/stinst/parser/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-07 Paolo Bonzini <address@hidden>
+
+ * RBParserTests.st: New, extracted from RewriteTests.st.
+ * RBScannerTests.st: New, extracted from RewriteTests.st.
+ * RewriteTests.st: Remove code extracted to new files.
+
2013-12-19 Holger Hans Peter Freyther <address@hidden>
* STCompiler.st: Rename STCompiler>>#addPool: to
diff --git a/packages/stinst/parser/RBParserTests.st
b/packages/stinst/parser/RBParserTests.st
new file mode 100644
index 0000000..f569821
--- /dev/null
+++ b/packages/stinst/parser/RBParserTests.st
@@ -0,0 +1,71 @@
+"======================================================================
+|
+| Smalltalk in Smalltalk RBParser tests
+|
+|
+ ======================================================================"
+
+"======================================================================
+|
+| Copyright 2007, 2013, 2014 Free Software Foundation, Inc.
+|
+| This file is part of GNU Smalltalk.
+|
+| GNU Smalltalk is free software; you can redistribute it and/or modify it
+| under the terms of the GNU General Public License as published by the Free
+| Software Foundation; either version 2, or (at your option) any later version.
+|
+| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+| FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+| details.
+|
+| You should have received a copy of the GNU General Public License along with
+| GNU Smalltalk; see the file COPYING. If not, write to the Free Software
+| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+|
+ ======================================================================"
+
+
+TestCase subclass: TestParser [
+ <comment: 'Test aspects of the RBParser'>
+
+ testNumberParsing [
+
+ | node |
+ node := RBParser parseExpression: '3'.
+ self assert: node value = 3.
+ node := RBParser parseExpression: '-3'.
+ self assert: node value = -3.
+ node := RBParser parseExpression: '-16r3'.
+ self assert: node value = -3.
+ node := RBParser parseExpression: '16r-3'.
+ self assert: node value = -3.
+ node := RBParser parseExpression: '- 16r3'.
+ self assert: node value = -3.
+ node := RBParser parseExpression: '16r-3.23'.
+ self assert: node value = 16r-3.23.
+ node := RBParser parseExpression: '16r-3s23_0'.
+ self assert: node value = 16r-3s23_0.
+ node := RBParser parseExpression: '3_000_000'.
+ self assert: node value = 3_000_000.
+ node := RBParser parseExpression: '3_000_000e1233'.
+ self assert: node value = 3_000_000e1233.
+ node := RBParser parseExpression: '3_000_000d1233'.
+ self assert: node value = 3_000_000d1233.
+ node := RBParser parseExpression: '3_000_000q1233'.
+ self assert: node value = 3_000_000q1233.
+ ]
+
+ testLiteralArrayParsing [
+ | node |
+
+ node := RBParser parseExpression: '#(-3 -2 -16r1)'.
+ self assert: node value first = -3.
+ self assert: node value second = -2.
+ self assert: node value third = -1.
+
+ node := RBParser parseExpression: '#(16r-1)'.
+ self assert: node value first = -1.
+ ]
+]
diff --git a/packages/stinst/parser/RBScannerTests.st
b/packages/stinst/parser/RBScannerTests.st
new file mode 100644
index 0000000..41ecfd9
--- /dev/null
+++ b/packages/stinst/parser/RBScannerTests.st
@@ -0,0 +1,50 @@
+"======================================================================
+|
+| Smalltalk in Smalltalk RBScanner tests
+|
+|
+ ======================================================================"
+
+"======================================================================
+|
+| Copyright 2007, 2013, 2014 Free Software Foundation, Inc.
+|
+| This file is part of GNU Smalltalk.
+|
+| GNU Smalltalk is free software; you can redistribute it and/or modify it
+| under the terms of the GNU General Public License as published by the Free
+| Software Foundation; either version 2, or (at your option) any later version.
+|
+| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+| FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+| details.
+|
+| You should have received a copy of the GNU General Public License along with
+| GNU Smalltalk; see the file COPYING. If not, write to the Free Software
+| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+|
+ ======================================================================"
+
+
+TestCase subclass: TestScanner [
+ <comment: 'I do test the RBScanner/Tokenizer.'>
+
+ testScanner [
+ | scanner num |
+ scanner := RBScanner on: '3' readStream.
+ num := scanner next.
+ self assert: num value = 3.
+ ]
+
+ testScannerConcatStream [
+ | scanner num |
+ "This is different to >>#testScanner by using a different kind of
stream with
+ a different species."
+
+ scanner := RBScanner on: (Kernel.ConcatenatedStream with: '3'
readStream).
+ num := scanner next.
+ self assert: num value = 3.
+ ]
+]
+
diff --git a/packages/stinst/parser/RewriteTests.st
b/packages/stinst/parser/RewriteTests.st
index 3712f92..322ac38 100644
--- a/packages/stinst/parser/RewriteTests.st
+++ b/packages/stinst/parser/RewriteTests.st
@@ -331,70 +331,6 @@ TestCase subclass: TestFormat [
]
]
-TestCase subclass: TestScanner [
- <comment: 'Test aspects of the RBScanner'>
-
- testScanner [
- | scanner num |
- scanner := RBScanner on: '3' readStream.
- num := scanner next.
- self assert: num value = 3.
- ]
-
- testScannerConcatStream [
- | scanner num |
- "This is different to >>#testScanner by using a different kind of
stream with
- a different species."
-
- scanner := RBScanner on: (Kernel.ConcatenatedStream with: '3'
readStream).
- num := scanner next.
- self assert: num value = 3.
- ]
-]
-
-TestCase subclass: TestParser [
- <comment: 'Test aspects of the RBParser'>
-
- testNumberParsing [
-
- | node |
- node := RBParser parseExpression: '3'.
- self assert: node value = 3.
- node := RBParser parseExpression: '-3'.
- self assert: node value = -3.
- node := RBParser parseExpression: '-16r3'.
- self assert: node value = -3.
- node := RBParser parseExpression: '16r-3'.
- self assert: node value = -3.
- node := RBParser parseExpression: '- 16r3'.
- self assert: node value = -3.
- node := RBParser parseExpression: '16r-3.23'.
- self assert: node value = 16r-3.23.
- node := RBParser parseExpression: '16r-3s23_0'.
- self assert: node value = 16r-3s23_0.
- node := RBParser parseExpression: '3_000_000'.
- self assert: node value = 3_000_000.
- node := RBParser parseExpression: '3_000_000e1233'.
- self assert: node value = 3_000_000e1233.
- node := RBParser parseExpression: '3_000_000d1233'.
- self assert: node value = 3_000_000d1233.
- node := RBParser parseExpression: '3_000_000q1233'.
- self assert: node value = 3_000_000q1233.
- ]
-
- testLiteralArrayParsing [
- | node |
-
- node := RBParser parseExpression: '#(-3 -2 -16r1)'.
- self assert: node value first = -3.
- self assert: node value second = -2.
- self assert: node value third = -1.
-
- node := RBParser parseExpression: '#(16r-1)'.
- self assert: node value first = -1.
- ]
-]
-
TestCase subclass: TestRewrite [
<comment: 'I test that rewriting a method for the OldSyntaxExport and
SqueakExporter will pick up the new code.'>
diff --git a/packages/stinst/parser/package.xml
b/packages/stinst/parser/package.xml
index 6102af7..f3516fc 100644
--- a/packages/stinst/parser/package.xml
+++ b/packages/stinst/parser/package.xml
@@ -44,6 +44,8 @@
<filein>STLoaderObjsTests.st</filein>
<filein>GSTParserTests.st</filein>
<filein>STCompilerTests.st</filein>
+ <filein>RBScannerTests.st</filein>
+ <filein>RBParserTests.st</filein>
</test>
<file>ChangeLog</file>
--
1.8.4.2