compiler/tests/PPCCodeGeneratorTest.st
changeset 489 0ca7a70db0f5
parent 488 19a9c25960ef
child 490 a836cbc0d8df
--- a/compiler/tests/PPCCodeGeneratorTest.st	Mon Jun 15 19:13:49 2015 +0100
+++ b/compiler/tests/PPCCodeGeneratorTest.st	Tue Jun 16 06:45:26 2015 +0100
@@ -488,6 +488,45 @@
     "Created: / 15-06-2015 / 18:27:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+testMappedNode3
+    node := ((#letter asParser , #letter asParser) 
+            ==> [:nodes | String with:(nodes first) with:(nodes second) ]) asCompilerTree.
+    node child markForInline.
+
+    self compileTree:node.
+
+    self assert:parser parse:'ab' to:'ab'.
+    self assert:parser parse:'cz' to:'cz'.
+    self assert:parser fail:''.
+
+    "Created: / 16-06-2015 / 06:01:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testMappedNode4
+    node := ((#letter asParser , #letter asParser) 
+            ==> [:nodes | String with:(nodes first) with:(nodes second) ]) asCompilerTree.
+    node child markForInline.
+
+    self compileTree:node.
+
+    self assert:parser fail:'a'.
+
+    "Created: / 16-06-2015 / 06:13:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testMappedNode5
+    node := ((#letter asParser , #letter asParser optional) 
+            ==> [:nodes | String with:(nodes first) with:((nodes second) isNil ifTrue:[$?] ifFalse:[nodes second]) ]) asCompilerTree.
+    node child markForInline.
+
+    self compileTree:node.
+
+    self assert:parser parse:'cz' to:'cz'.
+    self assert:parser parse:'c' to:'c?'.
+
+    "Created: / 16-06-2015 / 06:32:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 testMessagePredicate
     | messageNode |
     messageNode := PPCMessagePredicateNode new