############################################################################### # # File: # equations.txt # # Purpose: # This file is used as input for the eqn_regr_test.py script, which # exercises the eqn_test_driver SHARE executable. # # This first version is a decent start, and exercises SHARE 57334, but it # will no doubt need some additional test cases. # # Comments are lines that start with a '#'. Comments may be added to the # end of a line if they start with '=#' since the parser tokenizes by '='. # # History: # # Date PR Who Why # ------------------------------------------------------------------------- # 30May2006 57334 Sontag First version # ############################################################################### # # EQUATION = SOLUTION #------------------------------------------------------------------------------ # # Parsing basic integer operations: +,-,*,/ # 1+1 = 2 3+4 = 7 5-3 = 2 3-5 = -2 4*8 = 32 12*12 = 144 12/12 = 1 10/5 = 2 746234321*234234.0 = 174793449945114 # integer truncation 10/3 = 3 10/6 = 1 # # Parsing negatives # -7+3 = -4 7+-3 = 4 -7+-3 = -10 3+-9 = -6 13--7 = 20 13-(-7) = 20 -13--7 = -6 -13-(-7) = -6 # # Parsing float operations # 4.2734+89.34 = 93.6134 88.00-44.1 = 43.9 88.0/4 = 22 38495*1.111 = 42767.945 # # Unary operators # CEIL(1.3) = 2 CEIL(1.5) = 2 CEIL(-1.7) = -1 FLOOR(1.5) = 1 FLOOR(1.9) = 1 FLOOR(-1.3) = -2 # unaries in mixed expressions 3+CEIL(1.3) = 5 3-CEIL(1.5) = 1 -5+CEIL(-1.7) = -6 FLOOR(1.5)-3 = -2 FLOOR(1.9)+4 = 5 -FLOOR(-1.3)-2 = 0 # # Parsing expressions with exponential notation (on both/either sides) # Here we really need to exercise all combinations of lhs/rhs with +,-,*,/ # 5.1234E+8+7 = 512340007 5.1234E+8-7 = 512339993 5.1234E-8-7 = -6.999999948766 5.1234E-8+7 = 7.000000051234 (5.1234E+8)+7 = 512340007 #5.1234E+(8+7) = 15 =# eqn s/w throws away the 5.1234E -5.1234E+8+7 = -512339993 -5.1234E+8-7 = -512340007 -5.1234E-8-7 = -7.000000051234 -5.1234E-8+7 = 6.999999948766 (-5.1234E+8)+7 = -512339993 # 7+5.1234E+8 = 512340007 7-5.1234E+8 = -512339993 7-5.1234E-8 = 6.999999948766 7+5.1234E-8 = 7.000000051234 7-(5.1234E+8) = -512339993 -7+5.1234E+8 = 512339993 -7-5.1234E+8 = -512340007 -7-5.1234E-8 = -7.000000051234 -7+5.1234E-8 = -6.999999948766 -7-(5.1234E+8) = -512340007 # # a 2nd batch of the above, but using the redundant preceeding '+' +5.1234E+8+7 = 512340007 +5.1234E+8-7 = 512339993 +5.1234E-8-7 = -6.999999948766 +5.1234E-8+7 = 7.000000051234 +(5.1234E+8)+7 = 512340007 +7+5.1234E+8 = 512340007 +7-5.1234E+8 = -512339993 +7-5.1234E-8 = 6.999999948766 +7+5.1234E-8 = 7.000000051234 +7-(5.1234E+8) = -512339993 # # a 3rd batch of the above, but using lowercase 'e' versus 'E' +5.1234e+8+7 = 512340007 +5.1234e+8-7 = 512339993 +5.1234e-8-7 = -6.999999948766 +5.1234e-8+7 = 7.000000051234 +(5.1234e+8)+7 = 512340007 7+5.1234e+8 = 512340007 7-5.1234e+8 = -512339993 7-5.1234e-8 = 6.999999948766 7+5.1234e-8 = 7.000000051234 7-(5.1234e+8) = -512339993 # # a 4th batch of the above, but including leading 0's 5.1234E+08+7 = 512340007 05.1234E+08+7 = 512340007 0.51234E+9+7 = 512340007 0.51234E+09+07 = 512340007 5.1234E-08+7 = 7.000000051234 05.1234E-08+7 = 7.000000051234 0.51234E-7+7 = 7.000000051234 0.51234E-07+07 = 7.000000051234 7+5.1234E+08 = 512340007 7+05.1234E+08 = 512340007 7+0.51234E+9 = 512340007 07+0.51234E+09 = 512340007 7+5.1234E-08 = 7.000000051234 07+05.1234E-08 = 7.000000051234 7+0.51234E-7 = 7.000000051234 07+0.51234E-07 = 7.000000051234 # # mult.s, div.s, and mixed 2.0*5.1234E+8 = 1024680000 5.1234E+8*2.0 = 1024680000 5.1234E+8/2.0 = 256170000 1024680000/5.1234E+8 = 2 1024680000.0/5.1234E+8 = 2 10.2468E+8/5.1234E+8 = 2 -2.0*5.1234E+8 = -1024680000 -5.1234E+8*2.0 = -1024680000 -5.1234E+8/2.0 = -256170000 -1024680000/5.1234E+8 = -2 -1024680000.0/5.1234E+8 = -2 -10.2468E+8/5.1234E+8 = -2 # # exp. notn. on both sides 5.123E+3+2.222E+3 = 7345 5.123E+3+2.222E-3 = 5123.002222 5.123E+3-2.222E+3 = 2901 5.123E+3-2.222E-3 = 5122.997778 5.123E-3+2.222E+3 = 2222.005123 5.123E-3+2.222E-3 = 0.007345 5.123E-3-2.222E+3 = -2221.994877 5.123E-3-2.222E-3 = 0.002901 -5.123E+3+2.222E+3 = -2901 -5.123E+3+2.222E-3 = -5122.997778 -5.123E+3-2.222E+3 = -7345 -5.123E+3-2.222E-3 = -5123.002222 -5.123E-3+2.222E+3 = 2221.994877 -5.123E-3+2.222E-3 = -0.002901 -5.123E-3-2.222E+3 = -2222.005123 -5.123E-3-2.222E-3 = -0.007345 # cases with >2 operands 7+5.1234E+8+7 = 512340014