diff options
| author | Mustafa Quraish <[email protected]> | 2022-01-29 12:31:14 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-01-29 12:31:14 -0500 |
| commit | 0ff4735622a22b0630669307a78bced7c20d5bdc (patch) | |
| tree | 9ab76b0efe6c90b722b1bfc5aed03b410f9b5e63 /tests/variables.sh | |
| parent | Now supporting local variables! :^) (diff) | |
| download | cup-0ff4735622a22b0630669307a78bced7c20d5bdc.tar.xz cup-0ff4735622a22b0630669307a78bced7c20d5bdc.zip | |
Add some tests for local variables
Diffstat (limited to 'tests/variables.sh')
| -rwxr-xr-x | tests/variables.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/variables.sh b/tests/variables.sh new file mode 100755 index 0000000..94010d7 --- /dev/null +++ b/tests/variables.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +. tests/common.sh + +set -e + +echo -n "- One variable: " +assert_exit_status 'fn main() { let x: int = 45; return 1; }' 1 +assert_exit_status 'fn main() { let x: int = 45; return x; }' 45 +assert_exit_status 'fn main() { let x: int = 45; return x+x; }' 90 +echo " OK" + +echo -n "- Multiple variable: " + +assert_exit_status_stdin 2 <<EOF +fn main() { + let x: int = 1; + let y: int = x + x; + return y; +} +EOF + +assert_exit_status_stdin 23 <<EOF +fn main() { + let x: int = 1; + let y: int = x + x; + let z: int = y + y; + let w: int = z + z; + let r: int = w + w; + return r + x + y + z; +} +EOF + +echo " OK" |