compiler/tests/PPCOptimizeChoicesTest.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 07 Sep 2015 08:20:46 +0100
changeset 537 fb212e14d1f4
parent 535 a8feb0f47574
child 538 16e8536f5cfb
permissions -rw-r--r--
PPCConfiguration refactoring: [9/10]: Renamed PPCConfiguration to PPCCompiler.

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

"{ NameSpace: Smalltalk }"

TestCase subclass:#PPCOptimizeChoicesTest
	instanceVariableNames:'node result visitor compiler'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Tests-Visitors'
!

!PPCOptimizeChoicesTest methodsFor:'as yet unclassified'!

asPPCTree: parser
    ^ parser compileUsingCompiler: compiler

    "Modified: / 07-09-2015 / 10:08:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setUp
    | options |

    super setUp.
    visitor := PPCOptimizeChoices new.
    options := (PPCCompilationOptions default)
            profile:true;
            generate:false;
            tokenize:false;
            yourself.
    compiler := PPCCompiler new.
    compiler passes:{ PPCCacheFirstFollowPass }.
    compiler options:options.

    "Modified: / 04-09-2015 / 16:21:48 / 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).
! !