equal
deleted
inserted
replaced
|
1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 PPCompositeParserTest subclass:#PPExpressionGrammarTest |
|
6 instanceVariableNames:'' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'PetitCompiler-Tests-ExpressionGrammar' |
|
10 ! |
|
11 |
|
12 !PPExpressionGrammarTest methodsFor:'as yet unclassified'! |
|
13 |
|
14 parserClass |
|
15 ^ PPExpressionGrammar |
|
16 ! |
|
17 |
|
18 testNumber |
|
19 result := self parse: '1' rule: #number. |
|
20 self assert: result = 1. |
|
21 ! |
|
22 |
|
23 testTerm |
|
24 result := self parse: '1 + 2' rule: #term. |
|
25 self assert: result size = 3. |
|
26 self assert: result first = 1. |
|
27 self assert: result second inputValue = '+'. |
|
28 self assert: result third = 2. |
|
29 |
|
30 ! |
|
31 |
|
32 testTerm2 |
|
33 result := self parse: '1 + 2 * 3' rule: #term. |
|
34 self assert: result size = 3. |
|
35 self assert: result second inputValue = '+'. |
|
36 self assert: result first = 1. |
|
37 self assert: result third isArray. |
|
38 ! |
|
39 |
|
40 testTerm3 |
|
41 result := self parse: '1 * 2 + 3' rule: #term. |
|
42 self assert: result size = 3. |
|
43 self assert: result second inputValue = '+'. |
|
44 self assert: result first isArray. |
|
45 self assert: result third = 3. |
|
46 ! ! |
|
47 |