aboutsummaryrefslogtreecommitdiff
path: root/tests/bc.test
blob: 213b21abd184493af177b10f9ba27f2de8f0f67f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

BDIR="$FILES/bc"
TESTDIR="./"

results=$(cat "$BDIR/decimal_results.txt")
testcmd "decimal" "-l $BDIR/decimal.txt" "$results\n" "$BDIR/decimal.txt" ""

results=$(cat "$BDIR/add_results.txt")
testcmd "add" "-l $BDIR/add.txt" "$results\n" "$BDIR/add.txt" ""

results=$(cat "$BDIR/subtract_results.txt")
testcmd "subtract" "-l $BDIR/subtract.txt" "$results\n" "$BDIR/subtract.txt" ""

results=$(cat "$BDIR/multiply_results.txt")
testcmd "multiply" "-l $BDIR/multiply.txt" "$results\n" "$BDIR/multiply.txt" ""

results=$(cat "$BDIR/divide_results.txt")
testcmd "divide" "-l $BDIR/divide.txt" "$results\n" "$BDIR/divide.txt" ""

results=$(cat "$BDIR/modulus_results.txt")
testcmd "modulus" "-l $BDIR/modulus.txt" "$results\n" "$BDIR/modulus.txt" ""

results=$(cat "$BDIR/power_results.txt")
testcmd "power" "-l $BDIR/power.txt" "$results\n" "$BDIR/power.txt" ""

results=$(cat "$BDIR/sqrt_results.txt")
testcmd "sqrt" "-l $BDIR/sqrt.txt" "$results\n" "$BDIR/sqrt.txt" ""

results=$(cat "$BDIR/basic_results.txt")
testcmd "basic" "-l $BDIR/basic.txt" "$results\n" "$BDIR/basic.txt" ""

if [ ! -f "$TESTDIR/parse.txt" ]; then
  echo "Generating bc parse..."
  cat "$BDIR/parse.bc" | bc -l > "$TESTDIR/parse.txt"
fi
results=$(cat "$TESTDIR/parse.txt" | bc -l)
testcmd "parse" "-l $TESTDIR/parse.txt" "$results\n" "$TESTDIR/parse.txt" ""

if [ ! -f "$TESTDIR/print.txt" ]; then
  echo "Generating bc print..."
  cat "$BDIR/print.bc" | bc -l > "$TESTDIR/print.txt"
fi
results=$(cat "$TESTDIR/print.txt" | bc -l)
testcmd "print" "-l $TESTDIR/print.txt" "$results\n" "$TESTDIR/print.txt" ""

results=$(cat "$BDIR/pi.txt" | bc -l)
testcmd "pi" "-l $BDIR/pi.txt" "$results\n" "$BDIR/pi.txt" ""

if [ ! -f "$TESTDIR/arctan.txt" ]; then
  echo "Generating bc arctan..."
  cat "$BDIR/arctan.bc" | bc -l > "$TESTDIR/arctan.txt"
fi
results=$(cat "$TESTDIR/arctan.txt" | bc -l)
testcmd "arctan" "-l $TESTDIR/arctan.txt" "$results\n" "$TESTDIR/arctan.txt" ""

results=$(cat "$TESTDIR/arctan.txt")
testcmd "arctan script" "-l $BDIR/arctan.bc" "$results" "$BDIR/arctan.bc" ""

results=$(cat "$TESTDIR/parse.txt")
testcmd "parse script" "-l $BDIR/parse.bc" "$results\n" "$BDIR/parse.bc" ""

results=$(cat "$TESTDIR/print.txt")
testcmd "print script" "-l $BDIR/print.bc" "$results\n" "$BDIR/print.bc" ""

results=$(cat "$BDIR/screen.bc" | bc -l)
testcmd "screen script" "-l $BDIR/screen.bc" "$results\n" "$BDIR/screen.bc" ""