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