-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparseTests.js
71 lines (71 loc) · 2.9 KB
/
parseTests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module.exports = function(string2ast) {
return [
[function() {
return string2ast('"this is a quote: \\" ..."').json(true); },
'"this is a quote: \\" ..."'],
[function() {
return string2ast('"this is a backslash: \\\\" ; this is a comment').json(true); },
'"this is a backslash: \\\\"'],
[function() {
return string2ast('(a\nb)').json(true); },
'[a, b]'],
[function() {
return string2ast('(+ 1 2)').json(true); },
'[+, 1, 2]'],
[function() {
return string2ast('(cat "hello" " world")').json(true); },
'[cat, "hello", " world"]'],
[function() {
return string2ast('[]').json(true); },
'[list]'],
[function() {
return string2ast(';; foo\n[]').json(true); },
'[list]'],
[function() {
return string2ast('[1];; bar\n').json(true); },
'[list, 1]'],
[function() {
return string2ast('[1 2 3]').json(true); },
'[list, 1, 2, 3]'],
[function() {
return string2ast('{}').json(true); },
'[object]'],
[function() {
return string2ast('{a 1 b 2}').json(true); },
'[object, a, 1, b, 2]'],
[function() {
return string2ast('{a [1 2 3] b [{x 4} {x 5} {x 6}]}').json(true); },
'[object, a, [list, 1, 2, 3], b, [list, [object, x, 4], [object, x, 5], ' +
'[object, x, 6]]]'],
[function() {
return string2ast('foo.bar').json(true); },
'[., foo, bar]'],
[function() {
return string2ast('foo.bar.baz').json(true); },
'[., foo, bar, baz]'],
[function() {
return string2ast('(a b).c.d').json(true); },
'[., [a, b], c, d]'],
[function() {
return string2ast('(console.log "Hello World!")').json(true); },
'[[., console, log], "Hello World!"]'],
[function() {
return string2ast('(($ "div#foo").css "background-color" "#ffaaaa")').json(true); },
'[[., [$, "div#foo"], css], "background-color", "#ffaaaa"]'],
[function() {
return string2ast('(($ "div#foo").css { background-color "#ffaaaa" padding "5em"})').json(true); },
'[[., [$, "div#foo"], css], [object, background-color, "#ffaaaa", ' +
'padding, "5em"]]'],
[function() {
return string2ast('(def empty? (# (l) (= 0 (length l))))').json(true); },
'[def, empty?, [#, [l], [=, 0, [length, l]]]]'],
[function() {
return string2ast(
'(def empty? (# (l) (if (= 0 (length l)) true false)))'
).json(true); },
'[def, empty?, [#, [l], [if, [=, 0, [length, l]], true, false]]]'],
[function() {
return string2ast('([1 2 3].slice 2 3)').json(true); },
'[[., [list, 1, 2, 3], slice], 2, 3]']
];
};