sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

0035-dc.sh (584B)


      1 #!/bin/sh
      2 
      3 tmp1=$$.tmp1
      4 tmp2=$$.tmp2
      5 
      6 trap 'rm -f $tmp1 $tmp2' EXIT
      7 trap 'exit $?' HUP INT TERM
      8 
      9 # Test negative number sqrt - should produce error message and push 0
     10 # Test negative numbers: integers, fractions, odd and even fraction digits
     11 ($EXEC ../dc <<EOF 2>$tmp2
     12 [test 1:]pc _1vp
     13 [test 2:]pc _4vp
     14 [test 3:]pc _.5vp
     15 [test 4:]pc _.25vp
     16 EOF
     17 cat $tmp2) > $tmp1
     18 
     19 diff -u - $tmp1 <<'EOF'
     20 test 1:
     21 0
     22 test 2:
     23 0
     24 test 3:
     25 0
     26 test 4:
     27 0
     28 ../dc: square root of negative number
     29 ../dc: square root of negative number
     30 ../dc: square root of negative number
     31 ../dc: square root of negative number
     32 EOF