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 20fa206 commit 4645ac7
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 100 deletions.
100 changes: 0 additions & 100 deletions src/tests/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,106 +19,6 @@ fn validity_test(input: &str) {
test_amber!(code, output);
}

#[test]
fn shorthand_sub() {
let code = "
let x = 64
x -= 16
echo x
";
test_amber!(code, "48");
}

#[test]
fn shorthand_mul() {
let code = "
let x = 16
x *= 4
echo x
";
test_amber!(code, "64");
}

#[test]
fn shorthand_div() {
let code = "
let x = 21
x /= 3
echo x
";
test_amber!(code, "7");
}

#[test]
fn if_statements_singleline() {
let code = "
let x = 42
let y = 24
if x == y: echo x
else: echo y
";
test_amber!(code, "24");
}

#[test]
fn if_statements_else_singleline() {
let code = "
let x = 42
let y = 24
if x == y: echo x
else: echo y
";
test_amber!(code, "24");
}

#[test]
fn if_statement_chain_singleline() {
let code = "
let x = 42
let y = 24
if {
x == y: echo x
else: echo y
}
";
test_amber!(code, "24");
}

#[test]
fn ternary_conditional_simple() {
let code = "
let a = 12 > 24
then 42
else 24
echo a
";
test_amber!(code, "24");
}

#[test]
fn ternary_conditional_inline() {
let code = "
let a = 12 > 24 then 42 else 24
echo a
";
test_amber!(code, "24");
}

#[test]
fn ternary_conditional_nested() {
let code = "
let a = 24 > 12
then (12 > 24
then 42
else 24)
else (12 > 6
then 24
else 12)
echo a
";
test_amber!(code, "24");
}

#[test]
fn infinite_loop() {
let code = "
Expand Down
6 changes: 6 additions & 0 deletions src/tests/validity/if_statement_chain_singleline.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let x = 42
let y = 24
if {
x == y: echo x
else: echo y
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
4 changes: 4 additions & 0 deletions src/tests/validity/if_statements_else_singleline.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let x = 42
let y = 24
if x == y: echo x
else: echo y
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
4 changes: 4 additions & 0 deletions src/tests/validity/if_statements_singleline.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let x = 42
let y = 24
if x == y: echo x
else: echo y
1 change: 1 addition & 0 deletions src/tests/validity/if_statements_singleline.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
3 changes: 3 additions & 0 deletions src/tests/validity/shorthand_div.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let x = 21
x /= 3
echo x
1 change: 1 addition & 0 deletions src/tests/validity/shorthand_div.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
3 changes: 3 additions & 0 deletions src/tests/validity/shorthand_mul.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let x = 16
x *= 4
echo x
1 change: 1 addition & 0 deletions src/tests/validity/shorthand_mul.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
64
3 changes: 3 additions & 0 deletions src/tests/validity/shorthand_sub.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let x = 64
x -= 16
echo x
1 change: 1 addition & 0 deletions src/tests/validity/shorthand_sub.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
48
2 changes: 2 additions & 0 deletions src/tests/validity/ternary_conditional_inline.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let a = 12 > 24 then 42 else 24
echo a
1 change: 1 addition & 0 deletions src/tests/validity/ternary_conditional_inline.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
8 changes: 8 additions & 0 deletions src/tests/validity/ternary_conditional_nested.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let a = 24 > 12
then (12 > 24
then 42
else 24)
else (12 > 6
then 24
else 12)
echo a
1 change: 1 addition & 0 deletions src/tests/validity/ternary_conditional_nested.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
4 changes: 4 additions & 0 deletions src/tests/validity/ternary_conditional_simple.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let a = 12 > 24
then 42
else 24
echo a
1 change: 1 addition & 0 deletions src/tests/validity/ternary_conditional_simple.output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24

0 comments on commit 4645ac7

Please sign in to comment.