tests/PPConditionalParserTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 02 May 2015 07:00:39 +0200
changeset 447 cfbc9055c83b
parent 427 a7f5e6de19d2
child 459 4751c407bb40
permissions -rw-r--r--
Removed tests from compiled packages to workaround bug in stc. stc does not compile { computed arrays } properly in all cases, resulting in messages being send to wrong objects.

"{ Package: 'stx:goodies/petitparser/tests' }"

"{ NameSpace: Smalltalk }"

PPAbstractParserTest subclass:#PPConditionalParserTests
	instanceVariableNames:'context'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitTests-Tests'
!

!PPConditionalParserTests 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'.
! !