compiler/tests/PPCCodeGeneratorTest.st
changeset 488 19a9c25960ef
parent 484 e829f3860745
child 489 0ca7a70db0f5
--- a/compiler/tests/PPCCodeGeneratorTest.st	Mon Jun 15 18:00:44 2015 +0100
+++ b/compiler/tests/PPCCodeGeneratorTest.st	Mon Jun 15 19:13:49 2015 +0100
@@ -72,6 +72,24 @@
     self assert: parser fail: ''.
 !
 
+testActionNode2
+    node := PPCPlusNode new
+                child:  
+                    (PPCActionNode new
+                        block: [ :res | res asUppercase ];
+                        child: #letter asParser asCompilerTree;
+                        yourself);
+                yourself.
+    
+    self compileTree: node.
+                    
+    self assert: parser parse: 'foo' to: { $F . $O . $O}.
+    self assert: parser parse: 'bar' to: { $B . $A . $R}.
+    self assert: parser fail: ''.
+
+    "Created: / 15-06-2015 / 13:57:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 testAnyNode
     node := PPCForwardNode new
         child: PPCAnyNode new;
@@ -425,39 +443,49 @@
 testMappedActionNode1
     node := ((#letter asParser , #letter asParser) 
             map:[:a :b | String with:a with:b ]) asCompilerTree.
+
     self compileTree:node.
-    self 
-        assert:parser
-        parse:'ab'
-        to:'ab'.
-    self 
-        assert:parser
-        parse:'cz'
-        to:'cz'.
+
+    self assert:parser parse:'ab' to:'ab'.
+    self assert:parser parse:'cz' to:'cz'.
     self assert:parser fail:''.
     self assert:parser fail:'a'.
 
     "Created: / 02-06-2015 / 17:04:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 04-06-2015 / 22:44:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 15-06-2015 / 14:08:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testMappedActionNode2
     node := ((#letter asParser , #letter asParser) 
             map:[:a :b | String with:a with:b ]) asCompilerTree.
     node child markForInline.
+
     self compileTree:node.
-    self 
-        assert:parser
-        parse:'ab'
-        to:'ab'.
-    self 
-        assert:parser
-        parse:'cz'
-        to:'cz'.
+
+    self assert:parser parse:'ab' to:'ab'.
+    self assert:parser parse:'cz' to:'cz'.
     self assert:parser fail:''.
     self assert:parser fail:'a'.
 
     "Created: / 04-06-2015 / 23:13:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 15-06-2015 / 14:08:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testMappedActionNode3
+    node := PPCPlusNode new
+                child:  
+                    (PPCMappedActionNode new
+                        block: [ :l | l asUppercase ];
+                        child: #letter asParser asCompilerTree;
+                        yourself);
+                yourself.           
+
+    self compileTree:node.
+
+    self assert:parser parse:'abc' to:#($A $B $C).
+
+    "Created: / 15-06-2015 / 18:27:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testMessagePredicate