Skip to content

Commit cc912e6

Browse files
committed
Add compound assignment tests, fix missing match case for %=
1 parent 7858ab8 commit cc912e6

12 files changed

+68
-1
lines changed

src/compiler/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3041,7 +3041,7 @@ impl<'source, 'report, R: Reporter> RantParser<'source, 'report, R> {
30413041
}
30423042
},
30433043
// If we hit a compound assignment operator... well, it's a COMPOUND ASSIGNMENT setter!
3044-
comp_op @ (PlusEquals | MinusEquals | StarEquals | SlashEquals | DoubleStarEquals | AndEquals | VertBarEquals) => {
3044+
comp_op @ (PlusEquals | MinusEquals | StarEquals | SlashEquals | DoubleStarEquals | PercentEquals | AndEquals | VertBarEquals) => {
30453045
self.reader.skip_ws();
30463046

30473047
let ParsedSequence {

tests/runtime_tests.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,4 +830,44 @@ fn ops_or_short_circuit() {
830830
#[test]
831831
fn ops_xor() {
832832
test_rant_file!("sources/ops/xor.rant")
833+
}
834+
835+
#[test]
836+
fn access_add_assign() {
837+
test_rant_file!("sources/access/add_assign.rant");
838+
}
839+
840+
#[test]
841+
fn access_sub_assign() {
842+
test_rant_file!("sources/access/sub_assign.rant");
843+
}
844+
845+
#[test]
846+
fn access_mul_assign() {
847+
test_rant_file!("sources/access/mul_assign.rant");
848+
}
849+
850+
#[test]
851+
fn access_div_assign() {
852+
test_rant_file!("sources/access/div_assign.rant");
853+
}
854+
855+
#[test]
856+
fn access_pow_assign() {
857+
test_rant_file!("sources/access/pow_assign.rant");
858+
}
859+
860+
#[test]
861+
fn access_mod_assign() {
862+
test_rant_file!("sources/access/mod_assign.rant");
863+
}
864+
865+
#[test]
866+
fn access_and_assign() {
867+
test_rant_file!("sources/access/and_assign.rant");
868+
}
869+
870+
#[test]
871+
fn access_or_assign() {
872+
test_rant_file!("sources/access/or_assign.rant");
833873
}

tests/sources/access/add_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 1>
2+
<x += 1>
3+
[assert-eq: <x>; 2]

tests/sources/access/and_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = @true>
2+
<x &= @false>
3+
[assert-eq: <x>; @false]

tests/sources/access/compound_assign.rant

Whitespace-only changes.

tests/sources/access/div_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 20>
2+
<x /= 2>
3+
[assert-eq: <x>; 10]

tests/sources/access/mod_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 10>
2+
<x %= 3>
3+
[assert-eq: <x>; 1]

tests/sources/access/mul_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 2>
2+
<x *= 3>
3+
[assert-eq: <x>; 6]

tests/sources/access/or_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = @true>
2+
<x |= @false>
3+
[assert-eq: <x>; @true]

tests/sources/access/pow_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 2>
2+
<x **= 3>
3+
[assert-eq: <x>; 8]

tests/sources/access/sub_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = 1>
2+
<x -= 1>
3+
[assert-eq: <x>; 0]

tests/sources/access/xor_assign.rant

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<$x = @true>
2+
<x ^= @true>
3+
[assert-eq: <x>; @false]

0 commit comments

Comments
 (0)