25 lines
629 B
Bash
25 lines
629 B
Bash
#!/bin/sh
|
|
|
|
utest() {
|
|
PROGRAM="$PWD/build/dc"
|
|
EXPECTED="9"
|
|
ACTUAL=$("$PROGRAM" -e '5 4 + p')
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test empty stack
|
|
EXPECTED="'+' requires two operands"
|
|
ACTUAL=$("$PROGRAM" -e '+' 2>&1) || true
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test non numerical values
|
|
EXPECTED="'+' requires numeric values"
|
|
ACTUAL=$("$PROGRAM" -e '[ foo ] 5 +' 2>&1) || true
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test complex values
|
|
EXPECTED="(6,-4)"
|
|
ACTUAL=$("$PROGRAM" -e '2 -5 b 4 1 b + p')
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
}
|
|
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|