This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
005parse.test.cc
67 lines (56 loc) · 1.7 KB
/
005parse.test.cc
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
void test_parse_handles_empty_stream() {
read_all("");
CHECK_TRACE_CONTENTS("parse", "");
}
void test_parse_handles_trailing_comment() {
read_all("34 # abc");
CHECK_TRACE_CONTENTS("parse", "34");
}
void test_parse_handles_atom() {
read_all("34");
CHECK_TRACE_CONTENTS("parse", "34");
}
void test_parse_handles_atoms() {
read_all("34\n\"a b c\"\n3.4");
CHECK_TRACE_CONTENTS("parse", "34\"a b c\"3.4");
}
void test_parse_handles_forms() {
read_all("(34 \"a b c\")");
CHECK_TRACE_TOP("parse", "(34 \"a b c\")");
}
void test_parse_handles_nested_forms() {
read_all("(34 (2 3) \"a b c\")");
CHECK_TRACE_CONTENTS("parse", 1, "(34 (2 3) \"a b c\")");
CHECK_TRACE_CONTENTS("parse", 2, "34(2 3)\"a b c\"");
CHECK_TRACE_CONTENTS("parse", 3, "23");
}
void test_parse_handles_nested_forms_with_comments() {
read_all("(a b (c d #\n))");
CHECK_TRACE_CONTENTS("parse", 1, "(a b (c d))");
CHECK_TRACE_CONTENTS("parse", 2, "ab(c d)");
}
void test_parse_handles_quotes() {
read_all("(34 `(2 ,b) ',35 ,',36 ,'a)");
CHECK_TRACE_CONTENTS("parse", 1, "(34 `(2 ,b) ',35 ,',36 ,'a)");
CHECK_TRACE_CONTENTS("parse", 2, "34`(2 ,b)',35,',36,'a");
}
void test_parse_handles_splice_operators() {
read_all("`(2 ,@b)");
CHECK_TRACE_CONTENTS("parse", 1, "`(2 ,@b)");
CHECK_TRACE_CONTENTS("parse", 2, "2,@b");
}
void test_parse_handles_indented_toplevel_forms() {
read_all("a\n a b c\n d");
CHECK_TRACE_CONTENTS("parse", 1, "a(a b c d)");
CHECK_TRACE_CONTENTS("parse", 2, "abcd");
}
void test_syntax_error() {
Hide_warnings = true;
read_all("(a b\n");
CHECK_TRACE_WARNS();
}
void test_syntax_error2() {
Hide_warnings = true;
read_all("a b)\n");
CHECK_TRACE_WARNS();
}