"{ Package: 'stx:goodies/petitparser/compiler/tests' }"
"{ NameSpace: Smalltalk }"
TestCase subclass:#PPCOptimizeChoicesTest
instanceVariableNames:'node result visitor configuration'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Tests-Visitors'
!
!PPCOptimizeChoicesTest methodsFor:'as yet unclassified'!
asPPCTree: parser
^ parser compileWithConfiguration: configuration
!
setUp
| arguments |
super setUp.
visitor := PPCOptimizeChoices new.
arguments := PPCArguments default
profile: true.
configuration := PPCPluggableConfiguration on: [ :_self |
_self toPPCIr.
_self cacheFirstFollow.
].
configuration arguments: arguments.
!
testHasCommonPrefix
| foo bar |
foo := 'foo' asParser name: 'foo'; yourself.
bar := 'bar' asParser.
node := self asPPCTree: (foo, bar) / foo.
self assert: (visitor hasCommonPrefix: node children).
! !