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