1
1
import * as test from "tape" ;
2
- import { evaluate , verify , dedent , testSingleExpressionByList } from "./shared_functions" ;
2
+ import { evaluate , verify , dedent , testSingleExpressionByList , valueTest } from "./shared_functions" ;
3
3
4
4
// Test Constants
5
- // Would this fail on different architectures than mine? Not according to dcmumentation Maybe we Should
5
+ // Would this fail on different architectures than mine? Not according to documentation Maybe we Should
6
6
// flush out that implicit assumption.
7
7
8
- let constants_list : any = [
9
- { "Expression" :"pi[]" , "Value" :"3.141592653589793" } ,
10
- { "Expression" :"e[]" , "Value" :"2.718281828459045" } ,
11
- { "Expression" :"ln2[]" , "Value" :"0.6931471805599453" } ,
12
- { "Expression" :"log2e[]" , "Value" :"1.4426950408889634" } ,
13
- { "Expression" :"log10e[]" , "Value" :"0.4342944819032518" } ,
14
- { "Expression" :"sqrt1/2[]" , "Value" :"0.7071067811865476" } ,
15
- { "Expression" :"sqrt2[]" , "Value" :"1.4142135623730951" }
8
+ let delta = 0.00000000001 ;
9
+
10
+ let constants_list : valueTest [ ] = [
11
+ { expression : "pi[]" , expectedValue : 3.141592653589793 } ,
12
+ { expression : "e[]" , expectedValue : 2.718281828459045 } ,
13
+ { expression : "ln2[]" , expectedValue : 0.6931471805599453 } ,
14
+ { expression : "log2e[]" , expectedValue : 1.4426950408889634 } ,
15
+ { expression : "log10e[]" , expectedValue : 0.4342944819032518 } ,
16
+ { expression : "sqrt1/2[]" , expectedValue : 0.7071067811865476 } ,
17
+ { expression : "sqrt2[]" , expectedValue : 1.4142135623730951 }
16
18
]
17
19
testSingleExpressionByList ( constants_list ) ;
18
20
19
21
// Test Power Function
20
- let pow_list : any = [
21
- { "Expression" : "pow[ value:2 by:3 ]" , "Value" : "8" } ,
22
- { "Expression" : "pow[ value:9 by:1 / 2 ]" , "Value" : "3" } ]
22
+ let pow_list : valueTest [ ] = [
23
+ { expression : "pow[ value:2 by:3 ]" , expectedValue : 8 } ,
24
+ { expression : "pow[ value:9 by:1 / 2 ]" , expectedValue : 3 } ]
23
25
testSingleExpressionByList ( pow_list ) ;
24
26
25
27
// Test Log Function
26
- let log_list : any = [
27
- { "Expression" : "log[ value: e[] ]" , "Value" : "1" } ,
28
- { "Expression" : "log[ value: 10 base: 10 ]" , "Value" : "1" } ]
28
+ let log_list : valueTest [ ] = [
29
+ { expression : "log[ value: e[] ]" , expectedValue : 1 } ,
30
+ { expression : "log[ value: 10 base: 10 ]" , expectedValue : 1 } ]
29
31
testSingleExpressionByList ( log_list ) ;
30
32
31
33
// Test Exp Function
32
- let exp_list : any = [
33
- { "Expression" : "exp[ value: 1 ]" , "Value" : " 2.718281828459045" } ]
34
+ let exp_list : valueTest [ ] = [
35
+ { expression : "exp[ value: 1 ]" , expectedValue : 2.718281828459045 } ]
34
36
testSingleExpressionByList ( exp_list ) ;
35
37
36
38
// Test Trig Functions
37
- let trig_list : any = [
38
- { "Expression" : "sin[ radians: 1 ]" , "Value" : " 0.8414709848078965" } ,
39
- { "Expression" : "cos[ radians: 1 ]" , "Value" : " 0.5403023058681398" } ,
40
- { "Expression" : "tan[ radians: 1 ]" , "Value" : " 1.5574077246549023" }
39
+ let trig_list : valueTest [ ] = [
40
+ { expression : "sin[ radians: 1 ]" , expectedValue : 0.8414709848078965 } ,
41
+ { expression : "cos[ radians: 1 ]" , expectedValue : 0.5403023058681398 } ,
42
+ { expression : "tan[ radians: 1 ]" , expectedValue : 1.5574077246549023 }
41
43
]
42
44
testSingleExpressionByList ( trig_list ) ;
43
45
44
46
45
47
test ( "Should be able to use the sin function with degrees and radians" , ( assert ) => {
46
48
let expected = {
47
49
insert : [
48
- [ "a" , "result " , "1" ] ,
49
- [ "b" , "result " , "0.9999996829318346" ] ,
50
+ [ "a" , "floatTest " , "1" ] ,
51
+ [ "b" , "floatTest " , "0.9999996829318346" ] ,
50
52
] ,
51
53
remove : [ ] ,
52
54
} ;
@@ -58,8 +60,8 @@ test("Should be able to use the sin function with degrees and radians", (assert)
58
60
x = sin[radians: 3.14 / 2]
59
61
60
62
bind
61
- [result : y]
62
- [result : x]
63
+ [floatTest : y]
64
+ [floatTest : x]
63
65
~~~
64
66
` ) ;
65
67
assert . end ( ) ;
@@ -68,8 +70,8 @@ test("Should be able to use the sin function with degrees and radians", (assert)
68
70
test ( "Should be able to use the cos function with degrees and radians" , ( assert ) => {
69
71
let expected = {
70
72
insert : [
71
- [ "a" , "result " , "1" ] ,
72
- [ "b" , "result " , "-0.9999987317275395" ] ,
73
+ [ "a" , "floatTest " , "1" ] ,
74
+ [ "b" , "floatTest " , "-0.9999987317275395" ] ,
73
75
] ,
74
76
remove : [ ] ,
75
77
} ;
@@ -81,8 +83,8 @@ test("Should be able to use the cos function with degrees and radians", (assert)
81
83
x = cos[radians: 3.14]
82
84
83
85
bind
84
- [result : y]
85
- [result : x]
86
+ [floatTest : y]
87
+ [floatTest : x]
86
88
~~~
87
89
` ) ;
88
90
assert . end ( ) ;
@@ -91,8 +93,8 @@ test("Should be able to use the cos function with degrees and radians", (assert)
91
93
test ( "Should be able to use the tan function with degrees and radians" , ( assert ) => {
92
94
let expected = {
93
95
insert : [
94
- [ "a" , "result " , "0.5773502691896257" ] ,
95
- [ "b" , "result " , "0.5463024898437905" ] ,
96
+ [ "a" , "floatTest " , "0.5773502691896257" ] ,
97
+ [ "b" , "floatTest " , "0.5463024898437905" ] ,
96
98
] ,
97
99
remove : [ ] ,
98
100
} ;
@@ -104,34 +106,34 @@ test("Should be able to use the tan function with degrees and radians", (assert)
104
106
x = tan[radians: 0.5]
105
107
106
108
bind
107
- [result : y]
108
- [result : x]
109
+ [floatTest : y]
110
+ [floatTest : x]
109
111
~~~
110
112
` ) ;
111
113
assert . end ( ) ;
112
114
} )
113
115
114
116
// Test inverse Trig
115
- let atrig_list : any = [
116
- { "Expression" : "asin[ value: 0.8414709848078965 ]" , "Value" : "1" } ,
117
- { "Expression" : "acos[ value: 0.5403023058681398 ]" , "Value" : " 0.9999999999999999" } ,
118
- { "Expression" : "atan[ value: 1.5574077246549023 ]" , "Value" : "1" } ,
117
+ let atrig_list : valueTest [ ] = [
118
+ { expression : "asin[ value: 0.8414709848078965 ]" , expectedValue : 1 } ,
119
+ { expression : "acos[ value: 0.5403023058681398 ]" , expectedValue : 0.9999999999999999 } ,
120
+ { expression : "atan[ value: 1.5574077246549023 ]" , expectedValue : 1 } ,
119
121
]
120
122
testSingleExpressionByList ( atrig_list ) ;
121
123
122
124
// Test Hyperbolic Functions
123
- let hyp_list : any = [
124
- { "Expression" : "sinh[ value: 1 ]" , "Value" : " 1.1752011936438014" } ,
125
- { "Expression" : "cosh[ value: 1 ]" , "Value" : " 1.5430806348152437" } ,
126
- { "Expression" : "tanh[ value: 1 ]" , "Value" : " 0.7615941559557649" } ,
125
+ let hyp_list : valueTest [ ] = [
126
+ { expression : "sinh[ value: 1 ]" , expectedValue : 1.1752011936438014 } ,
127
+ { expression : "cosh[ value: 1 ]" , expectedValue : 1.5430806348152437 } ,
128
+ { expression : "tanh[ value: 1 ]" , expectedValue : 0.7615941559557649 } ,
127
129
]
128
130
testSingleExpressionByList ( hyp_list ) ;
129
131
130
132
// Test Inverse Hyperbolic Functions
131
- let ahyp_list : any = [
132
- { "Expression" : "asinh[ value: 1.1752011936438014 ]" , "Value" : "1" } ,
133
- { "Expression" : "acosh[ value: 1.5430806348152437 ]" , "Value" : "1" } ,
134
- { "Expression" : "atanh[ value: 0.7615941559557649 ]" , "Value" : " 0.9999999999999999" } ,
133
+ let ahyp_list : valueTest [ ] = [
134
+ { expression : "asinh[ value: 1.1752011936438014 ]" , expectedValue : 1 } ,
135
+ { expression : "acosh[ value: 1.5430806348152437 ]" , expectedValue : 1 } ,
136
+ { expression : "atanh[ value: 0.7615941559557649 ]" , expectedValue : 0.9999999999999999 } ,
135
137
]
136
138
testSingleExpressionByList ( ahyp_list ) ;
137
139
@@ -160,7 +162,7 @@ test("Test range", (assert) => {
160
162
test ( "Test nested functions" , ( assert ) => {
161
163
let expected = {
162
164
insert : [
163
- [ "a" , "result " , "1" ] ,
165
+ [ "a" , "floatTest " , "1" ] ,
164
166
] ,
165
167
remove : [ ] ,
166
168
} ;
@@ -171,49 +173,49 @@ test("Test nested functions", (assert) => {
171
173
x = sin[radians: pi[] / 2]
172
174
173
175
bind
174
- [result : x]
176
+ [floatTest : x]
175
177
~~~
176
178
` ) ;
177
179
assert . end ( ) ;
178
180
} )
179
181
180
182
// Test Floor Function
181
- let floor_list : any = [
182
- { "Expression" : "floor[ value: 1.0000000000000001 ]" , "Value" : "1" } ,
183
- { "Expression" : "floor[ value: 1.999999999999999 ]" , "Value" : "1" } ,
183
+ let floor_list : valueTest [ ] = [
184
+ { expression : "floor[ value: 1.0000000000000001 ]" , expectedValue : 1 } ,
185
+ { expression : "floor[ value: 1.999999999999999 ]" , expectedValue : 1 } ,
184
186
]
185
187
testSingleExpressionByList ( floor_list ) ;
186
188
187
189
// Test Ceiling Function
188
- let ceiling_list : any = [
189
- { "Expression" : "ceiling[ value: 1.000000000000001 ]" , "Value" : "2" } ,
190
- { "Expression" : "ceiling[ value: 1.999999999999999 ]" , "Value" : "2" } ,
190
+ let ceiling_list : valueTest [ ] = [
191
+ { expression : "ceiling[ value: 1.000000000000001 ]" , expectedValue : 2 } ,
192
+ { expression : "ceiling[ value: 1.999999999999999 ]" , expectedValue : 2 } ,
191
193
]
192
194
testSingleExpressionByList ( ceiling_list ) ;
193
195
194
196
// Test ABS Function
195
- let abs_list : any = [
196
- { "Expression" : "abs[ value: -1 ]" , "Value" : "1" } ,
197
- { "Expression" : "abs[ value: 1 ]" , "Value" : "1" } ,
197
+ let abs_list : valueTest [ ] = [
198
+ { expression : "abs[ value: -1 ]" , expectedValue : 1 } ,
199
+ { expression : "abs[ value: 1 ]" , expectedValue : 1 } ,
198
200
]
199
201
testSingleExpressionByList ( abs_list ) ;
200
202
201
203
// Test Mod Function
202
- let mod_list : any = [
203
- { "Expression" : "mod[ value: 7 by: 3]" , "Value" : "1" } ,
204
- { "Expression" : "mod[ value: 6 by: 3]" , "Value" : "0" } ,
204
+ let mod_list : valueTest [ ] = [
205
+ { expression : "mod[ value: 7 by: 3]" , expectedValue : 1 } ,
206
+ { expression : "mod[ value: 6 by: 3]" , expectedValue : 0 } ,
205
207
]
206
208
testSingleExpressionByList ( mod_list ) ;
207
209
208
210
// Test Round Function
209
- let round_list : any = [
210
- { "Expression" : "round[ value: 1.49999999999999 ]" , "Value" : "1" } ,
211
- { "Expression" : "round[ value: 1.5 ]" , "Value" : "2" }
211
+ let round_list : valueTest [ ] = [
212
+ { expression : "round[ value: 1.49999999999999 ]" , expectedValue : 1 } ,
213
+ { expression : "round[ value: 1.5 ]" , expectedValue : 2 }
212
214
]
213
215
testSingleExpressionByList ( round_list ) ;
214
216
215
217
// Test Round Function
216
- let toFixed_list : any = [
217
- { "Expression" : "to-fixed[ value: 1.499 places: 2 ]" , "Value" : " 1.50" } ,
218
+ let toFixed_list : valueTest [ ] = [
219
+ { expression : "to-fixed[ value: 1.499 places: 2 ]" , expectedValue : 1.50 } ,
218
220
]
219
- testSingleExpressionByList ( toFixed_list ) ;
221
+ testSingleExpressionByList ( toFixed_list ) ;
0 commit comments