Codegen: added support for smart action node compiling.
Avoid creation of intermediate result collection for action nodes if all references
to action block's argument (i.e., the nodes collection) is in form of:
* <nodes> at: <numeric constant>
* <nodes> first (second, third...
"{ Package: 'stx:goodies/petitparser/tests' }"
"{ NameSpace: Smalltalk }"
PPAbstractParserTest subclass:#PPConditionalParserTest
instanceVariableNames:'context'
classVariableNames:''
poolDictionaries:''
category:'PetitTests-Tests'
!
!PPConditionalParserTest methodsFor:'as yet unclassified'!
context
^ context
!
setUp
super setUp.
context := PPContext new
!
testConditionCtxAccess
| parser |
parser := ('a' asParser if: [ :ctx | (ctx propertyAt: #foo) = #bar ]).
context propertyAt: #foo put: #bar.
self assert: parser parse: 'a' .
context propertyAt: #foo put: #zorg.
self assert: parser fail: 'a' .
!
testConditionFalse
| parser |
parser := ('a' asParser if: [ :ctx | false ]).
self assert: parser fail: 'a'.
self assert: parser fail: 'b'.
!
testConditionTrue
| parser |
parser := ('a' asParser if: [ :ctx | true ]).
self assert: parser parse: 'a'.
self assert: parser fail: 'b'.
! !