--- linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp 2019/09/01 20:01:03 3589 +++ linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp 2019/09/02 09:03:31 3590 @@ -7897,6 +7897,1431 @@ #endif } +static void testBuiltInRoundFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in round() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( round($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(99.4) ) +end on +)NKSP_CODE", + .expectRealExitResult = 99.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(99.5) ) +end on +)NKSP_CODE", + .expectRealExitResult = 100.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(2.4ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 2.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(2.6kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(123.8) ) +end on +)NKSP_CODE", + .expectRealExitResult = 124.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( round(!123.8) ) +end on +)NKSP_CODE", + .expectRealExitResult = 124.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInCeilFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in ceil() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( ceil($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(99.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 99.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(99.1) ) +end on +)NKSP_CODE", + .expectRealExitResult = 100.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(99.9) ) +end on +)NKSP_CODE", + .expectRealExitResult = 100.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(2.4ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(2.6kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(123.1) ) +end on +)NKSP_CODE", + .expectRealExitResult = 124.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( ceil(!123.8) ) +end on +)NKSP_CODE", + .expectRealExitResult = 124.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInFloorFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in floor() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( floor($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(99.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 99.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(99.1) ) +end on +)NKSP_CODE", + .expectRealExitResult = 99.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(99.9) ) +end on +)NKSP_CODE", + .expectRealExitResult = 99.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(2.4ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 2.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(2.6kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 2.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(123.1) ) +end on +)NKSP_CODE", + .expectRealExitResult = 123.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( floor(!123.8) ) +end on +)NKSP_CODE", + .expectRealExitResult = 123.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInSqrtFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in sqrt() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( sqrt($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sqrt(36.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 6.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sqrt(100.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 10.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sqrt(5.76kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 2.4, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sqrt(25.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sqrt(!25.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInLogFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in log() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( log($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(~NI_MATH_E) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(~NI_MATH_E * 1.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(~NI_MATH_E * 1.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(~NI_MATH_E * 1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log(!(~NI_MATH_E * 1.0)) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInLog2Function() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in log2() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( log2($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(32.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(32.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(32.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(32.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log2(!32.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 5.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInLog10Function() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in log10() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( log10($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(1000.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(1000.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(1000.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(1000.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(1000.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( log10(!1000.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 3.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInExpFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in exp() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( exp($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = M_E + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( exp(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInPowFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in pow() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( pow($foo,$foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(1.0) ) +end on +)NKSP_CODE", + .expectParseError = true // because pow() requires exactly 2 arguments + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0,4.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 81.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0ms,4.0ms) ) +end on +)NKSP_CODE", + .expectParseError = true // because units are prohibited for 2nd argument + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0,4.0ms) ) +end on +)NKSP_CODE", + .expectParseError = true // because units are prohibited for 2nd argument + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0ms,4.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 81.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0kHz,4.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 81.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0,4.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 81.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(!3.0,4.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 81.0, + .expectExitResultFinal = true + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( pow(3.0,!4.0) ) +end on +)NKSP_CODE", + .expectParseError = true // because 'final' is meaningless for 2nd argument + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInSinFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in sin() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( sin($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(0.5 * ~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(1.5 * ~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = -1.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( sin(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInCosFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in cos() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( cos($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(0.5 * ~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = -1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(1.5 * ~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( cos(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInTanFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in tan() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( tan($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(0.25 * ~NI_MATH_PI) ) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( tan(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInAsinFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in asin() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( asin($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.5 * M_PI + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(-1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = -0.5 * M_PI + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( asin(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInAcosFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in acos() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( acos($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.5 * M_PI + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(-1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = M_PI + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(1.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(1.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( acos(!1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + +static void testBuiltInAtanFunction() { + #if !SILENT_TEST + std::cout << "UNIT TEST: built-in atan() function\n"; + #endif + + // integer tests ... + // (ATM not allowed for this function) + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := 1 + exit( atan($foo) ) +end on +)NKSP_CODE", + .expectParseError = true // integer not allowed for this function ATM + }); + + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(1.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.25 * M_PI + }); + + // std unit tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(0.0ms) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_MILLI }, + .expectExitResultUnit = VM_SECOND + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(0.0kHz) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultUnitPrefix = { VM_KILO }, + .expectExitResultUnit = VM_HERTZ + }); + + // 'final' ('!') operator tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = false + }); + + runScript({ + .code = R"NKSP_CODE( +on init + exit( atan(!0.0) ) +end on +)NKSP_CODE", + .expectRealExitResult = 0.0, + .expectExitResultFinal = true + }); + + #if !SILENT_TEST + std::cout << std::endl; + #endif +} + static void testBuiltInNumElementsFunction() { #if !SILENT_TEST std::cout << "UNIT TEST: built-in num_elements() function\n"; @@ -8190,6 +9615,21 @@ testBuiltInRealFunction(); testBuiltInRealToIntFunction(); testBuiltInIntFunction(); + testBuiltInRoundFunction(); + testBuiltInCeilFunction(); + testBuiltInFloorFunction(); + testBuiltInSqrtFunction(); + testBuiltInLogFunction(); + testBuiltInLog2Function(); + testBuiltInLog10Function(); + testBuiltInExpFunction(); + testBuiltInPowFunction(); + testBuiltInSinFunction(); + testBuiltInCosFunction(); + testBuiltInTanFunction(); + testBuiltInAsinFunction(); + testBuiltInAcosFunction(); + testBuiltInAtanFunction(); testBuiltInArrayEqualFunction(); testBuiltInSortFunction(); testBuiltInNumElementsFunction();