aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/lex/tests.rs
diff options
context:
space:
mode:
authorTolmachev Igor <me@igorek.dev>2026-05-10 12:47:18 +0300
committerTolmachev Igor <me@igorek.dev>2026-05-10 12:47:37 +0300
commit1801afdbd0058cc9cc040b977de0d5652d65aab9 (patch)
treefafafb12e7d877f506e022ecb282e66cecb72bdc /compiler/src/lex/tests.rs
parent160b64427d79290a59ac48c9babca064232d8dfd (diff)
downloadcrisp-1801afdbd0058cc9cc040b977de0d5652d65aab9.tar.gz
crisp-1801afdbd0058cc9cc040b977de0d5652d65aab9.zip
Remove Quote from parser
Dropped to make the language simpler.
Diffstat (limited to 'compiler/src/lex/tests.rs')
-rw-r--r--compiler/src/lex/tests.rs63
1 files changed, 0 insertions, 63 deletions
diff --git a/compiler/src/lex/tests.rs b/compiler/src/lex/tests.rs
index 2d872a2..d0ed658 100644
--- a/compiler/src/lex/tests.rs
+++ b/compiler/src/lex/tests.rs
@@ -38,24 +38,6 @@ fn test_parens() {
38} 38}
39 39
40#[test] 40#[test]
41fn test_quote() {
42 let cases = vec![
43 ("'", vec![Quote]),
44 ("'a", vec![Quote, Symbol("a")]),
45 ("''a", vec![Quote, Quote, Symbol("a")]),
46 ("'()", vec![Quote, LeftPar, RightPar]),
47 (
48 "'(1 2)",
49 vec![Quote, LeftPar, Number("1"), Number("2"), RightPar],
50 ),
51 ("(' )", vec![LeftPar, Quote, RightPar]),
52 ];
53 for (code, tokens) in cases {
54 assert_eq!(tokenize(code), tokens);
55 }
56}
57
58#[test]
59fn test_numbers() { 41fn test_numbers() {
60 let cases = vec![ 42 let cases = vec![
61 ("0", vec![Number("0")]), 43 ("0", vec![Number("0")]),
@@ -83,7 +65,6 @@ fn test_strings() {
83 (r#""hello""#, vec![String("hello")]), 65 (r#""hello""#, vec![String("hello")]),
84 (r#""hello world""#, vec![String("hello world")]), 66 (r#""hello world""#, vec![String("hello world")]),
85 (r#""(not a list)""#, vec![String("(not a list)")]), 67 (r#""(not a list)""#, vec![String("(not a list)")]),
86 (r#""'not a quote""#, vec![String("'not a quote")]),
87 (r#""; not a comment""#, vec![String("; not a comment")]), 68 (r#""; not a comment""#, vec![String("; not a comment")]),
88 (r#"" spaces ""#, vec![String(" spaces ")]), 69 (r#"" spaces ""#, vec![String(" spaces ")]),
89 ]; 70 ];
@@ -96,7 +77,6 @@ fn test_strings() {
96fn test_string_escapes() { 77fn test_string_escapes() {
97 let cases = vec![ 78 let cases = vec![
98 (r#""line\nbreak""#, vec![String(r"line\nbreak")]), 79 (r#""line\nbreak""#, vec![String(r"line\nbreak")]),
99 (r#""with \"quotes\"""#, vec![String(r#"with \"quotes\""#)]),
100 (r#""\\""#, vec![String(r"\\")]), 80 (r#""\\""#, vec![String(r"\\")]),
101 ("\"single\\\nline\"", vec![String("single\\\nline")]), 81 ("\"single\\\nline\"", vec![String("single\\\nline")]),
102 ]; 82 ];
@@ -169,7 +149,6 @@ fn test_no_separators() {
169 ("(foo)", vec![LeftPar, Symbol("foo"), RightPar]), 149 ("(foo)", vec![LeftPar, Symbol("foo"), RightPar]),
170 ("(1)", vec![LeftPar, Number("1"), RightPar]), 150 ("(1)", vec![LeftPar, Number("1"), RightPar]),
171 ("(a)b", vec![LeftPar, Symbol("a"), RightPar, Symbol("b")]), 151 ("(a)b", vec![LeftPar, Symbol("a"), RightPar, Symbol("b")]),
172 ("'(a)", vec![Quote, LeftPar, Symbol("a"), RightPar]),
173 (r#"("s")"#, vec![LeftPar, String("s"), RightPar]), 152 (r#"("s")"#, vec![LeftPar, String("s"), RightPar]),
174 ]; 153 ];
175 for (code, tokens) in cases { 154 for (code, tokens) in cases {
@@ -212,23 +191,6 @@ fn test_expressions() {
212 vec![LeftPar, Symbol("+"), Number("1"), Number("2"), RightPar], 191 vec![LeftPar, Symbol("+"), Number("1"), Number("2"), RightPar],
213 ), 192 ),
214 ( 193 (
215 "(if (= x 0) 'zero 'nonzero)",
216 vec![
217 LeftPar,
218 Symbol("if"),
219 LeftPar,
220 Symbol("="),
221 Symbol("x"),
222 Number("0"),
223 RightPar,
224 Quote,
225 Symbol("zero"),
226 Quote,
227 Symbol("nonzero"),
228 RightPar,
229 ],
230 ),
231 (
232 r#"(print "hello, world")"#, 194 r#"(print "hello, world")"#,
233 vec![LeftPar, Symbol("print"), String("hello, world"), RightPar], 195 vec![LeftPar, Symbol("print"), String("hello, world"), RightPar],
234 ), 196 ),
@@ -248,17 +210,6 @@ fn test_expressions() {
248 RightPar, 210 RightPar,
249 ], 211 ],
250 ), 212 ),
251 (
252 "'(1 2 3)",
253 vec![
254 Quote,
255 LeftPar,
256 Number("1"),
257 Number("2"),
258 Number("3"),
259 RightPar,
260 ],
261 ),
262 ]; 213 ];
263 for (code, tokens) in cases { 214 for (code, tokens) in cases {
264 assert_eq!(tokenize(code), tokens); 215 assert_eq!(tokenize(code), tokens);
@@ -367,17 +318,3 @@ fn test_span_after_comment() {
367 let s = spans("; cm\nfoo"); 318 let s = spans("; cm\nfoo");
368 assert_eq!(s, vec![(Pos::new(2, 0, 5), Pos::new(2, 3, 8))]); 319 assert_eq!(s, vec![(Pos::new(2, 0, 5), Pos::new(2, 3, 8))]);
369} 320}
370
371#[test]
372fn test_span_after_quote() {
373 // 'hello
374 // 0123456
375 let s = spans("'hello");
376 assert_eq!(
377 s,
378 vec![
379 (Pos::new(1, 0, 0), Pos::new(1, 1, 1)),
380 (Pos::new(1, 1, 1), Pos::new(1, 6, 6))
381 ]
382 );
383}