compiler/tests/PPCTokenizingTest.st
changeset 534 a949c4fe44df
parent 529 439c4057517f
child 535 a8feb0f47574
equal deleted inserted replaced
533:666372dbe307 534:a949c4fe44df
    46 setUp
    46 setUp
    47     options := PPCCompilationOptions default
    47     options := PPCCompilationOptions default
    48         profile: true;
    48         profile: true;
    49         yourself.
    49         yourself.
    50         
    50         
    51     configuration := PPCTokenizingConfiguration new
    51     configuration := PPCTokenizingConfiguration new.
    52         options: options;
    52     configuration context options: options.
    53         yourself.
    53 
    54         
       
    55     self cleanClass.
    54     self cleanClass.
    56 
    55 
    57     "Modified: / 24-08-2015 / 23:40:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    56     "Modified: / 28-08-2015 / 14:20:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    58 !
    57 !
    59 
    58 
    60 tearDown
    59 tearDown
    61     "self cleanClass"
    60     "self cleanClass"
    62 !
    61 !
   481     self assert: (parser scanner class methodDictionary includesKey: #scan_fooToken).
   480     self assert: (parser scanner class methodDictionary includesKey: #scan_fooToken).
   482 !
   481 !
   483 
   482 
   484 testWhitespace
   483 testWhitespace
   485     | token ws trimmingToken |
   484     | token ws trimmingToken |
   486     configuration options inline: false.
   485     options inline: false.
   487     
   486     
   488     token := 'foo' asParser token.
   487     token := 'foo' asParser token.
   489     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   488     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   490     trimmingToken := ((ws, token, ws) ==> #second) 
   489     trimmingToken := ((ws, token, ws) ==> #second) 
   491         propertyAt: 'trimmingToken' put: true; 
   490         propertyAt: 'trimmingToken' put: true; 
   496 
   495 
   497     self assert: parser parse: ' foo '.
   496     self assert: parser parse: ' foo '.
   498     self assert: result first inputValue = 'foo'.
   497     self assert: result first inputValue = 'foo'.
   499 
   498 
   500     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 3.
   499     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 3.
       
   500 
       
   501     "Modified: / 04-09-2015 / 06:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   501 !
   502 !
   502 
   503 
   503 testWhitespace2
   504 testWhitespace2
   504     | token ws trimmingToken |
   505     | token ws trimmingToken |
   505     configuration options inline: false.
   506     options inline: false.
   506         
   507         
   507     token := 'foo' asParser token.
   508     token := 'foo' asParser token.
   508     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   509     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   509     trimmingToken := ((ws, token, ws) ==> #second) 
   510     trimmingToken := ((ws, token, ws) ==> #second) 
   510         propertyAt: 'trimmingToken' put: true; 
   511         propertyAt: 'trimmingToken' put: true; 
   516     self assert: parser parse: ' foo foo '.
   517     self assert: parser parse: ' foo foo '.
   517     self assert: result first inputValue = 'foo'.
   518     self assert: result first inputValue = 'foo'.
   518     self assert: result second inputValue = 'foo'.
   519     self assert: result second inputValue = 'foo'.
   519 
   520 
   520     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 4.
   521     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 4.
       
   522 
       
   523     "Modified: / 04-09-2015 / 06:13:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   521 !
   524 !
   522 
   525 
   523 testWhitespace3
   526 testWhitespace3
   524     | token ws trimmingToken |
   527     | token ws trimmingToken |
   525     configuration options inline: false.
   528     options inline: false.
   526         
   529         
   527     token := 'foo' asParser token.
   530     token := 'foo' asParser token.
   528     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   531     ws := #blank asParser star name: 'consumeWhitespace'; yourself.
   529     trimmingToken := ((ws, token, ws) ==> #second) 
   532     trimmingToken := ((ws, token, ws) ==> #second) 
   530         propertyAt: 'trimmingToken' put: true; 
   533         propertyAt: 'trimmingToken' put: true; 
   537     self assert: result first inputValue = 'foo'.
   540     self assert: result first inputValue = 'foo'.
   538     self assert: result second inputValue = 'foo'.
   541     self assert: result second inputValue = 'foo'.
   539     self assert: result third inputValue = 'foo'.
   542     self assert: result third inputValue = 'foo'.
   540 
   543 
   541     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 5.
   544     self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 5.
       
   545 
       
   546     "Modified: / 04-09-2015 / 06:13:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   542 ! !
   547 ! !
   543 
   548