aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorEdvard Thörnros <edvard.thornros@gmail.com>2021-02-11 18:39:05 +0100
committerGitHub <noreply@github.com>2021-02-11 18:39:05 +0100
commitb09c97154886e1ca9e0a418f8969870a31f39077 (patch)
tree88273971103ff6a49295346a5415a1acd646e075 /src/lib.rs
parent6bd482f05c24f0aa1475c02d529f33ece40dee24 (diff)
parentd87c62959a784d15521a86508f2d63acb2206053 (diff)
downloadsylt-b09c97154886e1ca9e0a418f8969870a31f39077.tar.gz
Merge pull request #64 from FredTheDino/constants
constants
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 862e9fa..22b6713 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 {
<!>
@@ -1060,6 +1070,17 @@ a.a <=> 0"
);
test_multiple!(
+ read_constants,
+ simple: "
+a :: 1
+a <=> 1
+b := 2
+{
+ a <=> 1
+}",
+ );
+
+ test_multiple!(
assignment_op_regression,
simple_add: "
a := 0