sbase

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

0037-dc.sh (909B)


      1 #!/bin/sh
      2 
      3 tmp=$$.tmp
      4 
      5 trap 'rm -f $tmp' EXIT
      6 trap 'exit $?' HUP INT TERM
      7 
      8 # Expected output for z, Z, and X operators
      9 cat <<EOF >$tmp
     10 test 1:
     11 0
     12 test 2:
     13 1
     14 test 3:
     15 2
     16 test 4:
     17 3
     18 test 5:
     19 5
     20 test 6:
     21 1
     22 test 7:
     23 3
     24 test 8:
     25 2
     26 test 9:
     27 3
     28 test 10:
     29 4
     30 test 11:
     31 1
     32 test 12:
     33 1
     34 test 13:
     35 1
     36 test 14:
     37 1
     38 test 15:
     39 1
     40 test 16:
     41 1
     42 test 17:
     43 0
     44 test 18:
     45 1
     46 test 19:
     47 2
     48 test 20:
     49 3
     50 test 21:
     51 5
     52 EOF
     53 
     54 # Test z (stack depth), Z (digit count/string length), X (scale)
     55 $EXEC ../dc <<EOF | diff -u $tmp -
     56 [test 1:]pc zp c
     57 [test 2:]pc 1 zp c
     58 [test 3:]pc 1 2 zp c
     59 [test 4:]pc 1 2 3 zp c
     60 [test 5:]pc 12345Zp c
     61 [test 6:]pc 0Zp c
     62 [test 7:]pc 123Zp c
     63 [test 8:]pc 1.5Zp c
     64 [test 9:]pc 1.23Zp c
     65 [test 10:]pc 1.001Zp c
     66 [test 11:]pc 0.5Zp c
     67 [test 12:]pc 0.05Zp c
     68 [test 13:]pc 0.005Zp c
     69 [test 14:]pc .5Zp c
     70 [test 15:]pc .05Zp c
     71 [test 16:]pc .005Zp c
     72 [test 17:]pc 0Xp c
     73 [test 18:]pc 1.2Xp c
     74 [test 19:]pc 1.23Xp c
     75 [test 20:]pc 1.234Xp c
     76 [test 21:]pc [hello]Zp c
     77 EOF