author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 26 Oct 2014 01:28:07 +0000 | |
changeset 392 | 9b297f0d949c |
parent 376 | a2656b27cace |
child 404 | 8da796db7f95 |
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 |
|
3 |
PPAbstractParseTest subclass:#PPMappingTest |
|
4 |
instanceVariableNames:'' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'PetitTests-Tests' |
|
8 |
! |
|
9 |
||
10 |
||
11 |
!PPMappingTest methodsFor:'testing'! |
|
12 |
||
13 |
testFoldLeft2 |
|
14 |
| parser | |
|
32 | 15 |
parser := #any asParser star |
0 | 16 |
foldLeft: [ :a :b | Array with: a with: b ]. |
17 |
||
18 |
self assert: parser parse: #(a) to: #a. |
|
19 |
self assert: parser parse: #(a b) to: #(a b). |
|
20 |
self assert: parser parse: #(a b c) to: #((a b) c). |
|
21 |
self assert: parser parse: #(a b c d) to: #(((a b) c) d). |
|
22 |
self assert: parser parse: #(a b c d e) to: #((((a b) c) d) e) |
|
23 |
! |
|
24 |
||
25 |
testFoldLeft3 |
|
26 |
| parser | |
|
32 | 27 |
parser := #any asParser star |
0 | 28 |
foldLeft: [ :a :b :c | Array with: a with: b with: c ]. |
29 |
||
30 |
self assert: parser parse: #(a) to: #a. |
|
31 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
32 |
self assert: parser parse: #(a b c d e) to: #((a b c) d e) |
|
33 |
! |
|
34 |
||
35 |
testFoldRight2 |
|
36 |
| parser | |
|
32 | 37 |
parser := #any asParser star |
0 | 38 |
foldRight: [ :a :b | Array with: a with: b ]. |
39 |
||
40 |
self assert: parser parse: #(a) to: #a. |
|
41 |
self assert: parser parse: #(a b) to: #(a b). |
|
42 |
self assert: parser parse: #(a b c) to: #(a (b c)). |
|
43 |
self assert: parser parse: #(a b c d) to: #(a (b (c d))). |
|
44 |
self assert: parser parse: #(a b c d e) to: #(a (b (c (d e)))) |
|
45 |
! |
|
46 |
||
47 |
testFoldRight3 |
|
48 |
| parser | |
|
32 | 49 |
parser := #any asParser star |
0 | 50 |
foldRight: [ :a :b :c | Array with: a with: b with: c ]. |
51 |
||
52 |
self assert: parser parse: #(a) to: #a. |
|
53 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
54 |
self assert: parser parse: #(a b c d e) to: #(a b (c d e)) |
|
55 |
! |
|
56 |
||
57 |
testMap1 |
|
58 |
| parser | |
|
32 | 59 |
parser := #any asParser |
0 | 60 |
map: [ :a | Array with: a ]. |
61 |
||
62 |
self assert: parser parse: #(a) to: #(a) |
|
63 |
! |
|
64 |
||
65 |
testMap2 |
|
66 |
| parser | |
|
32 | 67 |
parser := (#any asParser , #any asParser) |
0 | 68 |
map: [ :a :b | Array with: b with: a ]. |
69 |
||
70 |
self assert: parser parse: #(a b) to: #(b a) |
|
71 |
! |
|
72 |
||
73 |
testMap3 |
|
74 |
| parser | |
|
75 |
parser := (#any asParser , #any asParser , #any asParser) |
|
76 |
map: [ :a :b :c | Array with: c with: b with: a ]. |
|
77 |
||
78 |
self assert: parser parse: #(a b c) to: #(c b a) |
|
79 |
! ! |
|
80 |
||
81 |
!PPMappingTest class methodsFor:'documentation'! |
|
82 |
||
32 | 83 |
version |
84 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
85 |
! |
|
86 |
||
87 |
version_CVS |
|
88 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
89 |
! |
|
90 |
||
0 | 91 |
version_SVN |
32 | 92 |
^ '§Id: PPMappingTest.st 4 2010-12-18 17:02:23Z kursjan §' |
0 | 93 |
! ! |
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
94 |