20 lines
515 B
Bash
20 lines
515 B
Bash
#!/bin/sh
|
|
|
|
utest() {
|
|
PROGRAM="$PWD/build/dc"
|
|
EXPECTED="1011b"
|
|
ACTUAL=$("$PROGRAM" -e '2 d i o 1000 0011 } 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"
|
|
}
|
|
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|