Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3eb594c
commit 46bfa25
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
def test() { | ||
x = 0 | ||
y = 1 | ||
if (y == 1) { | ||
x = 2 | ||
} | ||
assert(x == 2) | ||
|
||
if (y == 2) { | ||
x = 3 | ||
} | ||
assert(x == 2) | ||
|
||
if (y == 0) { | ||
x = 0 | ||
} else if (y == 1) { | ||
x = 1 | ||
} | ||
assert(x == 1) | ||
|
||
for (i in 0 .. 3) { | ||
if (i == 0) { | ||
assert(i == 0) | ||
} else if (i == 1) { | ||
assert(i == 1) | ||
} else if (i == 2) { | ||
assert(i == 2) | ||
} else { | ||
assert(i == 3) | ||
} | ||
} | ||
println("Conditional tests passed.") | ||
} | ||
|
||
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Tests for return values. | ||
|
||
def lastchar(x) { | ||
if (x != "") { | ||
y = @(echo -ne "$x" | tail -c 1) | ||
x = "$y" | ||
} | ||
return x | ||
} | ||
|
||
def test() { | ||
h = lastchar("hello") | ||
assert(h == "o") | ||
assert(lastchar("hello") == "o") | ||
assert(lastchar("") == "") | ||
println("Return value tests passed.") | ||
} | ||
|
||
# Include some module-level tests | ||
h = lastchar("hello") | ||
assert(h == "o") | ||
assert(lastchar("hello") == "o") | ||
|
||
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters