compiler/tests/PPCMergingVisitorTest.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 10 Jun 2020 21:33:27 +0100
changeset 650 4c6ed0a28d18
parent 524 f6f68d32de73
permissions -rw-r--r--
Replace `ifNil:[...]` with `isNil ifTrue:[...]` The latter is optimized by compilers and therefore faster.

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

"{ NameSpace: Smalltalk }"

TestCase subclass:#PPCMergingVisitorTest
	instanceVariableNames:'node result visitor node1 node2'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Tests-Visitors'
!


!PPCMergingVisitorTest methodsFor:'as yet unclassified'!

nilNode
    ^ PPCNilNode new
!

setUp
    visitor := PPCMergingVisitor new
!

testNilNode
    node1 := self nilNode.
    node2 := self nilNode.
    
    node := PPCSequenceNode new
        children: { node1 . node2 }.
        
    self assert: (node children first == node children second) not.
    node := visitor visit: node.
    self assert: (node children first == node children second).
!

testNilNode2
    node1 := self nilNode
        name: #foo;
        yourself.
    node2 := self nilNode
        name: #bar;
        yourself.
    
    node := PPCSequenceNode new
        children: { node1 . node2 }.
        
    self assert: (node children first == node children second) not.
    node := visitor visit: node.
    self assert: (node children first == node children second) not.
! !

!PPCMergingVisitorTest class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !