This commit is contained in:
parent
f2292c2598
commit
beee6a98d0
24
tests/test_sqrt
Normal file
24
tests/test_sqrt
Normal file
@ -0,0 +1,24 @@
|
||||
#!/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 domain error
|
||||
EXPECTED="'v' domain error"
|
||||
ACTUAL=$("$PROGRAM" -e '-1 v' 2>&1) || true
|
||||
assert_eq "$EXPECTED" "$ACTUAL"
|
||||
}
|
||||
# vim: ts=4 sw=4 softtabstop=4 expandtab:
|
Loading…
Reference in New Issue
Block a user