129 |
if (opt.expectExitResultUnit) { |
if (opt.expectExitResultUnit) { |
130 |
VMExpr* resExpr = execCtx->exitResult(); |
VMExpr* resExpr = execCtx->exitResult(); |
131 |
TEST_ASSERT(resExpr); |
TEST_ASSERT(resExpr); |
132 |
VMScalarNumberExpr* numberExpr = resExpr->asScalarNumberExpr(); |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
133 |
TEST_ASSERT(numberExpr); |
TEST_ASSERT(numberExpr); |
134 |
TEST_ASSERT(numberExpr->unitType() == *opt.expectExitResultUnit); |
TEST_ASSERT(numberExpr->unitType() == *opt.expectExitResultUnit); |
135 |
} |
} |
136 |
if (!opt.expectExitResultUnitPrefix.empty()) { |
if (!opt.expectExitResultUnitPrefix.empty()) { |
137 |
VMExpr* resExpr = execCtx->exitResult(); |
VMExpr* resExpr = execCtx->exitResult(); |
138 |
TEST_ASSERT(resExpr); |
TEST_ASSERT(resExpr); |
139 |
VMScalarNumberExpr* numberExpr = resExpr->asScalarNumberExpr(); |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
140 |
TEST_ASSERT(numberExpr); |
TEST_ASSERT(numberExpr); |
141 |
auto prefixes = opt.expectExitResultUnitPrefix; |
auto prefixes = opt.expectExitResultUnitPrefix; |
142 |
if (*prefixes.rbegin() != VM_NO_PREFIX) |
if (*prefixes.rbegin() != VM_NO_PREFIX) |
152 |
if (opt.expectExitResultFinal) { |
if (opt.expectExitResultFinal) { |
153 |
VMExpr* resExpr = execCtx->exitResult(); |
VMExpr* resExpr = execCtx->exitResult(); |
154 |
TEST_ASSERT(resExpr); |
TEST_ASSERT(resExpr); |
155 |
VMScalarNumberExpr* numberExpr = resExpr->asScalarNumberExpr(); |
VMNumberExpr* numberExpr = resExpr->asNumber(); |
156 |
TEST_ASSERT(numberExpr); |
TEST_ASSERT(numberExpr); |
157 |
TEST_ASSERT(numberExpr->isFinal() == *opt.expectExitResultFinal); |
TEST_ASSERT(numberExpr->isFinal() == *opt.expectExitResultFinal); |
158 |
} |
} |
285 |
.expectRealExitResult = 6.9 |
.expectRealExitResult = 6.9 |
286 |
}); |
}); |
287 |
|
|
288 |
|
// int array tests ... |
289 |
|
|
290 |
|
runScript({ |
291 |
|
.code = R"NKSP_CODE( |
292 |
|
on init |
293 |
|
declare %foo[3] |
294 |
|
%foo[0] := 21 |
295 |
|
exit(%foo[0]) |
296 |
|
end on |
297 |
|
)NKSP_CODE", |
298 |
|
.expectIntExitResult = 21 |
299 |
|
}); |
300 |
|
|
301 |
|
runScript({ |
302 |
|
.code = R"NKSP_CODE( |
303 |
|
on init |
304 |
|
declare %foo[3] := ( 12, 23, 34 ) |
305 |
|
exit(%foo[0]) |
306 |
|
end on |
307 |
|
)NKSP_CODE", |
308 |
|
.expectIntExitResult = 12 |
309 |
|
}); |
310 |
|
|
311 |
|
runScript({ |
312 |
|
.code = R"NKSP_CODE( |
313 |
|
on init |
314 |
|
declare %foo[3] := ( 12, 23, 34 ) |
315 |
|
exit(%foo[1]) |
316 |
|
end on |
317 |
|
)NKSP_CODE", |
318 |
|
.expectIntExitResult = 23 |
319 |
|
}); |
320 |
|
|
321 |
|
runScript({ |
322 |
|
.code = R"NKSP_CODE( |
323 |
|
on init |
324 |
|
declare %foo[3] := ( 12, 23, 34 ) |
325 |
|
exit(%foo[2]) |
326 |
|
end on |
327 |
|
)NKSP_CODE", |
328 |
|
.expectIntExitResult = 34 |
329 |
|
}); |
330 |
|
|
331 |
|
runScript({ // make sure array is entirely initialized with zeroes |
332 |
|
.code = R"NKSP_CODE( |
333 |
|
on init |
334 |
|
declare $i |
335 |
|
declare $result |
336 |
|
declare %foo[100] |
337 |
|
while ($i < 100) |
338 |
|
$result := $result .or. %foo[$i] |
339 |
|
inc($i) |
340 |
|
end while |
341 |
|
exit($result) |
342 |
|
end on |
343 |
|
)NKSP_CODE", |
344 |
|
.expectIntExitResult = 0 |
345 |
|
}); |
346 |
|
|
347 |
|
// real array tests ... |
348 |
|
|
349 |
|
runScript({ |
350 |
|
.code = R"NKSP_CODE( |
351 |
|
on init |
352 |
|
declare ?foo[3] |
353 |
|
?foo[0] := 34.9 |
354 |
|
exit(?foo[0]) |
355 |
|
end on |
356 |
|
)NKSP_CODE", |
357 |
|
.expectRealExitResult = 34.9 |
358 |
|
}); |
359 |
|
|
360 |
|
runScript({ |
361 |
|
.code = R"NKSP_CODE( |
362 |
|
on init |
363 |
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
364 |
|
exit(?foo[0]) |
365 |
|
end on |
366 |
|
)NKSP_CODE", |
367 |
|
.expectRealExitResult = 0.3 |
368 |
|
}); |
369 |
|
|
370 |
|
runScript({ |
371 |
|
.code = R"NKSP_CODE( |
372 |
|
on init |
373 |
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
374 |
|
exit(?foo[1]) |
375 |
|
end on |
376 |
|
)NKSP_CODE", |
377 |
|
.expectRealExitResult = 23.5 |
378 |
|
}); |
379 |
|
|
380 |
|
runScript({ |
381 |
|
.code = R"NKSP_CODE( |
382 |
|
on init |
383 |
|
declare ?foo[3] := ( 0.3, 23.5, 900.1 ) |
384 |
|
exit(?foo[2]) |
385 |
|
end on |
386 |
|
)NKSP_CODE", |
387 |
|
.expectRealExitResult = 900.1 |
388 |
|
}); |
389 |
|
|
390 |
|
runScript({ // make sure array is entirely initialized with zeroes |
391 |
|
.code = R"NKSP_CODE( |
392 |
|
on init |
393 |
|
declare $i |
394 |
|
declare ?foo[100] |
395 |
|
while ($i < 100) |
396 |
|
if (?foo[$i] # 0.0) |
397 |
|
exit(-1) { test failed } |
398 |
|
end if |
399 |
|
inc($i) |
400 |
|
end while |
401 |
|
exit(0) { test succeeded } |
402 |
|
end on |
403 |
|
)NKSP_CODE", |
404 |
|
.expectIntExitResult = 0 |
405 |
|
}); |
406 |
|
|
407 |
// std unit tests ... |
// std unit tests ... |
408 |
|
|
409 |
runScript({ |
runScript({ |
1254 |
.expectExitResultFinal = false |
.expectExitResultFinal = false |
1255 |
}); |
}); |
1256 |
|
|
1257 |
|
//TODO: the following are unary '+' operator tests which should be moved to their own function (lazy me). |
1258 |
|
|
1259 |
|
runScript({ |
1260 |
|
.code = R"NKSP_CODE( |
1261 |
|
on init |
1262 |
|
exit(+54) |
1263 |
|
end on |
1264 |
|
)NKSP_CODE", |
1265 |
|
.expectIntExitResult = 54 |
1266 |
|
}); |
1267 |
|
|
1268 |
|
runScript({ |
1269 |
|
.code = R"NKSP_CODE( |
1270 |
|
on init |
1271 |
|
declare $foo := +54 |
1272 |
|
exit( $foo ) |
1273 |
|
end on |
1274 |
|
)NKSP_CODE", |
1275 |
|
.expectIntExitResult = 54 |
1276 |
|
}); |
1277 |
|
|
1278 |
|
runScript({ |
1279 |
|
.code = R"NKSP_CODE( |
1280 |
|
on init |
1281 |
|
exit(+0.45) |
1282 |
|
end on |
1283 |
|
)NKSP_CODE", |
1284 |
|
.expectRealExitResult = 0.45 |
1285 |
|
}); |
1286 |
|
|
1287 |
|
runScript({ |
1288 |
|
.code = R"NKSP_CODE( |
1289 |
|
on init |
1290 |
|
declare ~foo := +0.29 |
1291 |
|
exit( ~foo ) |
1292 |
|
end on |
1293 |
|
)NKSP_CODE", |
1294 |
|
.expectRealExitResult = 0.29 |
1295 |
|
}); |
1296 |
|
|
1297 |
#if !SILENT_TEST |
#if !SILENT_TEST |
1298 |
std::cout << std::endl; |
std::cout << std::endl; |
1299 |
#endif |
#endif |
7937 |
#endif |
#endif |
7938 |
} |
} |
7939 |
|
|
7940 |
|
static void testBuiltInRoundFunction() { |
7941 |
|
#if !SILENT_TEST |
7942 |
|
std::cout << "UNIT TEST: built-in round() function\n"; |
7943 |
|
#endif |
7944 |
|
|
7945 |
|
// integer tests ... |
7946 |
|
// (ATM not allowed for this function) |
7947 |
|
|
7948 |
|
runScript({ |
7949 |
|
.code = R"NKSP_CODE( |
7950 |
|
on init |
7951 |
|
declare $foo := 1 |
7952 |
|
exit( round($foo) ) |
7953 |
|
end on |
7954 |
|
)NKSP_CODE", |
7955 |
|
.expectParseError = true // integer not allowed for this function ATM |
7956 |
|
}); |
7957 |
|
|
7958 |
|
// real number tests ... |
7959 |
|
|
7960 |
|
runScript({ |
7961 |
|
.code = R"NKSP_CODE( |
7962 |
|
on init |
7963 |
|
exit( round(99.4) ) |
7964 |
|
end on |
7965 |
|
)NKSP_CODE", |
7966 |
|
.expectRealExitResult = 99.0 |
7967 |
|
}); |
7968 |
|
|
7969 |
|
runScript({ |
7970 |
|
.code = R"NKSP_CODE( |
7971 |
|
on init |
7972 |
|
exit( round(99.5) ) |
7973 |
|
end on |
7974 |
|
)NKSP_CODE", |
7975 |
|
.expectRealExitResult = 100.0 |
7976 |
|
}); |
7977 |
|
|
7978 |
|
// std unit tests ... |
7979 |
|
|
7980 |
|
runScript({ |
7981 |
|
.code = R"NKSP_CODE( |
7982 |
|
on init |
7983 |
|
exit( round(2.4ms) ) |
7984 |
|
end on |
7985 |
|
)NKSP_CODE", |
7986 |
|
.expectRealExitResult = 2.0, |
7987 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
7988 |
|
.expectExitResultUnit = VM_SECOND |
7989 |
|
}); |
7990 |
|
|
7991 |
|
runScript({ |
7992 |
|
.code = R"NKSP_CODE( |
7993 |
|
on init |
7994 |
|
exit( round(2.6kHz) ) |
7995 |
|
end on |
7996 |
|
)NKSP_CODE", |
7997 |
|
.expectRealExitResult = 3.0, |
7998 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
7999 |
|
.expectExitResultUnit = VM_HERTZ |
8000 |
|
}); |
8001 |
|
|
8002 |
|
// 'final' ('!') operator tests ... |
8003 |
|
|
8004 |
|
runScript({ |
8005 |
|
.code = R"NKSP_CODE( |
8006 |
|
on init |
8007 |
|
exit( round(123.8) ) |
8008 |
|
end on |
8009 |
|
)NKSP_CODE", |
8010 |
|
.expectRealExitResult = 124.0, |
8011 |
|
.expectExitResultFinal = false |
8012 |
|
}); |
8013 |
|
|
8014 |
|
runScript({ |
8015 |
|
.code = R"NKSP_CODE( |
8016 |
|
on init |
8017 |
|
exit( round(!123.8) ) |
8018 |
|
end on |
8019 |
|
)NKSP_CODE", |
8020 |
|
.expectRealExitResult = 124.0, |
8021 |
|
.expectExitResultFinal = true |
8022 |
|
}); |
8023 |
|
|
8024 |
|
#if !SILENT_TEST |
8025 |
|
std::cout << std::endl; |
8026 |
|
#endif |
8027 |
|
} |
8028 |
|
|
8029 |
|
static void testBuiltInCeilFunction() { |
8030 |
|
#if !SILENT_TEST |
8031 |
|
std::cout << "UNIT TEST: built-in ceil() function\n"; |
8032 |
|
#endif |
8033 |
|
|
8034 |
|
// integer tests ... |
8035 |
|
// (ATM not allowed for this function) |
8036 |
|
|
8037 |
|
runScript({ |
8038 |
|
.code = R"NKSP_CODE( |
8039 |
|
on init |
8040 |
|
declare $foo := 1 |
8041 |
|
exit( ceil($foo) ) |
8042 |
|
end on |
8043 |
|
)NKSP_CODE", |
8044 |
|
.expectParseError = true // integer not allowed for this function ATM |
8045 |
|
}); |
8046 |
|
|
8047 |
|
// real number tests ... |
8048 |
|
|
8049 |
|
runScript({ |
8050 |
|
.code = R"NKSP_CODE( |
8051 |
|
on init |
8052 |
|
exit( ceil(99.0) ) |
8053 |
|
end on |
8054 |
|
)NKSP_CODE", |
8055 |
|
.expectRealExitResult = 99.0 |
8056 |
|
}); |
8057 |
|
|
8058 |
|
runScript({ |
8059 |
|
.code = R"NKSP_CODE( |
8060 |
|
on init |
8061 |
|
exit( ceil(99.1) ) |
8062 |
|
end on |
8063 |
|
)NKSP_CODE", |
8064 |
|
.expectRealExitResult = 100.0 |
8065 |
|
}); |
8066 |
|
|
8067 |
|
runScript({ |
8068 |
|
.code = R"NKSP_CODE( |
8069 |
|
on init |
8070 |
|
exit( ceil(99.9) ) |
8071 |
|
end on |
8072 |
|
)NKSP_CODE", |
8073 |
|
.expectRealExitResult = 100.0 |
8074 |
|
}); |
8075 |
|
|
8076 |
|
// std unit tests ... |
8077 |
|
|
8078 |
|
runScript({ |
8079 |
|
.code = R"NKSP_CODE( |
8080 |
|
on init |
8081 |
|
exit( ceil(2.4ms) ) |
8082 |
|
end on |
8083 |
|
)NKSP_CODE", |
8084 |
|
.expectRealExitResult = 3.0, |
8085 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8086 |
|
.expectExitResultUnit = VM_SECOND |
8087 |
|
}); |
8088 |
|
|
8089 |
|
runScript({ |
8090 |
|
.code = R"NKSP_CODE( |
8091 |
|
on init |
8092 |
|
exit( ceil(2.6kHz) ) |
8093 |
|
end on |
8094 |
|
)NKSP_CODE", |
8095 |
|
.expectRealExitResult = 3.0, |
8096 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8097 |
|
.expectExitResultUnit = VM_HERTZ |
8098 |
|
}); |
8099 |
|
|
8100 |
|
// 'final' ('!') operator tests ... |
8101 |
|
|
8102 |
|
runScript({ |
8103 |
|
.code = R"NKSP_CODE( |
8104 |
|
on init |
8105 |
|
exit( ceil(123.1) ) |
8106 |
|
end on |
8107 |
|
)NKSP_CODE", |
8108 |
|
.expectRealExitResult = 124.0, |
8109 |
|
.expectExitResultFinal = false |
8110 |
|
}); |
8111 |
|
|
8112 |
|
runScript({ |
8113 |
|
.code = R"NKSP_CODE( |
8114 |
|
on init |
8115 |
|
exit( ceil(!123.8) ) |
8116 |
|
end on |
8117 |
|
)NKSP_CODE", |
8118 |
|
.expectRealExitResult = 124.0, |
8119 |
|
.expectExitResultFinal = true |
8120 |
|
}); |
8121 |
|
|
8122 |
|
#if !SILENT_TEST |
8123 |
|
std::cout << std::endl; |
8124 |
|
#endif |
8125 |
|
} |
8126 |
|
|
8127 |
|
static void testBuiltInFloorFunction() { |
8128 |
|
#if !SILENT_TEST |
8129 |
|
std::cout << "UNIT TEST: built-in floor() function\n"; |
8130 |
|
#endif |
8131 |
|
|
8132 |
|
// integer tests ... |
8133 |
|
// (ATM not allowed for this function) |
8134 |
|
|
8135 |
|
runScript({ |
8136 |
|
.code = R"NKSP_CODE( |
8137 |
|
on init |
8138 |
|
declare $foo := 1 |
8139 |
|
exit( floor($foo) ) |
8140 |
|
end on |
8141 |
|
)NKSP_CODE", |
8142 |
|
.expectParseError = true // integer not allowed for this function ATM |
8143 |
|
}); |
8144 |
|
|
8145 |
|
// real number tests ... |
8146 |
|
|
8147 |
|
runScript({ |
8148 |
|
.code = R"NKSP_CODE( |
8149 |
|
on init |
8150 |
|
exit( floor(99.0) ) |
8151 |
|
end on |
8152 |
|
)NKSP_CODE", |
8153 |
|
.expectRealExitResult = 99.0 |
8154 |
|
}); |
8155 |
|
|
8156 |
|
runScript({ |
8157 |
|
.code = R"NKSP_CODE( |
8158 |
|
on init |
8159 |
|
exit( floor(99.1) ) |
8160 |
|
end on |
8161 |
|
)NKSP_CODE", |
8162 |
|
.expectRealExitResult = 99.0 |
8163 |
|
}); |
8164 |
|
|
8165 |
|
runScript({ |
8166 |
|
.code = R"NKSP_CODE( |
8167 |
|
on init |
8168 |
|
exit( floor(99.9) ) |
8169 |
|
end on |
8170 |
|
)NKSP_CODE", |
8171 |
|
.expectRealExitResult = 99.0 |
8172 |
|
}); |
8173 |
|
|
8174 |
|
// std unit tests ... |
8175 |
|
|
8176 |
|
runScript({ |
8177 |
|
.code = R"NKSP_CODE( |
8178 |
|
on init |
8179 |
|
exit( floor(2.4ms) ) |
8180 |
|
end on |
8181 |
|
)NKSP_CODE", |
8182 |
|
.expectRealExitResult = 2.0, |
8183 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8184 |
|
.expectExitResultUnit = VM_SECOND |
8185 |
|
}); |
8186 |
|
|
8187 |
|
runScript({ |
8188 |
|
.code = R"NKSP_CODE( |
8189 |
|
on init |
8190 |
|
exit( floor(2.6kHz) ) |
8191 |
|
end on |
8192 |
|
)NKSP_CODE", |
8193 |
|
.expectRealExitResult = 2.0, |
8194 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8195 |
|
.expectExitResultUnit = VM_HERTZ |
8196 |
|
}); |
8197 |
|
|
8198 |
|
// 'final' ('!') operator tests ... |
8199 |
|
|
8200 |
|
runScript({ |
8201 |
|
.code = R"NKSP_CODE( |
8202 |
|
on init |
8203 |
|
exit( floor(123.1) ) |
8204 |
|
end on |
8205 |
|
)NKSP_CODE", |
8206 |
|
.expectRealExitResult = 123.0, |
8207 |
|
.expectExitResultFinal = false |
8208 |
|
}); |
8209 |
|
|
8210 |
|
runScript({ |
8211 |
|
.code = R"NKSP_CODE( |
8212 |
|
on init |
8213 |
|
exit( floor(!123.8) ) |
8214 |
|
end on |
8215 |
|
)NKSP_CODE", |
8216 |
|
.expectRealExitResult = 123.0, |
8217 |
|
.expectExitResultFinal = true |
8218 |
|
}); |
8219 |
|
|
8220 |
|
#if !SILENT_TEST |
8221 |
|
std::cout << std::endl; |
8222 |
|
#endif |
8223 |
|
} |
8224 |
|
|
8225 |
|
static void testBuiltInSqrtFunction() { |
8226 |
|
#if !SILENT_TEST |
8227 |
|
std::cout << "UNIT TEST: built-in sqrt() function\n"; |
8228 |
|
#endif |
8229 |
|
|
8230 |
|
// integer tests ... |
8231 |
|
// (ATM not allowed for this function) |
8232 |
|
|
8233 |
|
runScript({ |
8234 |
|
.code = R"NKSP_CODE( |
8235 |
|
on init |
8236 |
|
declare $foo := 1 |
8237 |
|
exit( sqrt($foo) ) |
8238 |
|
end on |
8239 |
|
)NKSP_CODE", |
8240 |
|
.expectParseError = true // integer not allowed for this function ATM |
8241 |
|
}); |
8242 |
|
|
8243 |
|
// real number tests ... |
8244 |
|
|
8245 |
|
runScript({ |
8246 |
|
.code = R"NKSP_CODE( |
8247 |
|
on init |
8248 |
|
exit( sqrt(36.0) ) |
8249 |
|
end on |
8250 |
|
)NKSP_CODE", |
8251 |
|
.expectRealExitResult = 6.0 |
8252 |
|
}); |
8253 |
|
|
8254 |
|
// std unit tests ... |
8255 |
|
|
8256 |
|
runScript({ |
8257 |
|
.code = R"NKSP_CODE( |
8258 |
|
on init |
8259 |
|
exit( sqrt(100.0ms) ) |
8260 |
|
end on |
8261 |
|
)NKSP_CODE", |
8262 |
|
.expectRealExitResult = 10.0, |
8263 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8264 |
|
.expectExitResultUnit = VM_SECOND |
8265 |
|
}); |
8266 |
|
|
8267 |
|
runScript({ |
8268 |
|
.code = R"NKSP_CODE( |
8269 |
|
on init |
8270 |
|
exit( sqrt(5.76kHz) ) |
8271 |
|
end on |
8272 |
|
)NKSP_CODE", |
8273 |
|
.expectRealExitResult = 2.4, |
8274 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8275 |
|
.expectExitResultUnit = VM_HERTZ |
8276 |
|
}); |
8277 |
|
|
8278 |
|
// 'final' ('!') operator tests ... |
8279 |
|
|
8280 |
|
runScript({ |
8281 |
|
.code = R"NKSP_CODE( |
8282 |
|
on init |
8283 |
|
exit( sqrt(25.0) ) |
8284 |
|
end on |
8285 |
|
)NKSP_CODE", |
8286 |
|
.expectRealExitResult = 5.0, |
8287 |
|
.expectExitResultFinal = false |
8288 |
|
}); |
8289 |
|
|
8290 |
|
runScript({ |
8291 |
|
.code = R"NKSP_CODE( |
8292 |
|
on init |
8293 |
|
exit( sqrt(!25.0) ) |
8294 |
|
end on |
8295 |
|
)NKSP_CODE", |
8296 |
|
.expectRealExitResult = 5.0, |
8297 |
|
.expectExitResultFinal = true |
8298 |
|
}); |
8299 |
|
|
8300 |
|
#if !SILENT_TEST |
8301 |
|
std::cout << std::endl; |
8302 |
|
#endif |
8303 |
|
} |
8304 |
|
|
8305 |
|
static void testBuiltInLogFunction() { |
8306 |
|
#if !SILENT_TEST |
8307 |
|
std::cout << "UNIT TEST: built-in log() function\n"; |
8308 |
|
#endif |
8309 |
|
|
8310 |
|
// integer tests ... |
8311 |
|
// (ATM not allowed for this function) |
8312 |
|
|
8313 |
|
runScript({ |
8314 |
|
.code = R"NKSP_CODE( |
8315 |
|
on init |
8316 |
|
declare $foo := 1 |
8317 |
|
exit( log($foo) ) |
8318 |
|
end on |
8319 |
|
)NKSP_CODE", |
8320 |
|
.expectParseError = true // integer not allowed for this function ATM |
8321 |
|
}); |
8322 |
|
|
8323 |
|
// real number tests ... |
8324 |
|
|
8325 |
|
runScript({ |
8326 |
|
.code = R"NKSP_CODE( |
8327 |
|
on init |
8328 |
|
exit( log(1.0) ) |
8329 |
|
end on |
8330 |
|
)NKSP_CODE", |
8331 |
|
.expectRealExitResult = 0.0 |
8332 |
|
}); |
8333 |
|
|
8334 |
|
runScript({ |
8335 |
|
.code = R"NKSP_CODE( |
8336 |
|
on init |
8337 |
|
exit( log(~NI_MATH_E) ) |
8338 |
|
end on |
8339 |
|
)NKSP_CODE", |
8340 |
|
.expectRealExitResult = 1.0 |
8341 |
|
}); |
8342 |
|
|
8343 |
|
// std unit tests ... |
8344 |
|
|
8345 |
|
runScript({ |
8346 |
|
.code = R"NKSP_CODE( |
8347 |
|
on init |
8348 |
|
exit( log(~NI_MATH_E * 1.0ms) ) |
8349 |
|
end on |
8350 |
|
)NKSP_CODE", |
8351 |
|
.expectRealExitResult = 1.0, |
8352 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8353 |
|
.expectExitResultUnit = VM_SECOND |
8354 |
|
}); |
8355 |
|
|
8356 |
|
runScript({ |
8357 |
|
.code = R"NKSP_CODE( |
8358 |
|
on init |
8359 |
|
exit( log(~NI_MATH_E * 1.0kHz) ) |
8360 |
|
end on |
8361 |
|
)NKSP_CODE", |
8362 |
|
.expectRealExitResult = 1.0, |
8363 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8364 |
|
.expectExitResultUnit = VM_HERTZ |
8365 |
|
}); |
8366 |
|
|
8367 |
|
// 'final' ('!') operator tests ... |
8368 |
|
|
8369 |
|
runScript({ |
8370 |
|
.code = R"NKSP_CODE( |
8371 |
|
on init |
8372 |
|
exit( log(~NI_MATH_E * 1.0) ) |
8373 |
|
end on |
8374 |
|
)NKSP_CODE", |
8375 |
|
.expectRealExitResult = 1.0, |
8376 |
|
.expectExitResultFinal = false |
8377 |
|
}); |
8378 |
|
|
8379 |
|
runScript({ |
8380 |
|
.code = R"NKSP_CODE( |
8381 |
|
on init |
8382 |
|
exit( log(!(~NI_MATH_E * 1.0)) ) |
8383 |
|
end on |
8384 |
|
)NKSP_CODE", |
8385 |
|
.expectRealExitResult = 1.0, |
8386 |
|
.expectExitResultFinal = true |
8387 |
|
}); |
8388 |
|
|
8389 |
|
#if !SILENT_TEST |
8390 |
|
std::cout << std::endl; |
8391 |
|
#endif |
8392 |
|
} |
8393 |
|
|
8394 |
|
static void testBuiltInLog2Function() { |
8395 |
|
#if !SILENT_TEST |
8396 |
|
std::cout << "UNIT TEST: built-in log2() function\n"; |
8397 |
|
#endif |
8398 |
|
|
8399 |
|
// integer tests ... |
8400 |
|
// (ATM not allowed for this function) |
8401 |
|
|
8402 |
|
runScript({ |
8403 |
|
.code = R"NKSP_CODE( |
8404 |
|
on init |
8405 |
|
declare $foo := 1 |
8406 |
|
exit( log2($foo) ) |
8407 |
|
end on |
8408 |
|
)NKSP_CODE", |
8409 |
|
.expectParseError = true // integer not allowed for this function ATM |
8410 |
|
}); |
8411 |
|
|
8412 |
|
// real number tests ... |
8413 |
|
|
8414 |
|
runScript({ |
8415 |
|
.code = R"NKSP_CODE( |
8416 |
|
on init |
8417 |
|
exit( log2(1.0) ) |
8418 |
|
end on |
8419 |
|
)NKSP_CODE", |
8420 |
|
.expectRealExitResult = 0.0 |
8421 |
|
}); |
8422 |
|
|
8423 |
|
runScript({ |
8424 |
|
.code = R"NKSP_CODE( |
8425 |
|
on init |
8426 |
|
exit( log2(32.0) ) |
8427 |
|
end on |
8428 |
|
)NKSP_CODE", |
8429 |
|
.expectRealExitResult = 5.0 |
8430 |
|
}); |
8431 |
|
|
8432 |
|
// std unit tests ... |
8433 |
|
|
8434 |
|
runScript({ |
8435 |
|
.code = R"NKSP_CODE( |
8436 |
|
on init |
8437 |
|
exit( log2(32.0ms) ) |
8438 |
|
end on |
8439 |
|
)NKSP_CODE", |
8440 |
|
.expectRealExitResult = 5.0, |
8441 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8442 |
|
.expectExitResultUnit = VM_SECOND |
8443 |
|
}); |
8444 |
|
|
8445 |
|
runScript({ |
8446 |
|
.code = R"NKSP_CODE( |
8447 |
|
on init |
8448 |
|
exit( log2(32.0kHz) ) |
8449 |
|
end on |
8450 |
|
)NKSP_CODE", |
8451 |
|
.expectRealExitResult = 5.0, |
8452 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8453 |
|
.expectExitResultUnit = VM_HERTZ |
8454 |
|
}); |
8455 |
|
|
8456 |
|
// 'final' ('!') operator tests ... |
8457 |
|
|
8458 |
|
runScript({ |
8459 |
|
.code = R"NKSP_CODE( |
8460 |
|
on init |
8461 |
|
exit( log2(32.0) ) |
8462 |
|
end on |
8463 |
|
)NKSP_CODE", |
8464 |
|
.expectRealExitResult = 5.0, |
8465 |
|
.expectExitResultFinal = false |
8466 |
|
}); |
8467 |
|
|
8468 |
|
runScript({ |
8469 |
|
.code = R"NKSP_CODE( |
8470 |
|
on init |
8471 |
|
exit( log2(!32.0) ) |
8472 |
|
end on |
8473 |
|
)NKSP_CODE", |
8474 |
|
.expectRealExitResult = 5.0, |
8475 |
|
.expectExitResultFinal = true |
8476 |
|
}); |
8477 |
|
|
8478 |
|
#if !SILENT_TEST |
8479 |
|
std::cout << std::endl; |
8480 |
|
#endif |
8481 |
|
} |
8482 |
|
|
8483 |
|
static void testBuiltInLog10Function() { |
8484 |
|
#if !SILENT_TEST |
8485 |
|
std::cout << "UNIT TEST: built-in log10() function\n"; |
8486 |
|
#endif |
8487 |
|
|
8488 |
|
// integer tests ... |
8489 |
|
// (ATM not allowed for this function) |
8490 |
|
|
8491 |
|
runScript({ |
8492 |
|
.code = R"NKSP_CODE( |
8493 |
|
on init |
8494 |
|
declare $foo := 1 |
8495 |
|
exit( log10($foo) ) |
8496 |
|
end on |
8497 |
|
)NKSP_CODE", |
8498 |
|
.expectParseError = true // integer not allowed for this function ATM |
8499 |
|
}); |
8500 |
|
|
8501 |
|
// real number tests ... |
8502 |
|
|
8503 |
|
runScript({ |
8504 |
|
.code = R"NKSP_CODE( |
8505 |
|
on init |
8506 |
|
exit( log10(1000.0) ) |
8507 |
|
end on |
8508 |
|
)NKSP_CODE", |
8509 |
|
.expectRealExitResult = 3.0 |
8510 |
|
}); |
8511 |
|
|
8512 |
|
runScript({ |
8513 |
|
.code = R"NKSP_CODE( |
8514 |
|
on init |
8515 |
|
exit( log10(1000.0) ) |
8516 |
|
end on |
8517 |
|
)NKSP_CODE", |
8518 |
|
.expectRealExitResult = 3.0 |
8519 |
|
}); |
8520 |
|
|
8521 |
|
// std unit tests ... |
8522 |
|
|
8523 |
|
runScript({ |
8524 |
|
.code = R"NKSP_CODE( |
8525 |
|
on init |
8526 |
|
exit( log10(1000.0ms) ) |
8527 |
|
end on |
8528 |
|
)NKSP_CODE", |
8529 |
|
.expectRealExitResult = 3.0, |
8530 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8531 |
|
.expectExitResultUnit = VM_SECOND |
8532 |
|
}); |
8533 |
|
|
8534 |
|
runScript({ |
8535 |
|
.code = R"NKSP_CODE( |
8536 |
|
on init |
8537 |
|
exit( log10(1000.0kHz) ) |
8538 |
|
end on |
8539 |
|
)NKSP_CODE", |
8540 |
|
.expectRealExitResult = 3.0, |
8541 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8542 |
|
.expectExitResultUnit = VM_HERTZ |
8543 |
|
}); |
8544 |
|
|
8545 |
|
// 'final' ('!') operator tests ... |
8546 |
|
|
8547 |
|
runScript({ |
8548 |
|
.code = R"NKSP_CODE( |
8549 |
|
on init |
8550 |
|
exit( log10(1000.0) ) |
8551 |
|
end on |
8552 |
|
)NKSP_CODE", |
8553 |
|
.expectRealExitResult = 3.0, |
8554 |
|
.expectExitResultFinal = false |
8555 |
|
}); |
8556 |
|
|
8557 |
|
runScript({ |
8558 |
|
.code = R"NKSP_CODE( |
8559 |
|
on init |
8560 |
|
exit( log10(!1000.0) ) |
8561 |
|
end on |
8562 |
|
)NKSP_CODE", |
8563 |
|
.expectRealExitResult = 3.0, |
8564 |
|
.expectExitResultFinal = true |
8565 |
|
}); |
8566 |
|
|
8567 |
|
#if !SILENT_TEST |
8568 |
|
std::cout << std::endl; |
8569 |
|
#endif |
8570 |
|
} |
8571 |
|
|
8572 |
|
static void testBuiltInExpFunction() { |
8573 |
|
#if !SILENT_TEST |
8574 |
|
std::cout << "UNIT TEST: built-in exp() function\n"; |
8575 |
|
#endif |
8576 |
|
|
8577 |
|
// integer tests ... |
8578 |
|
// (ATM not allowed for this function) |
8579 |
|
|
8580 |
|
runScript({ |
8581 |
|
.code = R"NKSP_CODE( |
8582 |
|
on init |
8583 |
|
declare $foo := 1 |
8584 |
|
exit( exp($foo) ) |
8585 |
|
end on |
8586 |
|
)NKSP_CODE", |
8587 |
|
.expectParseError = true // integer not allowed for this function ATM |
8588 |
|
}); |
8589 |
|
|
8590 |
|
// real number tests ... |
8591 |
|
|
8592 |
|
runScript({ |
8593 |
|
.code = R"NKSP_CODE( |
8594 |
|
on init |
8595 |
|
exit( exp(0.0) ) |
8596 |
|
end on |
8597 |
|
)NKSP_CODE", |
8598 |
|
.expectRealExitResult = 1.0 |
8599 |
|
}); |
8600 |
|
|
8601 |
|
runScript({ |
8602 |
|
.code = R"NKSP_CODE( |
8603 |
|
on init |
8604 |
|
exit( exp(1.0) ) |
8605 |
|
end on |
8606 |
|
)NKSP_CODE", |
8607 |
|
.expectRealExitResult = M_E |
8608 |
|
}); |
8609 |
|
|
8610 |
|
// std unit tests ... |
8611 |
|
|
8612 |
|
runScript({ |
8613 |
|
.code = R"NKSP_CODE( |
8614 |
|
on init |
8615 |
|
exit( exp(0.0ms) ) |
8616 |
|
end on |
8617 |
|
)NKSP_CODE", |
8618 |
|
.expectRealExitResult = 1.0, |
8619 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8620 |
|
.expectExitResultUnit = VM_SECOND |
8621 |
|
}); |
8622 |
|
|
8623 |
|
runScript({ |
8624 |
|
.code = R"NKSP_CODE( |
8625 |
|
on init |
8626 |
|
exit( exp(0.0kHz) ) |
8627 |
|
end on |
8628 |
|
)NKSP_CODE", |
8629 |
|
.expectRealExitResult = 1.0, |
8630 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8631 |
|
.expectExitResultUnit = VM_HERTZ |
8632 |
|
}); |
8633 |
|
|
8634 |
|
// 'final' ('!') operator tests ... |
8635 |
|
|
8636 |
|
runScript({ |
8637 |
|
.code = R"NKSP_CODE( |
8638 |
|
on init |
8639 |
|
exit( exp(0.0) ) |
8640 |
|
end on |
8641 |
|
)NKSP_CODE", |
8642 |
|
.expectRealExitResult = 1.0, |
8643 |
|
.expectExitResultFinal = false |
8644 |
|
}); |
8645 |
|
|
8646 |
|
runScript({ |
8647 |
|
.code = R"NKSP_CODE( |
8648 |
|
on init |
8649 |
|
exit( exp(!0.0) ) |
8650 |
|
end on |
8651 |
|
)NKSP_CODE", |
8652 |
|
.expectRealExitResult = 1.0, |
8653 |
|
.expectExitResultFinal = true |
8654 |
|
}); |
8655 |
|
|
8656 |
|
#if !SILENT_TEST |
8657 |
|
std::cout << std::endl; |
8658 |
|
#endif |
8659 |
|
} |
8660 |
|
|
8661 |
|
static void testBuiltInPowFunction() { |
8662 |
|
#if !SILENT_TEST |
8663 |
|
std::cout << "UNIT TEST: built-in pow() function\n"; |
8664 |
|
#endif |
8665 |
|
|
8666 |
|
// integer tests ... |
8667 |
|
// (ATM not allowed for this function) |
8668 |
|
|
8669 |
|
runScript({ |
8670 |
|
.code = R"NKSP_CODE( |
8671 |
|
on init |
8672 |
|
declare $foo := 1 |
8673 |
|
exit( pow($foo,$foo) ) |
8674 |
|
end on |
8675 |
|
)NKSP_CODE", |
8676 |
|
.expectParseError = true // integer not allowed for this function ATM |
8677 |
|
}); |
8678 |
|
|
8679 |
|
// real number tests ... |
8680 |
|
|
8681 |
|
runScript({ |
8682 |
|
.code = R"NKSP_CODE( |
8683 |
|
on init |
8684 |
|
exit( pow(1.0) ) |
8685 |
|
end on |
8686 |
|
)NKSP_CODE", |
8687 |
|
.expectParseError = true // because pow() requires exactly 2 arguments |
8688 |
|
}); |
8689 |
|
|
8690 |
|
runScript({ |
8691 |
|
.code = R"NKSP_CODE( |
8692 |
|
on init |
8693 |
|
exit( pow(3.0,4.0) ) |
8694 |
|
end on |
8695 |
|
)NKSP_CODE", |
8696 |
|
.expectRealExitResult = 81.0 |
8697 |
|
}); |
8698 |
|
|
8699 |
|
// std unit tests ... |
8700 |
|
|
8701 |
|
runScript({ |
8702 |
|
.code = R"NKSP_CODE( |
8703 |
|
on init |
8704 |
|
exit( pow(3.0ms,4.0ms) ) |
8705 |
|
end on |
8706 |
|
)NKSP_CODE", |
8707 |
|
.expectParseError = true // because units are prohibited for 2nd argument |
8708 |
|
}); |
8709 |
|
|
8710 |
|
runScript({ |
8711 |
|
.code = R"NKSP_CODE( |
8712 |
|
on init |
8713 |
|
exit( pow(3.0,4.0ms) ) |
8714 |
|
end on |
8715 |
|
)NKSP_CODE", |
8716 |
|
.expectParseError = true // because units are prohibited for 2nd argument |
8717 |
|
}); |
8718 |
|
|
8719 |
|
runScript({ |
8720 |
|
.code = R"NKSP_CODE( |
8721 |
|
on init |
8722 |
|
exit( pow(3.0ms,4.0) ) |
8723 |
|
end on |
8724 |
|
)NKSP_CODE", |
8725 |
|
.expectRealExitResult = 81.0, |
8726 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8727 |
|
.expectExitResultUnit = VM_SECOND |
8728 |
|
}); |
8729 |
|
|
8730 |
|
runScript({ |
8731 |
|
.code = R"NKSP_CODE( |
8732 |
|
on init |
8733 |
|
exit( pow(3.0kHz,4.0) ) |
8734 |
|
end on |
8735 |
|
)NKSP_CODE", |
8736 |
|
.expectRealExitResult = 81.0, |
8737 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8738 |
|
.expectExitResultUnit = VM_HERTZ |
8739 |
|
}); |
8740 |
|
|
8741 |
|
// 'final' ('!') operator tests ... |
8742 |
|
|
8743 |
|
runScript({ |
8744 |
|
.code = R"NKSP_CODE( |
8745 |
|
on init |
8746 |
|
exit( pow(3.0,4.0) ) |
8747 |
|
end on |
8748 |
|
)NKSP_CODE", |
8749 |
|
.expectRealExitResult = 81.0, |
8750 |
|
.expectExitResultFinal = false |
8751 |
|
}); |
8752 |
|
|
8753 |
|
runScript({ |
8754 |
|
.code = R"NKSP_CODE( |
8755 |
|
on init |
8756 |
|
exit( pow(!3.0,4.0) ) |
8757 |
|
end on |
8758 |
|
)NKSP_CODE", |
8759 |
|
.expectRealExitResult = 81.0, |
8760 |
|
.expectExitResultFinal = true |
8761 |
|
}); |
8762 |
|
|
8763 |
|
runScript({ |
8764 |
|
.code = R"NKSP_CODE( |
8765 |
|
on init |
8766 |
|
exit( pow(3.0,!4.0) ) |
8767 |
|
end on |
8768 |
|
)NKSP_CODE", |
8769 |
|
.expectParseError = true // because 'final' is meaningless for 2nd argument |
8770 |
|
}); |
8771 |
|
|
8772 |
|
#if !SILENT_TEST |
8773 |
|
std::cout << std::endl; |
8774 |
|
#endif |
8775 |
|
} |
8776 |
|
|
8777 |
|
static void testBuiltInSinFunction() { |
8778 |
|
#if !SILENT_TEST |
8779 |
|
std::cout << "UNIT TEST: built-in sin() function\n"; |
8780 |
|
#endif |
8781 |
|
|
8782 |
|
// integer tests ... |
8783 |
|
// (ATM not allowed for this function) |
8784 |
|
|
8785 |
|
runScript({ |
8786 |
|
.code = R"NKSP_CODE( |
8787 |
|
on init |
8788 |
|
declare $foo := 1 |
8789 |
|
exit( sin($foo) ) |
8790 |
|
end on |
8791 |
|
)NKSP_CODE", |
8792 |
|
.expectParseError = true // integer not allowed for this function ATM |
8793 |
|
}); |
8794 |
|
|
8795 |
|
// real number tests ... |
8796 |
|
|
8797 |
|
runScript({ |
8798 |
|
.code = R"NKSP_CODE( |
8799 |
|
on init |
8800 |
|
exit( sin(0.0) ) |
8801 |
|
end on |
8802 |
|
)NKSP_CODE", |
8803 |
|
.expectRealExitResult = 0.0 |
8804 |
|
}); |
8805 |
|
|
8806 |
|
runScript({ |
8807 |
|
.code = R"NKSP_CODE( |
8808 |
|
on init |
8809 |
|
exit( sin(0.5 * ~NI_MATH_PI) ) |
8810 |
|
end on |
8811 |
|
)NKSP_CODE", |
8812 |
|
.expectRealExitResult = 1.0 |
8813 |
|
}); |
8814 |
|
|
8815 |
|
runScript({ |
8816 |
|
.code = R"NKSP_CODE( |
8817 |
|
on init |
8818 |
|
exit( sin(~NI_MATH_PI) ) |
8819 |
|
end on |
8820 |
|
)NKSP_CODE", |
8821 |
|
.expectRealExitResult = 0.0 |
8822 |
|
}); |
8823 |
|
|
8824 |
|
runScript({ |
8825 |
|
.code = R"NKSP_CODE( |
8826 |
|
on init |
8827 |
|
exit( sin(1.5 * ~NI_MATH_PI) ) |
8828 |
|
end on |
8829 |
|
)NKSP_CODE", |
8830 |
|
.expectRealExitResult = -1.0 |
8831 |
|
}); |
8832 |
|
|
8833 |
|
// std unit tests ... |
8834 |
|
|
8835 |
|
runScript({ |
8836 |
|
.code = R"NKSP_CODE( |
8837 |
|
on init |
8838 |
|
exit( sin(0.0ms) ) |
8839 |
|
end on |
8840 |
|
)NKSP_CODE", |
8841 |
|
.expectRealExitResult = 0.0, |
8842 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8843 |
|
.expectExitResultUnit = VM_SECOND |
8844 |
|
}); |
8845 |
|
|
8846 |
|
runScript({ |
8847 |
|
.code = R"NKSP_CODE( |
8848 |
|
on init |
8849 |
|
exit( sin(0.0kHz) ) |
8850 |
|
end on |
8851 |
|
)NKSP_CODE", |
8852 |
|
.expectRealExitResult = 0.0, |
8853 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8854 |
|
.expectExitResultUnit = VM_HERTZ |
8855 |
|
}); |
8856 |
|
|
8857 |
|
// 'final' ('!') operator tests ... |
8858 |
|
|
8859 |
|
runScript({ |
8860 |
|
.code = R"NKSP_CODE( |
8861 |
|
on init |
8862 |
|
exit( sin(0.0) ) |
8863 |
|
end on |
8864 |
|
)NKSP_CODE", |
8865 |
|
.expectRealExitResult = 0.0, |
8866 |
|
.expectExitResultFinal = false |
8867 |
|
}); |
8868 |
|
|
8869 |
|
runScript({ |
8870 |
|
.code = R"NKSP_CODE( |
8871 |
|
on init |
8872 |
|
exit( sin(!0.0) ) |
8873 |
|
end on |
8874 |
|
)NKSP_CODE", |
8875 |
|
.expectRealExitResult = 0.0, |
8876 |
|
.expectExitResultFinal = true |
8877 |
|
}); |
8878 |
|
|
8879 |
|
#if !SILENT_TEST |
8880 |
|
std::cout << std::endl; |
8881 |
|
#endif |
8882 |
|
} |
8883 |
|
|
8884 |
|
static void testBuiltInCosFunction() { |
8885 |
|
#if !SILENT_TEST |
8886 |
|
std::cout << "UNIT TEST: built-in cos() function\n"; |
8887 |
|
#endif |
8888 |
|
|
8889 |
|
// integer tests ... |
8890 |
|
// (ATM not allowed for this function) |
8891 |
|
|
8892 |
|
runScript({ |
8893 |
|
.code = R"NKSP_CODE( |
8894 |
|
on init |
8895 |
|
declare $foo := 1 |
8896 |
|
exit( cos($foo) ) |
8897 |
|
end on |
8898 |
|
)NKSP_CODE", |
8899 |
|
.expectParseError = true // integer not allowed for this function ATM |
8900 |
|
}); |
8901 |
|
|
8902 |
|
// real number tests ... |
8903 |
|
|
8904 |
|
runScript({ |
8905 |
|
.code = R"NKSP_CODE( |
8906 |
|
on init |
8907 |
|
exit( cos(0.0) ) |
8908 |
|
end on |
8909 |
|
)NKSP_CODE", |
8910 |
|
.expectRealExitResult = 1.0 |
8911 |
|
}); |
8912 |
|
|
8913 |
|
runScript({ |
8914 |
|
.code = R"NKSP_CODE( |
8915 |
|
on init |
8916 |
|
exit( cos(0.5 * ~NI_MATH_PI) ) |
8917 |
|
end on |
8918 |
|
)NKSP_CODE", |
8919 |
|
.expectRealExitResult = 0.0 |
8920 |
|
}); |
8921 |
|
|
8922 |
|
runScript({ |
8923 |
|
.code = R"NKSP_CODE( |
8924 |
|
on init |
8925 |
|
exit( cos(~NI_MATH_PI) ) |
8926 |
|
end on |
8927 |
|
)NKSP_CODE", |
8928 |
|
.expectRealExitResult = -1.0 |
8929 |
|
}); |
8930 |
|
|
8931 |
|
runScript({ |
8932 |
|
.code = R"NKSP_CODE( |
8933 |
|
on init |
8934 |
|
exit( cos(1.5 * ~NI_MATH_PI) ) |
8935 |
|
end on |
8936 |
|
)NKSP_CODE", |
8937 |
|
.expectRealExitResult = 0.0 |
8938 |
|
}); |
8939 |
|
|
8940 |
|
// std unit tests ... |
8941 |
|
|
8942 |
|
runScript({ |
8943 |
|
.code = R"NKSP_CODE( |
8944 |
|
on init |
8945 |
|
exit( cos(0.0ms) ) |
8946 |
|
end on |
8947 |
|
)NKSP_CODE", |
8948 |
|
.expectRealExitResult = 1.0, |
8949 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
8950 |
|
.expectExitResultUnit = VM_SECOND |
8951 |
|
}); |
8952 |
|
|
8953 |
|
runScript({ |
8954 |
|
.code = R"NKSP_CODE( |
8955 |
|
on init |
8956 |
|
exit( cos(0.0kHz) ) |
8957 |
|
end on |
8958 |
|
)NKSP_CODE", |
8959 |
|
.expectRealExitResult = 1.0, |
8960 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
8961 |
|
.expectExitResultUnit = VM_HERTZ |
8962 |
|
}); |
8963 |
|
|
8964 |
|
// 'final' ('!') operator tests ... |
8965 |
|
|
8966 |
|
runScript({ |
8967 |
|
.code = R"NKSP_CODE( |
8968 |
|
on init |
8969 |
|
exit( cos(0.0) ) |
8970 |
|
end on |
8971 |
|
)NKSP_CODE", |
8972 |
|
.expectRealExitResult = 1.0, |
8973 |
|
.expectExitResultFinal = false |
8974 |
|
}); |
8975 |
|
|
8976 |
|
runScript({ |
8977 |
|
.code = R"NKSP_CODE( |
8978 |
|
on init |
8979 |
|
exit( cos(!0.0) ) |
8980 |
|
end on |
8981 |
|
)NKSP_CODE", |
8982 |
|
.expectRealExitResult = 1.0, |
8983 |
|
.expectExitResultFinal = true |
8984 |
|
}); |
8985 |
|
|
8986 |
|
#if !SILENT_TEST |
8987 |
|
std::cout << std::endl; |
8988 |
|
#endif |
8989 |
|
} |
8990 |
|
|
8991 |
|
static void testBuiltInTanFunction() { |
8992 |
|
#if !SILENT_TEST |
8993 |
|
std::cout << "UNIT TEST: built-in tan() function\n"; |
8994 |
|
#endif |
8995 |
|
|
8996 |
|
// integer tests ... |
8997 |
|
// (ATM not allowed for this function) |
8998 |
|
|
8999 |
|
runScript({ |
9000 |
|
.code = R"NKSP_CODE( |
9001 |
|
on init |
9002 |
|
declare $foo := 1 |
9003 |
|
exit( tan($foo) ) |
9004 |
|
end on |
9005 |
|
)NKSP_CODE", |
9006 |
|
.expectParseError = true // integer not allowed for this function ATM |
9007 |
|
}); |
9008 |
|
|
9009 |
|
// real number tests ... |
9010 |
|
|
9011 |
|
runScript({ |
9012 |
|
.code = R"NKSP_CODE( |
9013 |
|
on init |
9014 |
|
exit( tan(0.0) ) |
9015 |
|
end on |
9016 |
|
)NKSP_CODE", |
9017 |
|
.expectRealExitResult = 0.0 |
9018 |
|
}); |
9019 |
|
|
9020 |
|
runScript({ |
9021 |
|
.code = R"NKSP_CODE( |
9022 |
|
on init |
9023 |
|
exit( tan(0.25 * ~NI_MATH_PI) ) |
9024 |
|
end on |
9025 |
|
)NKSP_CODE", |
9026 |
|
.expectRealExitResult = 1.0 |
9027 |
|
}); |
9028 |
|
|
9029 |
|
// std unit tests ... |
9030 |
|
|
9031 |
|
runScript({ |
9032 |
|
.code = R"NKSP_CODE( |
9033 |
|
on init |
9034 |
|
exit( tan(0.0ms) ) |
9035 |
|
end on |
9036 |
|
)NKSP_CODE", |
9037 |
|
.expectRealExitResult = 0.0, |
9038 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9039 |
|
.expectExitResultUnit = VM_SECOND |
9040 |
|
}); |
9041 |
|
|
9042 |
|
runScript({ |
9043 |
|
.code = R"NKSP_CODE( |
9044 |
|
on init |
9045 |
|
exit( tan(0.0kHz) ) |
9046 |
|
end on |
9047 |
|
)NKSP_CODE", |
9048 |
|
.expectRealExitResult = 0.0, |
9049 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9050 |
|
.expectExitResultUnit = VM_HERTZ |
9051 |
|
}); |
9052 |
|
|
9053 |
|
// 'final' ('!') operator tests ... |
9054 |
|
|
9055 |
|
runScript({ |
9056 |
|
.code = R"NKSP_CODE( |
9057 |
|
on init |
9058 |
|
exit( tan(0.0) ) |
9059 |
|
end on |
9060 |
|
)NKSP_CODE", |
9061 |
|
.expectRealExitResult = 0.0, |
9062 |
|
.expectExitResultFinal = false |
9063 |
|
}); |
9064 |
|
|
9065 |
|
runScript({ |
9066 |
|
.code = R"NKSP_CODE( |
9067 |
|
on init |
9068 |
|
exit( tan(!0.0) ) |
9069 |
|
end on |
9070 |
|
)NKSP_CODE", |
9071 |
|
.expectRealExitResult = 0.0, |
9072 |
|
.expectExitResultFinal = true |
9073 |
|
}); |
9074 |
|
|
9075 |
|
#if !SILENT_TEST |
9076 |
|
std::cout << std::endl; |
9077 |
|
#endif |
9078 |
|
} |
9079 |
|
|
9080 |
|
static void testBuiltInAsinFunction() { |
9081 |
|
#if !SILENT_TEST |
9082 |
|
std::cout << "UNIT TEST: built-in asin() function\n"; |
9083 |
|
#endif |
9084 |
|
|
9085 |
|
// integer tests ... |
9086 |
|
// (ATM not allowed for this function) |
9087 |
|
|
9088 |
|
runScript({ |
9089 |
|
.code = R"NKSP_CODE( |
9090 |
|
on init |
9091 |
|
declare $foo := 1 |
9092 |
|
exit( asin($foo) ) |
9093 |
|
end on |
9094 |
|
)NKSP_CODE", |
9095 |
|
.expectParseError = true // integer not allowed for this function ATM |
9096 |
|
}); |
9097 |
|
|
9098 |
|
// real number tests ... |
9099 |
|
|
9100 |
|
runScript({ |
9101 |
|
.code = R"NKSP_CODE( |
9102 |
|
on init |
9103 |
|
exit( asin(0.0) ) |
9104 |
|
end on |
9105 |
|
)NKSP_CODE", |
9106 |
|
.expectRealExitResult = 0.0 |
9107 |
|
}); |
9108 |
|
|
9109 |
|
runScript({ |
9110 |
|
.code = R"NKSP_CODE( |
9111 |
|
on init |
9112 |
|
exit( asin(1.0) ) |
9113 |
|
end on |
9114 |
|
)NKSP_CODE", |
9115 |
|
.expectRealExitResult = 0.5 * M_PI |
9116 |
|
}); |
9117 |
|
|
9118 |
|
runScript({ |
9119 |
|
.code = R"NKSP_CODE( |
9120 |
|
on init |
9121 |
|
exit( asin(-1.0) ) |
9122 |
|
end on |
9123 |
|
)NKSP_CODE", |
9124 |
|
.expectRealExitResult = -0.5 * M_PI |
9125 |
|
}); |
9126 |
|
|
9127 |
|
// std unit tests ... |
9128 |
|
|
9129 |
|
runScript({ |
9130 |
|
.code = R"NKSP_CODE( |
9131 |
|
on init |
9132 |
|
exit( asin(0.0ms) ) |
9133 |
|
end on |
9134 |
|
)NKSP_CODE", |
9135 |
|
.expectRealExitResult = 0.0, |
9136 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9137 |
|
.expectExitResultUnit = VM_SECOND |
9138 |
|
}); |
9139 |
|
|
9140 |
|
runScript({ |
9141 |
|
.code = R"NKSP_CODE( |
9142 |
|
on init |
9143 |
|
exit( asin(0.0kHz) ) |
9144 |
|
end on |
9145 |
|
)NKSP_CODE", |
9146 |
|
.expectRealExitResult = 0.0, |
9147 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9148 |
|
.expectExitResultUnit = VM_HERTZ |
9149 |
|
}); |
9150 |
|
|
9151 |
|
// 'final' ('!') operator tests ... |
9152 |
|
|
9153 |
|
runScript({ |
9154 |
|
.code = R"NKSP_CODE( |
9155 |
|
on init |
9156 |
|
exit( asin(0.0) ) |
9157 |
|
end on |
9158 |
|
)NKSP_CODE", |
9159 |
|
.expectRealExitResult = 0.0, |
9160 |
|
.expectExitResultFinal = false |
9161 |
|
}); |
9162 |
|
|
9163 |
|
runScript({ |
9164 |
|
.code = R"NKSP_CODE( |
9165 |
|
on init |
9166 |
|
exit( asin(!0.0) ) |
9167 |
|
end on |
9168 |
|
)NKSP_CODE", |
9169 |
|
.expectRealExitResult = 0.0, |
9170 |
|
.expectExitResultFinal = true |
9171 |
|
}); |
9172 |
|
|
9173 |
|
#if !SILENT_TEST |
9174 |
|
std::cout << std::endl; |
9175 |
|
#endif |
9176 |
|
} |
9177 |
|
|
9178 |
|
static void testBuiltInAcosFunction() { |
9179 |
|
#if !SILENT_TEST |
9180 |
|
std::cout << "UNIT TEST: built-in acos() function\n"; |
9181 |
|
#endif |
9182 |
|
|
9183 |
|
// integer tests ... |
9184 |
|
// (ATM not allowed for this function) |
9185 |
|
|
9186 |
|
runScript({ |
9187 |
|
.code = R"NKSP_CODE( |
9188 |
|
on init |
9189 |
|
declare $foo := 1 |
9190 |
|
exit( acos($foo) ) |
9191 |
|
end on |
9192 |
|
)NKSP_CODE", |
9193 |
|
.expectParseError = true // integer not allowed for this function ATM |
9194 |
|
}); |
9195 |
|
|
9196 |
|
// real number tests ... |
9197 |
|
|
9198 |
|
runScript({ |
9199 |
|
.code = R"NKSP_CODE( |
9200 |
|
on init |
9201 |
|
exit( acos(1.0) ) |
9202 |
|
end on |
9203 |
|
)NKSP_CODE", |
9204 |
|
.expectRealExitResult = 0.0 |
9205 |
|
}); |
9206 |
|
|
9207 |
|
runScript({ |
9208 |
|
.code = R"NKSP_CODE( |
9209 |
|
on init |
9210 |
|
exit( acos(0.0) ) |
9211 |
|
end on |
9212 |
|
)NKSP_CODE", |
9213 |
|
.expectRealExitResult = 0.5 * M_PI |
9214 |
|
}); |
9215 |
|
|
9216 |
|
runScript({ |
9217 |
|
.code = R"NKSP_CODE( |
9218 |
|
on init |
9219 |
|
exit( acos(-1.0) ) |
9220 |
|
end on |
9221 |
|
)NKSP_CODE", |
9222 |
|
.expectRealExitResult = M_PI |
9223 |
|
}); |
9224 |
|
|
9225 |
|
// std unit tests ... |
9226 |
|
|
9227 |
|
runScript({ |
9228 |
|
.code = R"NKSP_CODE( |
9229 |
|
on init |
9230 |
|
exit( acos(1.0ms) ) |
9231 |
|
end on |
9232 |
|
)NKSP_CODE", |
9233 |
|
.expectRealExitResult = 0.0, |
9234 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9235 |
|
.expectExitResultUnit = VM_SECOND |
9236 |
|
}); |
9237 |
|
|
9238 |
|
runScript({ |
9239 |
|
.code = R"NKSP_CODE( |
9240 |
|
on init |
9241 |
|
exit( acos(1.0kHz) ) |
9242 |
|
end on |
9243 |
|
)NKSP_CODE", |
9244 |
|
.expectRealExitResult = 0.0, |
9245 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9246 |
|
.expectExitResultUnit = VM_HERTZ |
9247 |
|
}); |
9248 |
|
|
9249 |
|
// 'final' ('!') operator tests ... |
9250 |
|
|
9251 |
|
runScript({ |
9252 |
|
.code = R"NKSP_CODE( |
9253 |
|
on init |
9254 |
|
exit( acos(1.0) ) |
9255 |
|
end on |
9256 |
|
)NKSP_CODE", |
9257 |
|
.expectRealExitResult = 0.0, |
9258 |
|
.expectExitResultFinal = false |
9259 |
|
}); |
9260 |
|
|
9261 |
|
runScript({ |
9262 |
|
.code = R"NKSP_CODE( |
9263 |
|
on init |
9264 |
|
exit( acos(!1.0) ) |
9265 |
|
end on |
9266 |
|
)NKSP_CODE", |
9267 |
|
.expectRealExitResult = 0.0, |
9268 |
|
.expectExitResultFinal = true |
9269 |
|
}); |
9270 |
|
|
9271 |
|
#if !SILENT_TEST |
9272 |
|
std::cout << std::endl; |
9273 |
|
#endif |
9274 |
|
} |
9275 |
|
|
9276 |
|
static void testBuiltInAtanFunction() { |
9277 |
|
#if !SILENT_TEST |
9278 |
|
std::cout << "UNIT TEST: built-in atan() function\n"; |
9279 |
|
#endif |
9280 |
|
|
9281 |
|
// integer tests ... |
9282 |
|
// (ATM not allowed for this function) |
9283 |
|
|
9284 |
|
runScript({ |
9285 |
|
.code = R"NKSP_CODE( |
9286 |
|
on init |
9287 |
|
declare $foo := 1 |
9288 |
|
exit( atan($foo) ) |
9289 |
|
end on |
9290 |
|
)NKSP_CODE", |
9291 |
|
.expectParseError = true // integer not allowed for this function ATM |
9292 |
|
}); |
9293 |
|
|
9294 |
|
// real number tests ... |
9295 |
|
|
9296 |
|
runScript({ |
9297 |
|
.code = R"NKSP_CODE( |
9298 |
|
on init |
9299 |
|
exit( atan(0.0) ) |
9300 |
|
end on |
9301 |
|
)NKSP_CODE", |
9302 |
|
.expectRealExitResult = 0.0 |
9303 |
|
}); |
9304 |
|
|
9305 |
|
runScript({ |
9306 |
|
.code = R"NKSP_CODE( |
9307 |
|
on init |
9308 |
|
exit( atan(1.0) ) |
9309 |
|
end on |
9310 |
|
)NKSP_CODE", |
9311 |
|
.expectRealExitResult = 0.25 * M_PI |
9312 |
|
}); |
9313 |
|
|
9314 |
|
// std unit tests ... |
9315 |
|
|
9316 |
|
runScript({ |
9317 |
|
.code = R"NKSP_CODE( |
9318 |
|
on init |
9319 |
|
exit( atan(0.0ms) ) |
9320 |
|
end on |
9321 |
|
)NKSP_CODE", |
9322 |
|
.expectRealExitResult = 0.0, |
9323 |
|
.expectExitResultUnitPrefix = { VM_MILLI }, |
9324 |
|
.expectExitResultUnit = VM_SECOND |
9325 |
|
}); |
9326 |
|
|
9327 |
|
runScript({ |
9328 |
|
.code = R"NKSP_CODE( |
9329 |
|
on init |
9330 |
|
exit( atan(0.0kHz) ) |
9331 |
|
end on |
9332 |
|
)NKSP_CODE", |
9333 |
|
.expectRealExitResult = 0.0, |
9334 |
|
.expectExitResultUnitPrefix = { VM_KILO }, |
9335 |
|
.expectExitResultUnit = VM_HERTZ |
9336 |
|
}); |
9337 |
|
|
9338 |
|
// 'final' ('!') operator tests ... |
9339 |
|
|
9340 |
|
runScript({ |
9341 |
|
.code = R"NKSP_CODE( |
9342 |
|
on init |
9343 |
|
exit( atan(0.0) ) |
9344 |
|
end on |
9345 |
|
)NKSP_CODE", |
9346 |
|
.expectRealExitResult = 0.0, |
9347 |
|
.expectExitResultFinal = false |
9348 |
|
}); |
9349 |
|
|
9350 |
|
runScript({ |
9351 |
|
.code = R"NKSP_CODE( |
9352 |
|
on init |
9353 |
|
exit( atan(!0.0) ) |
9354 |
|
end on |
9355 |
|
)NKSP_CODE", |
9356 |
|
.expectRealExitResult = 0.0, |
9357 |
|
.expectExitResultFinal = true |
9358 |
|
}); |
9359 |
|
|
9360 |
|
#if !SILENT_TEST |
9361 |
|
std::cout << std::endl; |
9362 |
|
#endif |
9363 |
|
} |
9364 |
|
|
9365 |
static void testBuiltInNumElementsFunction() { |
static void testBuiltInNumElementsFunction() { |
9366 |
#if !SILENT_TEST |
#if !SILENT_TEST |
9367 |
std::cout << "UNIT TEST: built-in num_elements() function\n"; |
std::cout << "UNIT TEST: built-in num_elements() function\n"; |
9655 |
testBuiltInRealFunction(); |
testBuiltInRealFunction(); |
9656 |
testBuiltInRealToIntFunction(); |
testBuiltInRealToIntFunction(); |
9657 |
testBuiltInIntFunction(); |
testBuiltInIntFunction(); |
9658 |
|
testBuiltInRoundFunction(); |
9659 |
|
testBuiltInCeilFunction(); |
9660 |
|
testBuiltInFloorFunction(); |
9661 |
|
testBuiltInSqrtFunction(); |
9662 |
|
testBuiltInLogFunction(); |
9663 |
|
testBuiltInLog2Function(); |
9664 |
|
testBuiltInLog10Function(); |
9665 |
|
testBuiltInExpFunction(); |
9666 |
|
testBuiltInPowFunction(); |
9667 |
|
testBuiltInSinFunction(); |
9668 |
|
testBuiltInCosFunction(); |
9669 |
|
testBuiltInTanFunction(); |
9670 |
|
testBuiltInAsinFunction(); |
9671 |
|
testBuiltInAcosFunction(); |
9672 |
|
testBuiltInAtanFunction(); |
9673 |
testBuiltInArrayEqualFunction(); |
testBuiltInArrayEqualFunction(); |
9674 |
testBuiltInSortFunction(); |
testBuiltInSortFunction(); |
9675 |
testBuiltInNumElementsFunction(); |
testBuiltInNumElementsFunction(); |