equal
deleted
inserted
replaced
1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 TestCase subclass:#PEGFsaTransitionTest |
5 TestCase subclass:#PEGFsaTransitionTest |
6 instanceVariableNames:'t1 t2 result' |
6 instanceVariableNames:'t1 t2 result e1 e2' |
7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Tests-FSA' |
9 category:'PetitCompiler-Tests-FSA' |
10 ! |
10 ! |
11 |
11 |
12 !PEGFsaTransitionTest methodsFor:'as yet unclassified'! |
12 !PEGFsaTransitionTest methodsFor:'as yet unclassified'! |
13 |
13 |
14 setUp |
14 setUp |
15 t1 := PEGFsaTransition new. |
15 t1 := PEGFsaCharacterTransition new. |
16 t2 := PEGFsaTransition new. |
16 t2 := PEGFsaCharacterTransition new. |
17 ! |
17 |
|
18 e1 := PEGFsaEpsilonTransition new. |
|
19 e2 := PEGFsaEpsilonTransition new. |
|
20 ! ! |
|
21 |
|
22 !PEGFsaTransitionTest methodsFor:'character'! |
18 |
23 |
19 testCompare |
24 testCompare |
20 t1 addCharacter: $a. |
25 t1 addCharacter: $a. |
21 t1 addCharacter: $b. |
26 t1 addCharacter: $b. |
22 t2 addCharacter: $a. |
27 t2 addCharacter: $a. |
89 self assert: (result at: $a codePoint). |
94 self assert: (result at: $a codePoint). |
90 self assert: (result at: $b codePoint). |
95 self assert: (result at: $b codePoint). |
91 self assert: (result at: $c codePoint) not. |
96 self assert: (result at: $c codePoint) not. |
92 ! |
97 ! |
93 |
98 |
|
99 testEpsilonIntersection |
|
100 result := e1 intersection: e2. |
|
101 |
|
102 self assert: (result isEpsilon) |
|
103 ! |
|
104 |
94 testIntersection |
105 testIntersection |
95 t1 addCharacter: $a. |
106 t1 addCharacter: $a. |
96 t1 addCharacter: $b. |
107 t1 addCharacter: $b. |
97 t2 addCharacter: $b. |
108 t2 addCharacter: $b. |
98 t2 addCharacter: $c. |
109 t2 addCharacter: $c. |
126 self assert: (result at: $a codePoint). |
137 self assert: (result at: $a codePoint). |
127 self assert: (result at: $c codePoint). |
138 self assert: (result at: $c codePoint). |
128 self assert: (result at: $d codePoint) not. |
139 self assert: (result at: $d codePoint) not. |
129 ! ! |
140 ! ! |
130 |
141 |
|
142 !PEGFsaTransitionTest methodsFor:'tests - epsilon'! |
|
143 |
|
144 testCompareEpsilon |
|
145 |
|
146 self assert: e1 = e2. |
|
147 |
|
148 e1 destination: #a. |
|
149 e2 destination: #b. |
|
150 |
|
151 self assert: (e1 = e2) not. |
|
152 |
|
153 ! |
|
154 |
|
155 testCopyEpsilon |
|
156 |
|
157 e2 := e1 copy. |
|
158 |
|
159 |
|
160 self assert: e1 = e2. |
|
161 self assert: (e1 == e2) not. |
|
162 |
|
163 e2 destination: #foo. |
|
164 self assert: (e1 = e2) not. |
|
165 |
|
166 e1 destination: #foo. |
|
167 self assert: (e1 = e2). |
|
168 |
|
169 e1 priority: -1. |
|
170 self assert: (e1 = e2) not. |
|
171 |
|
172 e2 priority: -1. |
|
173 self assert: (e1 = e2). |
|
174 ! ! |
|
175 |