Portability: fixes for Smalltalk/X
* Do not use detect:ifFound: - not present in Smalltalk/X
* Removed leftover debugging code (Halt if:, ...)
* Do not use `aClass methods`, use `aClass methodDictionary values`
* Do not use #allPairsDo; - not present in Smalltalk/X
* Do not use #crShow: - not present in Smalltalk/X
* On Smalltalk?X use Filename - there's no FileReference in Smalltalk/X
* Do not use CharacterSet, use String
"{ 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'.
! !