author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 24 Jul 2015 15:37:23 +0100 | |
changeset 503 | ff58cd9f1f3c |
parent 426 | 2a65c972b937 |
child 642 | 77d5fddb6462 |
permissions | -rw-r--r-- |
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
1 |
"{ Package: 'stx:goodies/petitparser/tests' }" |
0 | 2 |
|
426
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
3 |
"{ NameSpace: Smalltalk }" |
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
4 |
|
404
8da796db7f95
Removed class PPAbstractParseTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
376
diff
changeset
|
5 |
PPAbstractParserTest subclass:#PPMappingTest |
0 | 6 |
instanceVariableNames:'' |
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'PetitTests-Tests' |
|
10 |
! |
|
11 |
||
12 |
||
13 |
!PPMappingTest methodsFor:'testing'! |
|
14 |
||
15 |
testFoldLeft2 |
|
16 |
| parser | |
|
32 | 17 |
parser := #any asParser star |
0 | 18 |
foldLeft: [ :a :b | Array with: a with: b ]. |
19 |
||
20 |
self assert: parser parse: #(a) to: #a. |
|
21 |
self assert: parser parse: #(a b) to: #(a b). |
|
22 |
self assert: parser parse: #(a b c) to: #((a b) c). |
|
23 |
self assert: parser parse: #(a b c d) to: #(((a b) c) d). |
|
24 |
self assert: parser parse: #(a b c d e) to: #((((a b) c) d) e) |
|
25 |
! |
|
26 |
||
27 |
testFoldLeft3 |
|
28 |
| parser | |
|
32 | 29 |
parser := #any asParser star |
0 | 30 |
foldLeft: [ :a :b :c | Array with: a with: b with: c ]. |
31 |
||
32 |
self assert: parser parse: #(a) to: #a. |
|
33 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
34 |
self assert: parser parse: #(a b c d e) to: #((a b c) d e) |
|
35 |
! |
|
36 |
||
37 |
testFoldRight2 |
|
38 |
| parser | |
|
32 | 39 |
parser := #any asParser star |
0 | 40 |
foldRight: [ :a :b | Array with: a with: b ]. |
41 |
||
42 |
self assert: parser parse: #(a) to: #a. |
|
43 |
self assert: parser parse: #(a b) to: #(a b). |
|
44 |
self assert: parser parse: #(a b c) to: #(a (b c)). |
|
45 |
self assert: parser parse: #(a b c d) to: #(a (b (c d))). |
|
46 |
self assert: parser parse: #(a b c d e) to: #(a (b (c (d e)))) |
|
47 |
! |
|
48 |
||
49 |
testFoldRight3 |
|
50 |
| parser | |
|
32 | 51 |
parser := #any asParser star |
0 | 52 |
foldRight: [ :a :b :c | Array with: a with: b with: c ]. |
53 |
||
54 |
self assert: parser parse: #(a) to: #a. |
|
55 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
56 |
self assert: parser parse: #(a b c d e) to: #(a b (c d e)) |
|
57 |
! |
|
58 |
||
59 |
testMap1 |
|
60 |
| parser | |
|
32 | 61 |
parser := #any asParser |
0 | 62 |
map: [ :a | Array with: a ]. |
63 |
||
64 |
self assert: parser parse: #(a) to: #(a) |
|
65 |
! |
|
66 |
||
67 |
testMap2 |
|
68 |
| parser | |
|
32 | 69 |
parser := (#any asParser , #any asParser) |
0 | 70 |
map: [ :a :b | Array with: b with: a ]. |
71 |
||
72 |
self assert: parser parse: #(a b) to: #(b a) |
|
73 |
! |
|
74 |
||
75 |
testMap3 |
|
76 |
| parser | |
|
77 |
parser := (#any asParser , #any asParser , #any asParser) |
|
78 |
map: [ :a :b :c | Array with: c with: b with: a ]. |
|
79 |
||
80 |
self assert: parser parse: #(a b c) to: #(c b a) |
|
81 |
! ! |
|
82 |
||
83 |
!PPMappingTest class methodsFor:'documentation'! |
|
84 |
||
32 | 85 |
version |
86 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
87 |
! |
|
88 |
||
89 |
version_CVS |
|
90 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
91 |
! |
|
92 |
||
426
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
93 |
version_HG |
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
94 |
|
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
95 |
^ '$Changeset: <not expanded> $' |
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
96 |
! |
2a65c972b937
Tell stc to NOT to inline #not as it has different meaning in PetitParser...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
404
diff
changeset
|
97 |
|
0 | 98 |
version_SVN |
32 | 99 |
^ '§Id: PPMappingTest.st 4 2010-12-18 17:02:23Z kursjan §' |
0 | 100 |
! ! |
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
101 |