Skip to content

Commit

Permalink
feat(test): still moving
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed Jul 11, 2024
1 parent e200d03 commit 499ef36
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 78 deletions.
78 changes: 0 additions & 78 deletions src/tests/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,6 @@ fn validity_test(input: &str) {
test_amber!(code, output);
}

#[test]
fn chained_modifiers_functions() {
let code = "
fun foo(a) {
echo a
fail 1
}
fun bar() {
echo \"this should not appear\"
}
unsafe foo(\"one\")
unsafe {
foo(\"two\")
}
unsafe silent foo(\"this should not appear\")
silent bar()
";
test_amber!(code, "one\ntwo");
}

#[test]
fn variable_ref_set_text() {
let code = "
fun foo(ref a) {
a = \"one\"
}
let a = \"two\"
foo(a)
echo a
";
test_amber!(code, "one");
}

#[test]
fn variable_ref_set_num() {
let code = "
fun foo(ref a) {
a = 42
}
let a = 24
foo(a)
echo a
";
test_amber!(code, "42");
}

#[test]
fn variable_ref_set_bool() {
let code = "
fun foo(ref a) {
a = false
}
let a = true
foo(a)
echo a
";
test_amber!(code, "0");
}

#[test]
fn variable_ref_set_array() {
let code = "
fun foo(ref a) {
a = [1, 2, 3]
}
let a = [3, 2, 1]
foo(a)
echo a
";
test_amber!(code, "1 2 3");
}

#[test]
fn variable_ref_add_shorthand_text() {
let code = "
Expand Down
15 changes: 15 additions & 0 deletions src/tests/validity/chained_modifiers_functions.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fun foo(a) {
echo a
fail 1
}

fun bar() {
echo "this should not appear"
}

unsafe foo("one")
unsafe {
foo("two")
}
unsafe silent foo("this should not appear")
silent bar()
2 changes: 2 additions & 0 deletions src/tests/validity/chained_modifiers_functions.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
one
two
7 changes: 7 additions & 0 deletions src/tests/validity/variable_ref_set_array.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fun foo(ref a) {
a = [1, 2, 3]
}

let a = [3, 2, 1]
foo(a)
echo a
1 change: 1 addition & 0 deletions src/tests/validity/variable_ref_set_array.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2 3
7 changes: 7 additions & 0 deletions src/tests/validity/variable_ref_set_bool.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fun foo(ref a) {
a = false
}

let a = true
foo(a)
echo a
1 change: 1 addition & 0 deletions src/tests/validity/variable_ref_set_bool.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
7 changes: 7 additions & 0 deletions src/tests/validity/variable_ref_set_num.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fun foo(ref a) {
a = 42
}

let a = 24
foo(a)
echo a
1 change: 1 addition & 0 deletions src/tests/validity/variable_ref_set_num.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
7 changes: 7 additions & 0 deletions src/tests/validity/variable_ref_set_text.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fun foo(ref a) {
a = "one"
}

let a = "two"
foo(a)
echo a
1 change: 1 addition & 0 deletions src/tests/validity/variable_ref_set_text.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
one

0 comments on commit 499ef36

Please sign in to comment.