20 lines
541 B
Bash
20 lines
541 B
Bash
#!/bin/sh
|
|
|
|
utest() {
|
|
PROGRAM="$PWD/build/dc"
|
|
EXPECTED="100000b" # 32
|
|
ACTUAL=$("$PROGRAM" -e '2 d i o 10000000000 101 M p') # 1024 / 2^5
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test empty stack
|
|
EXPECTED="'M' requires two operands"
|
|
ACTUAL=$("$PROGRAM" -e 'M' 2>&1) || true
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
|
|
# Test non numerical values
|
|
EXPECTED="'M' requires numeric values"
|
|
ACTUAL=$("$PROGRAM" -e '5 [ foo ] M' 2>&1) || true
|
|
assert_eq "$EXPECTED" "$ACTUAL"
|
|
}
|
|
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|