25 lines
628 B
Bash
25 lines
628 B
Bash
#!/bin/sh
|
|
|
|
utest() {
|
|
PROGRAM="$PWD/build/dc"
|
|
EXPECTED="25"
|
|
ACTUAL=$("$PROGRAM" -e '5 2 ^ 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 '5 [ foo ] ^' 2>&1) || true
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test complex values
|
|
EXPECTED="(-1,0.00)"
|
|
ACTUAL=$("$PROGRAM" -e '0 1 b 2 ^ p')
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
}
|
|
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|