author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 14 Nov 2018 13:01:14 +0100 | |
changeset 642 | 77d5fddb6462 |
parent 426 | 2a65c972b937 |
permissions | -rw-r--r-- |
642
77d5fddb6462
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
426
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
77d5fddb6462
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
426
diff
changeset
|
2 |
|
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
3 |
"{ Package: 'stx:goodies/petitparser/tests' }" |
0 | 4 |
|
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
|
5 |
"{ 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
|
6 |
|
404
8da796db7f95
Removed class PPAbstractParseTest.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
376
diff
changeset
|
7 |
PPAbstractParserTest subclass:#PPMappingTest |
0 | 8 |
instanceVariableNames:'' |
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
11 |
category:'PetitTests-Tests' |
|
12 |
! |
|
13 |
||
14 |
||
15 |
!PPMappingTest methodsFor:'testing'! |
|
16 |
||
17 |
testFoldLeft2 |
|
18 |
| parser | |
|
32 | 19 |
parser := #any asParser star |
0 | 20 |
foldLeft: [ :a :b | Array with: a with: b ]. |
21 |
||
22 |
self assert: parser parse: #(a) to: #a. |
|
23 |
self assert: parser parse: #(a b) to: #(a b). |
|
24 |
self assert: parser parse: #(a b c) to: #((a b) c). |
|
25 |
self assert: parser parse: #(a b c d) to: #(((a b) c) d). |
|
26 |
self assert: parser parse: #(a b c d e) to: #((((a b) c) d) e) |
|
27 |
! |
|
28 |
||
29 |
testFoldLeft3 |
|
30 |
| parser | |
|
32 | 31 |
parser := #any asParser star |
0 | 32 |
foldLeft: [ :a :b :c | Array with: a with: b with: c ]. |
33 |
||
34 |
self assert: parser parse: #(a) to: #a. |
|
35 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
36 |
self assert: parser parse: #(a b c d e) to: #((a b c) d e) |
|
37 |
! |
|
38 |
||
39 |
testFoldRight2 |
|
40 |
| parser | |
|
32 | 41 |
parser := #any asParser star |
0 | 42 |
foldRight: [ :a :b | Array with: a with: b ]. |
43 |
||
44 |
self assert: parser parse: #(a) to: #a. |
|
45 |
self assert: parser parse: #(a b) to: #(a b). |
|
46 |
self assert: parser parse: #(a b c) to: #(a (b c)). |
|
47 |
self assert: parser parse: #(a b c d) to: #(a (b (c d))). |
|
48 |
self assert: parser parse: #(a b c d e) to: #(a (b (c (d e)))) |
|
49 |
! |
|
50 |
||
51 |
testFoldRight3 |
|
52 |
| parser | |
|
32 | 53 |
parser := #any asParser star |
0 | 54 |
foldRight: [ :a :b :c | Array with: a with: b with: c ]. |
55 |
||
56 |
self assert: parser parse: #(a) to: #a. |
|
57 |
self assert: parser parse: #(a b c) to: #(a b c). |
|
58 |
self assert: parser parse: #(a b c d e) to: #(a b (c d e)) |
|
59 |
! |
|
60 |
||
61 |
testMap1 |
|
62 |
| parser | |
|
32 | 63 |
parser := #any asParser |
0 | 64 |
map: [ :a | Array with: a ]. |
65 |
||
66 |
self assert: parser parse: #(a) to: #(a) |
|
67 |
! |
|
68 |
||
69 |
testMap2 |
|
70 |
| parser | |
|
32 | 71 |
parser := (#any asParser , #any asParser) |
0 | 72 |
map: [ :a :b | Array with: b with: a ]. |
73 |
||
74 |
self assert: parser parse: #(a b) to: #(b a) |
|
75 |
! |
|
76 |
||
77 |
testMap3 |
|
78 |
| parser | |
|
79 |
parser := (#any asParser , #any asParser , #any asParser) |
|
80 |
map: [ :a :b :c | Array with: c with: b with: a ]. |
|
81 |
||
82 |
self assert: parser parse: #(a b c) to: #(c b a) |
|
83 |
! ! |
|
84 |
||
85 |
!PPMappingTest class methodsFor:'documentation'! |
|
86 |
||
32 | 87 |
version |
88 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
89 |
! |
|
90 |
||
91 |
version_CVS |
|
92 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPMappingTest.st,v 1.3 2012-05-04 22:03:40 vrany Exp $' |
|
93 |
! |
|
94 |
||
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
|
95 |
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
|
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 |
^ '$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
|
98 |
! |
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
|
99 |
|
0 | 100 |
version_SVN |
642
77d5fddb6462
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
426
diff
changeset
|
101 |
^ '§Id: PPMappingTest.st 4 2010-12-18 17:02:23Z kursjan §' |
0 | 102 |
! ! |
376
a2656b27cace
Added monticelloName to package definition to ease export to .mcz
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
375
diff
changeset
|
103 |