compiler/tests/extras/PPCSmalltalkTests.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/extras' }"

"{ NameSpace: Smalltalk }"

TestCase subclass:#PPCSmalltalkTests
	instanceVariableNames:'compiler result'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Extras-Tests-Smalltalk'
!

!PPCSmalltalkTests methodsFor:'as yet unclassified'!

assert: parser parse: input
    result := parser parse: input.
    self assert: result isPetitFailure not.
!

setUp
    compiler := PPCCompiler newWithOptions: #(profile: true)

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

testSmalltakToken
    | token1  |
    token1 := compiler compile: 'a' asParser smalltalkToken.
    
    self assert: ((token1 parse: 'a') class == PPSmalltalkToken).
    self assert: (token1 parse: '"comment" a "another comment"') inputValue = 'a'

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

testSmalltakToken2
    | parser compiled  |
    parser := 'a' asParser smalltalkToken, 'b' asParser smalltalkToken.
    compiled := compiler compile: parser.
    
    self assert: compiled parse: 'ab'.
    self assert: compiled parse: '"comment" a "another comment" b '.
    self assert: result size = 2.
    self assert: result first inputValue = 'a'.
    self assert: result second inputValue = 'b'.
    
!

testSmalltakWhitespace
    | ws1 ws2 |
    ws1 := PPSmalltalkWhitespaceParser new.
    ws2 := PPSmalltalkWhitespaceParser new.
    
    self assert: ws1 = ws2.
    self assert: ws1 ~~ ws2.
    
    self assert: ws1 hash = ws2 hash.

    "Modified: / 30-07-2015 / 06:56:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !