--- linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp 2019/08/28 12:56:38 3576 +++ linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp 2019/08/28 15:23:23 3577 @@ -2382,6 +2382,8 @@ .expectParseError = true // because min() function requires 2 arguments }); + // integer tests ... + runScript({ .code = R"NKSP_CODE( on init @@ -2402,6 +2404,70 @@ .expectIntExitResult = -30 }); + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(1.0, 2.0) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(-30.0, 4.0) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = -30.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(1.1, 1.13) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.1 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(1.13, 1.1) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.1 + }); + + // mixed type tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(1, 1.16) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := min(-3.92, 9) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = -3.92 + }); + #if !SILENT_TEST std::cout << std::endl; #endif @@ -2412,6 +2478,8 @@ std::cout << "UNIT TEST: built-in max() function\n"; #endif + // integer tests ... + runScript({ .code = R"NKSP_CODE( on init @@ -2459,6 +2527,70 @@ .expectIntExitResult = 4 }); + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(1.0, 2.0) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 2.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(-30.0, 4.0) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 4.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(1.1, 1.13) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.13 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(1.13, 1.1) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.13 + }); + + // mixed type tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(1, 1.16) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 1.16 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare $foo := max(-3.92, 9) + exit($foo) +end on +)NKSP_CODE", + .expectRealExitResult = 9.0 + }); + #if !SILENT_TEST std::cout << std::endl; #endif @@ -2487,6 +2619,8 @@ .expectParseError = true // because abs() function requires 1 argument }); + // integer tests ... + runScript({ .code = R"NKSP_CODE( on init @@ -2507,6 +2641,49 @@ .expectIntExitResult = 23 }); + // real number tests ... + + runScript({ + .code = R"NKSP_CODE( +on init + declare ~foo := abs(23.0) + exit(~foo) +end on +)NKSP_CODE", + .expectRealExitResult = 23.0 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare ~foo := abs(23.11) + exit(~foo) +end on +)NKSP_CODE", + .expectRealExitResult = 23.11 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare ~foo := abs(-23.11) + exit(~foo) +end on +)NKSP_CODE", + .expectRealExitResult = 23.11 + }); + + runScript({ + .code = R"NKSP_CODE( +on init + declare ~bar := -23.11 + declare ~foo := abs(~bar) + exit(~foo) +end on +)NKSP_CODE", + .expectRealExitResult = 23.11 + }); + #if !SILENT_TEST std::cout << std::endl; #endif