--- a/compiler/tests/PPCNodeCompilingTest.st Wed Nov 05 23:05:19 2014 +0000
+++ b/compiler/tests/PPCNodeCompilingTest.st Thu Nov 06 01:41:10 2014 +0000
@@ -92,29 +92,33 @@
!
testCompileChoice
- tree := PPCChoiceNode new
- children: { #digit asParser asCompilerNode. #letter asParser asCompilerNode };
- yourself.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 4.
-
- self assert: parser parse: '1' to: $1.
- self assert: parser parse: 'a' to: $a.
- self assert: parser fail: '_'.
+ tree := PPCChoiceNode new
+ children: { #digit asParser asCompilerNode. #letter asParser asCompilerNode };
+ yourself.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 4.
+
+ self assert: parser parse: '1' to: $1.
+ self assert: parser parse: 'a' to: $a.
+ self assert: parser fail: '_'.
+
+ "Modified: / 06-11-2014 / 00:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileLiteral
- tree := PPCLiteralNode new
- literal: 'foo';
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'foo' to: 'foo'.
- self assert: parser parse: 'foobar' to: 'foo' end: 3.
- self assert: parser fail: 'boo'.
+ tree := PPCLiteralNode new
+ literal: 'foo';
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'foo' to: 'foo'.
+ self assert: parser parse: 'foobar' to: 'foo' end: 3.
+ self assert: parser fail: 'boo'.
+
+ "Modified: / 06-11-2014 / 00:48:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileLiteral2
@@ -149,45 +153,51 @@
!
testCompileNotCharSetPredicate
- tree := PPCNotCharSetPredicateNode new
- predicate: (PPCharSetPredicate on: [ :e | e = $a ]);
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'b' to: nil end: 0.
- self assert: context invocationCount = 2.
-
- self assert: parser fail: 'a'.
- self assert: parser parse: '' to: nil end: 0.
+ tree := PPCNotCharSetPredicateNode new
+ predicate: (PPCharSetPredicate on: [ :e | e = $a ]);
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'b' to: nil end: 0.
+ self assert: context invocationCount = 2.
+
+ self assert: parser fail: 'a'.
+ self assert: parser parse: '' to: nil end: 0.
+
+ "Modified: / 06-11-2014 / 00:48:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileNotLiteral
- tree := PPCNotLiteralNode new
- literal: 'foo';
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'bar' to: nil end: 0.
- self assert: context invocationCount = 2.
-
- self assert: parser fail: 'foo'.
- self assert: parser parse: '' to: nil end: 0.
+ tree := PPCNotLiteralNode new
+ literal: 'foo';
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'bar' to: nil end: 0.
+ self assert: context invocationCount = 2.
+
+ self assert: parser fail: 'foo'.
+ self assert: parser parse: '' to: nil end: 0.
+
+ "Modified: / 06-11-2014 / 00:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileNotMessagePredicate
- tree := PPCNotMessagePredicateNode new
- message: #isDigit;
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'a' to: nil end: 0.
- self assert: context invocationCount = 2.
-
- self assert: parser fail: '1'.
- self assert: parser parse: '' to: nil end: 0.
+ tree := PPCNotMessagePredicateNode new
+ message: #isDigit;
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'a' to: nil end: 0.
+ self assert: context invocationCount = 2.
+
+ self assert: parser fail: '1'.
+ self assert: parser parse: '' to: nil end: 0.
+
+ "Modified: / 06-11-2014 / 00:48:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileOptional
@@ -255,32 +265,34 @@
!
testCompileStarCharSetPredicate
- tree := PPCStarCharSetPredicateNode new
- predicate: (PPCharSetPredicate on: [:e | e = $a ]);
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'aaa1' to: #( $a $a $a) end: 3.
- self assert: context invocationCount = 2.
- self assert: parser parse: 'bba' to: #() end: 0.
- self assert: context invocationCount = 2.
-
+ tree := PPCStarCharSetPredicateNode new
+ predicate: (PPCharSetPredicate on: [:e | e = $a ]);
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'aaa1' to: #( $a $a $a) end: 3.
+ self assert: context invocationCount = 2.
+ self assert: parser parse: 'bba' to: #() end: 0.
+ self assert: context invocationCount = 2.
+
+ "Modified: / 06-11-2014 / 00:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileStarMessagePredicate
- tree := PPCStarMessagePredicateNode new
- message: #isLetter;
- yourself.
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 2.
- self assert: parser parse: 'abc1' to: #( $a $b $c) end: 3.
- self assert: context invocationCount = 2.
-
- self assert: parser parse: '123a' to: #() end: 0.
- self assert: context invocationCount = 2.
-
+ tree := PPCStarMessagePredicateNode new
+ message: #isLetter;
+ yourself.
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'abc1' to: #( $a $b $c) end: 3.
+ self assert: context invocationCount = 2.
+
+ self assert: parser parse: '123a' to: #() end: 0.
+ self assert: context invocationCount = 2.
+
+ "Modified: / 06-11-2014 / 00:48:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testCompileSymbolAction
@@ -341,19 +353,21 @@
!
testCompileTokenStarMessagePredicate
-
- tree := PPCTokenStarMessagePredicateNode new message: #isLetter.
- parser := self compileTree: tree params: {#guards -> false}.
-
- self assert: parser class methods size = 2.
-
- self assert: parser parse: 'foo' to: parser.
- self assert: context invocationCount = 2.
- self assert: context lwRememberCount = 0.
- self assert: context lwRestoreCount = 0.
- self assert: context rememberCount = 0.
-
- self assert: parser parse: 'foo123' to: parser end: 3.
+
+ tree := PPCTokenStarMessagePredicateNode new message: #isLetter.
+ parser := self compileTree: tree params: {#guards -> false}.
+
+ self assert: parser class methodDictionary size = 2.
+
+ self assert: parser parse: 'foo' to: parser.
+ self assert: context invocationCount = 2.
+ self assert: context lwRememberCount = 0.
+ self assert: context lwRestoreCount = 0.
+ self assert: context rememberCount = 0.
+
+ self assert: parser parse: 'foo123' to: parser end: 3.
+
+ "Modified: / 06-11-2014 / 00:49:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCNodeCompilingTest methodsFor:'tests - guard'!
@@ -408,77 +422,91 @@
!PPCNodeCompilingTest methodsFor:'tests - inlining'!
testInlineAny
- tree := PPCSequenceNode new
- children: { PPCInlineAnyNode new. $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: '.a' to: #($. $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlineAnyNode new. $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: '.a' to: #($. $a).
+
+ "Modified: / 06-11-2014 / 01:12:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlineCharSetPredicate
- tree := PPCPlusNode new
- child: (PPCInlineCharSetPredicateNode new
- predicate: (PPCharSetPredicate on: [ :e | e = $a ]);
- yourself);
- yourself.
-
- parser := self compileTree: tree.
+ tree := PPCPlusNode new
+ child: (PPCInlineCharSetPredicateNode new
+ predicate: (PPCharSetPredicate on: [ :e | e = $a ]);
+ yourself);
+ yourself.
+
+ parser := self compileTree: tree.
- self assert: parser class methods size = 2.
- self assert: parser parse: 'a' to: #($a).
- self assert: parser fail: 'b'.
+ self assert: parser class methodDictionary size = 2.
+ self assert: parser parse: 'a' to: #($a).
+ self assert: parser fail: 'b'.
+
+ "Modified: / 06-11-2014 / 01:12:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlineCharacter
- tree := PPCSequenceNode new
- children: { PPCInlineCharacterNode new character: $b . $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: 'ba' to: #($b $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlineCharacterNode new character: $b . $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: 'ba' to: #($b $a).
+
+ "Modified: / 06-11-2014 / 01:12:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlineLiteral
- tree := PPCSequenceNode new
- children: { PPCInlineLiteralNode new literal: 'foo'. $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: 'fooa' to: #('foo' $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlineLiteralNode new literal: 'foo'. $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: 'fooa' to: #('foo' $a).
+
+ "Modified: / 06-11-2014 / 01:12:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlineNil
- tree := PPCSequenceNode new
- children: { PPCInlineNilNode new . $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: 'a' to: #(nil $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlineNilNode new . $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: 'a' to: #(nil $a).
+
+ "Modified: / 06-11-2014 / 01:12:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlineNotLiteral
- tree := PPCSequenceNode new
- children: { PPCInlineNotLiteralNode new literal: 'foo'. $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: 'a' to: #(nil $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlineNotLiteralNode new literal: 'foo'. $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: 'a' to: #(nil $a).
+
+ "Modified: / 06-11-2014 / 01:12:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testInlinePluggable
- tree := PPCSequenceNode new
- children: { PPCInlinePluggableNode new block: [ :ctx | ctx next ]. $a asParser asCompilerNode }.
-
- parser := self compileTree: tree.
-
- self assert: parser class methods size = 3.
- self assert: parser parse: 'ba' to: #($b $a).
+ tree := PPCSequenceNode new
+ children: { PPCInlinePluggableNode new block: [ :ctx | tree. ctx next ]. $a asParser asCompilerNode }.
+
+ parser := self compileTree: tree.
+
+ self assert: parser class methodDictionary size = 3.
+ self assert: parser parse: 'ba' to: #($b $a).
+
+ "Modified: / 06-11-2014 / 01:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCNodeCompilingTest class methodsFor:'documentation'!