aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdvard Thörnros <edvard.thornros@gmail.com>2021-02-10 23:05:45 +0100
committerEdvard Thörnros <edvard.thornros@gmail.com>2021-02-10 23:05:45 +0100
commit9bd53d666c32d93b6a81a05c15025fd41bd056ba (patch)
tree7c76d23d18b5764c21217969f54fa14d503cc411 /src
parent651865f41eea7a64093724ad664646eb76100ab1 (diff)
downloadsylt-9bd53d666c32d93b6a81a05c15025fd41bd056ba.tar.gz
add tests for constants
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ae45c45..cd84776 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -805,6 +805,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 {
@@ -848,7 +858,7 @@ mod tests {
test_multiple!(
if_,
compare_constants_equality: "if 1 == 2 {
- <!>
+
}",
compare_constants_unequality: "if 1 != 1 {
<!>
@@ -1050,4 +1060,16 @@ a.a <=> 0"
simple: "a := 1 // blargh \na += 1 // blargh \n a <=> 2 // HARGH",
expressions: "1 + 1 // blargh \n 2 // blargh \n // HARGH \n",
);
+
+ test_multiple!(
+ read_constants,
+ simple: "
+a :: 1
+a <=> 1
+b := 2
+{
+ a <=> 1
+}
+",
+ );
}