1 "{ Package: 'stx:goodies/petitparser/compiler/tests/extras' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler/tests/extras' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 TestCase subclass:#PPCSmalltalkTests |
5 TestCase subclass:#PPCSmalltalkTests |
6 instanceVariableNames:'compiler options result' |
6 instanceVariableNames:'compiler result' |
7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Extras-Tests-Smalltalk' |
9 category:'PetitCompiler-Extras-Tests-Smalltalk' |
10 ! |
10 ! |
11 |
11 |
15 result := parser parse: input. |
15 result := parser parse: input. |
16 self assert: result isPetitFailure not. |
16 self assert: result isPetitFailure not. |
17 ! |
17 ! |
18 |
18 |
19 setUp |
19 setUp |
20 options := PPCArguments default |
20 compiler := PPCCompiler newWithOptions: #(profile: true) |
21 profile: true; |
21 |
22 yourself. |
22 "Modified: / 07-09-2015 / 11:10:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
23 |
|
24 compiler := PPCTokenizingConfiguration new |
|
25 options: options; |
|
26 yourself. |
|
27 ! |
23 ! |
28 |
24 |
29 testSmalltakToken |
25 testSmalltakToken |
30 | token1 | |
26 | token1 | |
31 token1 := 'a' asParser smalltalkToken compileUsingCompiler:compiler. |
27 token1 := compiler compile: 'a' asParser smalltalkToken. |
32 |
28 |
33 self assert: ((token1 parse: 'a') class == PPSmalltalkToken). |
29 self assert: ((token1 parse: 'a') class == PPSmalltalkToken). |
34 self assert: (token1 parse: '"comment" a "another comment"') inputValue = 'a' |
30 self assert: (token1 parse: '"comment" a "another comment"') inputValue = 'a' |
|
31 |
|
32 "Modified: / 07-09-2015 / 12:36:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
35 ! |
33 ! |
36 |
34 |
37 testSmalltakToken2 |
35 testSmalltakToken2 |
38 | parser compiled | |
36 | parser compiled | |
39 parser := 'a' asParser smalltalkToken, 'b' asParser smalltalkToken. |
37 parser := 'a' asParser smalltalkToken, 'b' asParser smalltalkToken. |
40 compiled := parser compileUsingCompiler:compiler. |
38 compiled := compiler compile: parser. |
41 |
39 |
42 self assert: compiled parse: 'ab'. |
40 self assert: compiled parse: 'ab'. |
43 self assert: compiled parse: '"comment" a "another comment" b '. |
41 self assert: compiled parse: '"comment" a "another comment" b '. |
44 self assert: result size = 2. |
42 self assert: result size = 2. |
45 self assert: result first inputValue = 'a'. |
43 self assert: result first inputValue = 'a'. |