root / pobysoC-4.0 / src / test-pobyso-is-polynomial-term.sh @ 150
Historique | Voir | Annoter | Télécharger (3,24 ko)
1 | 138 | storres | #! /bin/sh |
---|---|---|---|
2 | 138 | storres | # |
3 | 138 | storres | # |
4 | 138 | storres | TEST_BIN=./test-pobyso-is-polynomial-term |
5 | 138 | storres | |
6 | 138 | storres | echo |
7 | 138 | storres | ## Functions |
8 | 138 | storres | ok_if_fail() { |
9 | 138 | storres | echo "$@" |
10 | 138 | storres | eval "$TEST_BIN $ARGUMENTS" |
11 | 138 | storres | if [ $? -eq 0 ] ; then |
12 | 138 | storres | echo "Succeeded (but should not have) for $ARGUMENTS" |
13 | 138 | storres | exit 1 |
14 | 138 | storres | fi |
15 | 138 | storres | echo "Correctly failing$WHY." |
16 | 138 | storres | echo |
17 | 138 | storres | } |
18 | 138 | storres | ## |
19 | 138 | storres | ok_if_ok() { |
20 | 138 | storres | echo "$@" |
21 | 138 | storres | eval "$TEST_BIN $ARGUMENTS" |
22 | 138 | storres | if [ $? -ne 0 ] ; then |
23 | 138 | storres | echo "Failed for $ARGUMENTS" |
24 | 138 | storres | exit 1 |
25 | 138 | storres | fi |
26 | 138 | storres | echo |
27 | 138 | storres | } |
28 | 138 | storres | ## |
29 | 138 | storres | ARGUMENTS="\"x\"" |
30 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
31 | 138 | storres | |
32 | 138 | storres | ARGUMENTS="\"1\"" |
33 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
34 | 138 | storres | |
35 | 138 | storres | ARGUMENTS="\"-1\"" |
36 | 138 | storres | WHY=" ($ARGUMENTS is not a monomial)" |
37 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
38 | 138 | storres | |
39 | 138 | storres | ARGUMENTS="\"2\"" |
40 | 138 | storres | WHY=" ($ARGUMENTS is not a monomial)" |
41 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
42 | 138 | storres | |
43 | 138 | storres | ARGUMENTS="\"(x^0)\"" |
44 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
45 | 138 | storres | |
46 | 138 | storres | ARGUMENTS="\"(x^63)\"" |
47 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
48 | 138 | storres | |
49 | 138 | storres | ARGUMENTS="\"x^-2\"" |
50 | 138 | storres | WHY=" ($ARGUMENTS is has negative integer exponent)" |
51 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
52 | 138 | storres | |
53 | 138 | storres | ARGUMENTS="\"x^((2^63)-2)\"" |
54 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
55 | 138 | storres | |
56 | 138 | storres | ARGUMENTS="\"x^((2^63)-1)\"" |
57 | 138 | storres | WHY=" (\"2^63-1\" is a too large integer)" |
58 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
59 | 138 | storres | |
60 | 138 | storres | ARGUMENTS="\"(x^(2))*3\"" |
61 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
62 | 138 | storres | |
63 | 138 | storres | ARGUMENTS="\"cos(pi)\"" |
64 | 138 | storres | WHY=" ($ARGUMENTS is a negative integer)" |
65 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
66 | 138 | storres | |
67 | 138 | storres | ARGUMENTS="\"cos(pi)*x^exp(0)\"" |
68 | 138 | storres | WHY=" ($ARGUMENTS is a negative integer)" |
69 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
70 | 138 | storres | |
71 | 138 | storres | ARGUMENTS="\"x^(2*exp(0))*cos(pi)*4\"" |
72 | 138 | storres | WHY=" ($ARGUMENTS is a negative integer)" |
73 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
74 | 138 | storres | |
75 | 138 | storres | ARGUMENTS="\"x^exp(0)*cos(pi)\"" |
76 | 138 | storres | WHY=" ($ARGUMENTS is a negative integer)" |
77 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
78 | 138 | storres | |
79 | 138 | storres | ARGUMENTS="\"x^sin(pi)\"" |
80 | 138 | storres | #WHY=" ($ARGUMENTS is not an integer)" |
81 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
82 | 138 | storres | |
83 | 138 | storres | ## |
84 | 138 | storres | ARGUMENTS="\"x^1.1\"" |
85 | 138 | storres | WHY=" ($ARGUMENTS is not an integer)" |
86 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
87 | 138 | storres | |
88 | 138 | storres | ARGUMENTS="\"x^ceil(1.1)\"" |
89 | 138 | storres | WHY=" ($ARGUMENTS is not an integer)" |
90 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
91 | 138 | storres | |
92 | 138 | storres | ARGUMENTS="\"-1.1\"" |
93 | 138 | storres | WHY=" ($ARGUMENTS is not a positive integer)" |
94 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
95 | 138 | storres | |
96 | 138 | storres | ARGUMENTS="\"x^floor(-1.1)\"" |
97 | 138 | storres | WHY=" (\"floor(-1.1)\" is not a positive integer)" |
98 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
99 | 138 | storres | |
100 | 138 | storres | ARGUMENTS="\"x+2\"" |
101 | 138 | storres | WHY=" ($ARGUMENTS is not a monomial)" |
102 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
103 | 138 | storres | |
104 | 138 | storres | ARGUMENTS="\"x^(2/3)\"" |
105 | 138 | storres | WHY=" (\"2/3\" is not an integer)" |
106 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
107 | 138 | storres | |
108 | 138 | storres | ARGUMENTS="\"x^(2)*(2/3)\"" |
109 | 138 | storres | WHY=" ($ARGUMENTS is not an integer)" |
110 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
111 | 138 | storres | |
112 | 138 | storres | ## |
113 | 138 | storres | ARGUMENTS="\"4-2*x+4*x^2\"" |
114 | 138 | storres | WHY=" (expression not a polynomial term)" |
115 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
116 | 138 | storres | |
117 | 138 | storres | ## |
118 | 138 | storres | ARGUMENTS="\"yx+\"" |
119 | 138 | storres | WHY=" ($ARGUMENTS not expression)" |
120 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
121 | 138 | storres | |
122 | 138 | storres | ## |
123 | 138 | storres | ARGUMENTS="\"1/0\"" |
124 | 138 | storres | WHY=" ($ARGUMENTS not a number)" |
125 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
126 | 138 | storres | |
127 | 138 | storres | ## |
128 | 138 | storres | ARGUMENTS="\"exp(1000000)\"" |
129 | 138 | storres | WHY=" ($ARGUMENTS is too large)" |
130 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
131 | 138 | storres | |
132 | 138 | storres | ARGUMENTS="\"-exp(1000000)\"" |
133 | 138 | storres | WHY=" ($ARGUMENTS is too small)" |
134 | 138 | storres | ok_if_ok "Testing: $ARGUMENTS" |
135 | 138 | storres | |
136 | 138 | storres | ARGUMENTS="\"+infty\"" |
137 | 138 | storres | WHY=" ($ARGUMENTS is infinity)" |
138 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
139 | 138 | storres | |
140 | 138 | storres | ARGUMENTS="\"infty\"" |
141 | 138 | storres | WHY=" ($ARGUMENTS is infinity)" |
142 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
143 | 138 | storres | |
144 | 138 | storres | ARGUMENTS="\"-infty\"" |
145 | 138 | storres | WHY=" ($ARGUMENTS is infinity)" |
146 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
147 | 138 | storres | |
148 | 138 | storres | ARGUMENTS="\"-infty*x^2\"" |
149 | 138 | storres | WHY=" ($ARGUMENTS has infinity)" |
150 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
151 | 138 | storres | |
152 | 138 | storres | ARGUMENTS="\"2*x^infty\"" |
153 | 138 | storres | WHY=" ($ARGUMENTS has infinity)" |
154 | 138 | storres | ok_if_fail "Testing: $ARGUMENTS" |
155 | 138 | storres | |
156 | 138 | storres | |
157 | 138 | storres | ## |
158 | 138 | storres | echo "Tests terminated without error." |
159 | 138 | storres | echo |