compiler/tests/PPCOptimizeChoicesTest.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 19 Mar 2016 00:12:47 +0100
changeset 556 51c6afba5c91
parent 538 16e8536f5cfb
permissions -rw-r--r--
CI: Use VM provided by Pharo team on both Linux and Windows. Hand-crafter Pharo VM is no longer needed as the Linux slave in SWING build farm has been upgraded so it has compatible GLIBC. This makes CI scripts simpler and more usable for other people.

"{ 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
    ^ compiler compile: parser

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

setUp
    | options |

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

    "Modified: / 07-09-2015 / 10:22:37 / 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).
! !