Skip to content

Commit

Permalink
Add some basic substring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylabbate committed Jun 13, 2022
1 parent b1c250d commit eab1aaa
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/expressions.bats
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@
[ "$output" -eq 1 ]
}

@test "Substring expressions" {
run bin/riff -e 'print("abc"[0])'
[ "$output" = "a" ]

run bin/riff -e 'print("abc"[2..])'
[ "$output" = "c" ]

run bin/riff -e 'print("abc"[-1])'
[ "$output" = "c" ]

run bin/riff -e 'print(#"abc"[2..])'
[ "$output" -eq 1 ]

run bin/riff -e 'print("abc"[2..0])'
[ "$output" = "cba" ]
}

@test "Misc. edge case expressions" {
run bin/riff -e 'print(a=b=7)'
[ "$output" -eq 7 ]
Expand Down

0 comments on commit eab1aaa

Please sign in to comment.