diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-02-11 18:42:04 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-02-11 18:42:04 +0100 |
| commit | 4e6f4ff865a132df3e7a6f39f481f78c6fc1df47 (patch) | |
| tree | a9f1ea95995b8b24758ee4d368313ec0e9809c3e /src/lib.rs | |
| parent | 04b0c68a792cc9be4dea92bb8750d7990bd43cc8 (diff) | |
| parent | b09c97154886e1ca9e0a418f8969870a31f39077 (diff) | |
| download | sylt-4e6f4ff865a132df3e7a6f39f481f78c6fc1df47.tar.gz | |
Merge remote-tracking branch 'origin/main' into break-continue
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 59 |
1 files changed, 58 insertions, 1 deletions
@@ -813,6 +813,16 @@ mod tests { assert_errs!(run_string("<!>\n", true, Vec::new()), [ErrorKind::Unreachable]); } + #[test] + fn assign_to_constant() { + assert_errs!(run_string("a :: 2\na = 2", true, Vec::new()), [ErrorKind::SyntaxError(_, _)]); + } + + #[test] + fn assign_to_constant_upvalue() { + assert_errs!(run_string("a :: 2\nq :: fn { a = 2 }\n", true, Vec::new()), [ErrorKind::SyntaxError(_, _)]); + } + macro_rules! test_multiple { ($mod:ident, $( $fn:ident : $prog:literal ),+ $( , )? ) => { mod $mod { @@ -856,7 +866,7 @@ mod tests { test_multiple!( if_, compare_constants_equality: "if 1 == 2 { - <!> + <!> }", compare_constants_unequality: "if 1 != 1 { <!> @@ -1054,6 +1064,14 @@ a.a <=> 0" ); test_multiple!( + fancy_call, + not: "f := fn {}\n f!\n", + one_arg: "f := fn a:int { a <=> 1 }\n f! 1\n", + two_arg: "f := fn a:int, b:int { b <=> 3 }\n f! 1, 1 + 2\n", + three_arg: "f := fn a:int, b:int, c:int { c <=> 13 }\n f! 1, 1 + 2, 1 + 4 * 3\n", + ); + + test_multiple!( newline_regression, simple: "a := 1 // blargh \na += 1 // blargh \n a <=> 2 // HARGH", expressions: "1 + 1 // blargh \n 2 // blargh \n // HARGH \n", @@ -1114,6 +1132,45 @@ for i := 0, i < 4, i += 1 { } a <=> 3 ", + ); + + test_multiple!( + read_constants, + simple: " +a :: 1 +a <=> 1 +b := 2 +{ + a <=> 1 +}", + ); + test_multiple!( + assignment_op_regression, + simple_add: " +a := 0 +b := 99999 +a += 1 +a <=> 1 +", + + simple_sub: " +a := 0 +b := 99999 +a -= 1 +a <=> -1 +", + + strange: " +a := 0 +{ + b := 99999 + { + a := 99999 + } + a -= 1 +} +a <=> -1 +", ); } |
