compiler/tests/PPCOptimizeChoicesTest.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 24 Aug 2015 23:42:53 +0100
changeset 529 439c4057517f
parent 452 9f4558b3be66
child 534 a949c4fe44df
permissions -rw-r--r--
PPCConfiguration refactoring [1/10]: renamed PPCArguments to PPCCompilationOptions Renamed PPCConfiguration>>#arguments/#arguments: to #options/#options:

"{ 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
    | options |
    super setUp.

    visitor := PPCOptimizeChoices new.
    
    options := PPCCompilationOptions default
        profile: true.
                
    configuration := PPCPluggableConfiguration on: [ :_self | 
        _self toPPCIr.
        _self cacheFirstFollow.
    ].
    configuration options: options.

    "Modified: / 24-08-2015 / 23:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

testHasCommonPrefix
    | foo bar |
    foo := 'foo' asParser name: 'foo'; yourself.
    bar := 'bar' asParser.
    
    node := self asPPCTree: (foo, bar) / foo.

    self assert: (visitor hasCommonPrefix: node children).
! !