/[svn]/linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/tests/NKSPTest.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3589 by schoenebeck, Fri Aug 30 18:59:21 2019 UTC revision 3590 by schoenebeck, Mon Sep 2 09:03:31 2019 UTC
# Line 7897  end on Line 7897  end on
7897      #endif      #endif
7898  }  }
7899    
7900    static void testBuiltInRoundFunction() {
7901        #if !SILENT_TEST
7902        std::cout << "UNIT TEST: built-in round() function\n";
7903        #endif
7904    
7905        // integer tests ...
7906        // (ATM not allowed for this function)
7907    
7908        runScript({
7909            .code = R"NKSP_CODE(
7910    on init
7911      declare $foo := 1
7912      exit( round($foo) )
7913    end on
7914    )NKSP_CODE",
7915            .expectParseError = true // integer not allowed for this function ATM
7916        });
7917    
7918        // real number tests ...
7919    
7920        runScript({
7921            .code = R"NKSP_CODE(
7922    on init
7923      exit( round(99.4) )
7924    end on
7925    )NKSP_CODE",
7926            .expectRealExitResult = 99.0
7927        });
7928    
7929        runScript({
7930            .code = R"NKSP_CODE(
7931    on init
7932      exit( round(99.5) )
7933    end on
7934    )NKSP_CODE",
7935            .expectRealExitResult = 100.0
7936        });
7937    
7938        // std unit tests ...
7939    
7940        runScript({
7941            .code = R"NKSP_CODE(
7942    on init
7943      exit( round(2.4ms) )
7944    end on
7945    )NKSP_CODE",
7946            .expectRealExitResult = 2.0,
7947            .expectExitResultUnitPrefix = { VM_MILLI },
7948            .expectExitResultUnit = VM_SECOND
7949        });
7950    
7951        runScript({
7952            .code = R"NKSP_CODE(
7953    on init
7954      exit( round(2.6kHz) )
7955    end on
7956    )NKSP_CODE",
7957            .expectRealExitResult = 3.0,
7958            .expectExitResultUnitPrefix = { VM_KILO },
7959            .expectExitResultUnit = VM_HERTZ
7960        });
7961    
7962        // 'final' ('!') operator tests ...
7963    
7964        runScript({
7965            .code = R"NKSP_CODE(
7966    on init
7967      exit( round(123.8) )
7968    end on
7969    )NKSP_CODE",
7970            .expectRealExitResult = 124.0,
7971            .expectExitResultFinal = false
7972        });
7973    
7974        runScript({
7975            .code = R"NKSP_CODE(
7976    on init
7977      exit( round(!123.8) )
7978    end on
7979    )NKSP_CODE",
7980            .expectRealExitResult = 124.0,
7981            .expectExitResultFinal = true
7982        });
7983    
7984        #if !SILENT_TEST
7985        std::cout << std::endl;
7986        #endif
7987    }
7988    
7989    static void testBuiltInCeilFunction() {
7990        #if !SILENT_TEST
7991        std::cout << "UNIT TEST: built-in ceil() function\n";
7992        #endif
7993    
7994        // integer tests ...
7995        // (ATM not allowed for this function)
7996    
7997        runScript({
7998            .code = R"NKSP_CODE(
7999    on init
8000      declare $foo := 1
8001      exit( ceil($foo) )
8002    end on
8003    )NKSP_CODE",
8004            .expectParseError = true // integer not allowed for this function ATM
8005        });
8006    
8007        // real number tests ...
8008    
8009        runScript({
8010            .code = R"NKSP_CODE(
8011    on init
8012      exit( ceil(99.0) )
8013    end on
8014    )NKSP_CODE",
8015            .expectRealExitResult = 99.0
8016        });
8017    
8018        runScript({
8019            .code = R"NKSP_CODE(
8020    on init
8021      exit( ceil(99.1) )
8022    end on
8023    )NKSP_CODE",
8024            .expectRealExitResult = 100.0
8025        });
8026    
8027        runScript({
8028            .code = R"NKSP_CODE(
8029    on init
8030      exit( ceil(99.9) )
8031    end on
8032    )NKSP_CODE",
8033            .expectRealExitResult = 100.0
8034        });
8035    
8036        // std unit tests ...
8037    
8038        runScript({
8039            .code = R"NKSP_CODE(
8040    on init
8041      exit( ceil(2.4ms) )
8042    end on
8043    )NKSP_CODE",
8044            .expectRealExitResult = 3.0,
8045            .expectExitResultUnitPrefix = { VM_MILLI },
8046            .expectExitResultUnit = VM_SECOND
8047        });
8048    
8049        runScript({
8050            .code = R"NKSP_CODE(
8051    on init
8052      exit( ceil(2.6kHz) )
8053    end on
8054    )NKSP_CODE",
8055            .expectRealExitResult = 3.0,
8056            .expectExitResultUnitPrefix = { VM_KILO },
8057            .expectExitResultUnit = VM_HERTZ
8058        });
8059    
8060        // 'final' ('!') operator tests ...
8061    
8062        runScript({
8063            .code = R"NKSP_CODE(
8064    on init
8065      exit( ceil(123.1) )
8066    end on
8067    )NKSP_CODE",
8068            .expectRealExitResult = 124.0,
8069            .expectExitResultFinal = false
8070        });
8071    
8072        runScript({
8073            .code = R"NKSP_CODE(
8074    on init
8075      exit( ceil(!123.8) )
8076    end on
8077    )NKSP_CODE",
8078            .expectRealExitResult = 124.0,
8079            .expectExitResultFinal = true
8080        });
8081    
8082        #if !SILENT_TEST
8083        std::cout << std::endl;
8084        #endif
8085    }
8086    
8087    static void testBuiltInFloorFunction() {
8088        #if !SILENT_TEST
8089        std::cout << "UNIT TEST: built-in floor() function\n";
8090        #endif
8091    
8092        // integer tests ...
8093        // (ATM not allowed for this function)
8094    
8095        runScript({
8096            .code = R"NKSP_CODE(
8097    on init
8098      declare $foo := 1
8099      exit( floor($foo) )
8100    end on
8101    )NKSP_CODE",
8102            .expectParseError = true // integer not allowed for this function ATM
8103        });
8104    
8105        // real number tests ...
8106    
8107        runScript({
8108            .code = R"NKSP_CODE(
8109    on init
8110      exit( floor(99.0) )
8111    end on
8112    )NKSP_CODE",
8113            .expectRealExitResult = 99.0
8114        });
8115    
8116        runScript({
8117            .code = R"NKSP_CODE(
8118    on init
8119      exit( floor(99.1) )
8120    end on
8121    )NKSP_CODE",
8122            .expectRealExitResult = 99.0
8123        });
8124    
8125        runScript({
8126            .code = R"NKSP_CODE(
8127    on init
8128      exit( floor(99.9) )
8129    end on
8130    )NKSP_CODE",
8131            .expectRealExitResult = 99.0
8132        });
8133    
8134        // std unit tests ...
8135    
8136        runScript({
8137            .code = R"NKSP_CODE(
8138    on init
8139      exit( floor(2.4ms) )
8140    end on
8141    )NKSP_CODE",
8142            .expectRealExitResult = 2.0,
8143            .expectExitResultUnitPrefix = { VM_MILLI },
8144            .expectExitResultUnit = VM_SECOND
8145        });
8146    
8147        runScript({
8148            .code = R"NKSP_CODE(
8149    on init
8150      exit( floor(2.6kHz) )
8151    end on
8152    )NKSP_CODE",
8153            .expectRealExitResult = 2.0,
8154            .expectExitResultUnitPrefix = { VM_KILO },
8155            .expectExitResultUnit = VM_HERTZ
8156        });
8157    
8158        // 'final' ('!') operator tests ...
8159    
8160        runScript({
8161            .code = R"NKSP_CODE(
8162    on init
8163      exit( floor(123.1) )
8164    end on
8165    )NKSP_CODE",
8166            .expectRealExitResult = 123.0,
8167            .expectExitResultFinal = false
8168        });
8169    
8170        runScript({
8171            .code = R"NKSP_CODE(
8172    on init
8173      exit( floor(!123.8) )
8174    end on
8175    )NKSP_CODE",
8176            .expectRealExitResult = 123.0,
8177            .expectExitResultFinal = true
8178        });
8179    
8180        #if !SILENT_TEST
8181        std::cout << std::endl;
8182        #endif
8183    }
8184    
8185    static void testBuiltInSqrtFunction() {
8186        #if !SILENT_TEST
8187        std::cout << "UNIT TEST: built-in sqrt() function\n";
8188        #endif
8189    
8190        // integer tests ...
8191        // (ATM not allowed for this function)
8192    
8193        runScript({
8194            .code = R"NKSP_CODE(
8195    on init
8196      declare $foo := 1
8197      exit( sqrt($foo) )
8198    end on
8199    )NKSP_CODE",
8200            .expectParseError = true // integer not allowed for this function ATM
8201        });
8202    
8203        // real number tests ...
8204    
8205        runScript({
8206            .code = R"NKSP_CODE(
8207    on init
8208      exit( sqrt(36.0) )
8209    end on
8210    )NKSP_CODE",
8211            .expectRealExitResult = 6.0
8212        });
8213    
8214        // std unit tests ...
8215    
8216        runScript({
8217            .code = R"NKSP_CODE(
8218    on init
8219      exit( sqrt(100.0ms) )
8220    end on
8221    )NKSP_CODE",
8222            .expectRealExitResult = 10.0,
8223            .expectExitResultUnitPrefix = { VM_MILLI },
8224            .expectExitResultUnit = VM_SECOND
8225        });
8226    
8227        runScript({
8228            .code = R"NKSP_CODE(
8229    on init
8230      exit( sqrt(5.76kHz) )
8231    end on
8232    )NKSP_CODE",
8233            .expectRealExitResult = 2.4,
8234            .expectExitResultUnitPrefix = { VM_KILO },
8235            .expectExitResultUnit = VM_HERTZ
8236        });
8237    
8238        // 'final' ('!') operator tests ...
8239    
8240        runScript({
8241            .code = R"NKSP_CODE(
8242    on init
8243      exit( sqrt(25.0) )
8244    end on
8245    )NKSP_CODE",
8246            .expectRealExitResult = 5.0,
8247            .expectExitResultFinal = false
8248        });
8249    
8250        runScript({
8251            .code = R"NKSP_CODE(
8252    on init
8253      exit( sqrt(!25.0) )
8254    end on
8255    )NKSP_CODE",
8256            .expectRealExitResult = 5.0,
8257            .expectExitResultFinal = true
8258        });
8259    
8260        #if !SILENT_TEST
8261        std::cout << std::endl;
8262        #endif
8263    }
8264    
8265    static void testBuiltInLogFunction() {
8266        #if !SILENT_TEST
8267        std::cout << "UNIT TEST: built-in log() function\n";
8268        #endif
8269    
8270        // integer tests ...
8271        // (ATM not allowed for this function)
8272    
8273        runScript({
8274            .code = R"NKSP_CODE(
8275    on init
8276      declare $foo := 1
8277      exit( log($foo) )
8278    end on
8279    )NKSP_CODE",
8280            .expectParseError = true // integer not allowed for this function ATM
8281        });
8282    
8283        // real number tests ...
8284    
8285        runScript({
8286            .code = R"NKSP_CODE(
8287    on init
8288      exit( log(1.0) )
8289    end on
8290    )NKSP_CODE",
8291            .expectRealExitResult = 0.0
8292        });
8293    
8294        runScript({
8295            .code = R"NKSP_CODE(
8296    on init
8297      exit( log(~NI_MATH_E) )
8298    end on
8299    )NKSP_CODE",
8300            .expectRealExitResult = 1.0
8301        });
8302    
8303        // std unit tests ...
8304    
8305        runScript({
8306            .code = R"NKSP_CODE(
8307    on init
8308      exit( log(~NI_MATH_E * 1.0ms) )
8309    end on
8310    )NKSP_CODE",
8311            .expectRealExitResult = 1.0,
8312            .expectExitResultUnitPrefix = { VM_MILLI },
8313            .expectExitResultUnit = VM_SECOND
8314        });
8315    
8316        runScript({
8317            .code = R"NKSP_CODE(
8318    on init
8319      exit( log(~NI_MATH_E * 1.0kHz) )
8320    end on
8321    )NKSP_CODE",
8322            .expectRealExitResult = 1.0,
8323            .expectExitResultUnitPrefix = { VM_KILO },
8324            .expectExitResultUnit = VM_HERTZ
8325        });
8326    
8327        // 'final' ('!') operator tests ...
8328    
8329        runScript({
8330            .code = R"NKSP_CODE(
8331    on init
8332      exit( log(~NI_MATH_E * 1.0) )
8333    end on
8334    )NKSP_CODE",
8335            .expectRealExitResult = 1.0,
8336            .expectExitResultFinal = false
8337        });
8338    
8339        runScript({
8340            .code = R"NKSP_CODE(
8341    on init
8342      exit( log(!(~NI_MATH_E * 1.0)) )
8343    end on
8344    )NKSP_CODE",
8345            .expectRealExitResult = 1.0,
8346            .expectExitResultFinal = true
8347        });
8348    
8349        #if !SILENT_TEST
8350        std::cout << std::endl;
8351        #endif
8352    }
8353    
8354    static void testBuiltInLog2Function() {
8355        #if !SILENT_TEST
8356        std::cout << "UNIT TEST: built-in log2() function\n";
8357        #endif
8358    
8359        // integer tests ...
8360        // (ATM not allowed for this function)
8361    
8362        runScript({
8363            .code = R"NKSP_CODE(
8364    on init
8365      declare $foo := 1
8366      exit( log2($foo) )
8367    end on
8368    )NKSP_CODE",
8369            .expectParseError = true // integer not allowed for this function ATM
8370        });
8371    
8372        // real number tests ...
8373    
8374        runScript({
8375            .code = R"NKSP_CODE(
8376    on init
8377      exit( log2(1.0) )
8378    end on
8379    )NKSP_CODE",
8380            .expectRealExitResult = 0.0
8381        });
8382    
8383        runScript({
8384            .code = R"NKSP_CODE(
8385    on init
8386      exit( log2(32.0) )
8387    end on
8388    )NKSP_CODE",
8389            .expectRealExitResult = 5.0
8390        });
8391    
8392        // std unit tests ...
8393    
8394        runScript({
8395            .code = R"NKSP_CODE(
8396    on init
8397      exit( log2(32.0ms) )
8398    end on
8399    )NKSP_CODE",
8400            .expectRealExitResult = 5.0,
8401            .expectExitResultUnitPrefix = { VM_MILLI },
8402            .expectExitResultUnit = VM_SECOND
8403        });
8404    
8405        runScript({
8406            .code = R"NKSP_CODE(
8407    on init
8408      exit( log2(32.0kHz) )
8409    end on
8410    )NKSP_CODE",
8411            .expectRealExitResult = 5.0,
8412            .expectExitResultUnitPrefix = { VM_KILO },
8413            .expectExitResultUnit = VM_HERTZ
8414        });
8415    
8416        // 'final' ('!') operator tests ...
8417    
8418        runScript({
8419            .code = R"NKSP_CODE(
8420    on init
8421      exit( log2(32.0) )
8422    end on
8423    )NKSP_CODE",
8424            .expectRealExitResult = 5.0,
8425            .expectExitResultFinal = false
8426        });
8427    
8428        runScript({
8429            .code = R"NKSP_CODE(
8430    on init
8431      exit( log2(!32.0) )
8432    end on
8433    )NKSP_CODE",
8434            .expectRealExitResult = 5.0,
8435            .expectExitResultFinal = true
8436        });
8437    
8438        #if !SILENT_TEST
8439        std::cout << std::endl;
8440        #endif
8441    }
8442    
8443    static void testBuiltInLog10Function() {
8444        #if !SILENT_TEST
8445        std::cout << "UNIT TEST: built-in log10() function\n";
8446        #endif
8447    
8448        // integer tests ...
8449        // (ATM not allowed for this function)
8450    
8451        runScript({
8452            .code = R"NKSP_CODE(
8453    on init
8454      declare $foo := 1
8455      exit( log10($foo) )
8456    end on
8457    )NKSP_CODE",
8458            .expectParseError = true // integer not allowed for this function ATM
8459        });
8460    
8461        // real number tests ...
8462    
8463        runScript({
8464            .code = R"NKSP_CODE(
8465    on init
8466      exit( log10(1000.0) )
8467    end on
8468    )NKSP_CODE",
8469            .expectRealExitResult = 3.0
8470        });
8471    
8472        runScript({
8473            .code = R"NKSP_CODE(
8474    on init
8475      exit( log10(1000.0) )
8476    end on
8477    )NKSP_CODE",
8478            .expectRealExitResult = 3.0
8479        });
8480    
8481        // std unit tests ...
8482    
8483        runScript({
8484            .code = R"NKSP_CODE(
8485    on init
8486      exit( log10(1000.0ms) )
8487    end on
8488    )NKSP_CODE",
8489            .expectRealExitResult = 3.0,
8490            .expectExitResultUnitPrefix = { VM_MILLI },
8491            .expectExitResultUnit = VM_SECOND
8492        });
8493    
8494        runScript({
8495            .code = R"NKSP_CODE(
8496    on init
8497      exit( log10(1000.0kHz) )
8498    end on
8499    )NKSP_CODE",
8500            .expectRealExitResult = 3.0,
8501            .expectExitResultUnitPrefix = { VM_KILO },
8502            .expectExitResultUnit = VM_HERTZ
8503        });
8504    
8505        // 'final' ('!') operator tests ...
8506    
8507        runScript({
8508            .code = R"NKSP_CODE(
8509    on init
8510      exit( log10(1000.0) )
8511    end on
8512    )NKSP_CODE",
8513            .expectRealExitResult = 3.0,
8514            .expectExitResultFinal = false
8515        });
8516    
8517        runScript({
8518            .code = R"NKSP_CODE(
8519    on init
8520      exit( log10(!1000.0) )
8521    end on
8522    )NKSP_CODE",
8523            .expectRealExitResult = 3.0,
8524            .expectExitResultFinal = true
8525        });
8526    
8527        #if !SILENT_TEST
8528        std::cout << std::endl;
8529        #endif
8530    }
8531    
8532    static void testBuiltInExpFunction() {
8533        #if !SILENT_TEST
8534        std::cout << "UNIT TEST: built-in exp() function\n";
8535        #endif
8536    
8537        // integer tests ...
8538        // (ATM not allowed for this function)
8539    
8540        runScript({
8541            .code = R"NKSP_CODE(
8542    on init
8543      declare $foo := 1
8544      exit( exp($foo) )
8545    end on
8546    )NKSP_CODE",
8547            .expectParseError = true // integer not allowed for this function ATM
8548        });
8549    
8550        // real number tests ...
8551    
8552        runScript({
8553            .code = R"NKSP_CODE(
8554    on init
8555      exit( exp(0.0) )
8556    end on
8557    )NKSP_CODE",
8558            .expectRealExitResult = 1.0
8559        });
8560    
8561        runScript({
8562            .code = R"NKSP_CODE(
8563    on init
8564      exit( exp(1.0) )
8565    end on
8566    )NKSP_CODE",
8567            .expectRealExitResult = M_E
8568        });
8569    
8570        // std unit tests ...
8571    
8572        runScript({
8573            .code = R"NKSP_CODE(
8574    on init
8575      exit( exp(0.0ms) )
8576    end on
8577    )NKSP_CODE",
8578            .expectRealExitResult = 1.0,
8579            .expectExitResultUnitPrefix = { VM_MILLI },
8580            .expectExitResultUnit = VM_SECOND
8581        });
8582    
8583        runScript({
8584            .code = R"NKSP_CODE(
8585    on init
8586      exit( exp(0.0kHz) )
8587    end on
8588    )NKSP_CODE",
8589            .expectRealExitResult = 1.0,
8590            .expectExitResultUnitPrefix = { VM_KILO },
8591            .expectExitResultUnit = VM_HERTZ
8592        });
8593    
8594        // 'final' ('!') operator tests ...
8595    
8596        runScript({
8597            .code = R"NKSP_CODE(
8598    on init
8599      exit( exp(0.0) )
8600    end on
8601    )NKSP_CODE",
8602            .expectRealExitResult = 1.0,
8603            .expectExitResultFinal = false
8604        });
8605    
8606        runScript({
8607            .code = R"NKSP_CODE(
8608    on init
8609      exit( exp(!0.0) )
8610    end on
8611    )NKSP_CODE",
8612            .expectRealExitResult = 1.0,
8613            .expectExitResultFinal = true
8614        });
8615    
8616        #if !SILENT_TEST
8617        std::cout << std::endl;
8618        #endif
8619    }
8620    
8621    static void testBuiltInPowFunction() {
8622        #if !SILENT_TEST
8623        std::cout << "UNIT TEST: built-in pow() function\n";
8624        #endif
8625    
8626        // integer tests ...
8627        // (ATM not allowed for this function)
8628    
8629        runScript({
8630            .code = R"NKSP_CODE(
8631    on init
8632      declare $foo := 1
8633      exit( pow($foo,$foo) )
8634    end on
8635    )NKSP_CODE",
8636            .expectParseError = true // integer not allowed for this function ATM
8637        });
8638    
8639        // real number tests ...
8640    
8641        runScript({
8642            .code = R"NKSP_CODE(
8643    on init
8644      exit( pow(1.0) )
8645    end on
8646    )NKSP_CODE",
8647            .expectParseError = true // because pow() requires exactly 2 arguments
8648        });
8649    
8650        runScript({
8651            .code = R"NKSP_CODE(
8652    on init
8653      exit( pow(3.0,4.0) )
8654    end on
8655    )NKSP_CODE",
8656            .expectRealExitResult = 81.0
8657        });
8658    
8659        // std unit tests ...
8660    
8661        runScript({
8662            .code = R"NKSP_CODE(
8663    on init
8664      exit( pow(3.0ms,4.0ms) )
8665    end on
8666    )NKSP_CODE",
8667            .expectParseError = true // because units are prohibited for 2nd argument
8668        });
8669    
8670        runScript({
8671            .code = R"NKSP_CODE(
8672    on init
8673      exit( pow(3.0,4.0ms) )
8674    end on
8675    )NKSP_CODE",
8676            .expectParseError = true // because units are prohibited for 2nd argument
8677        });
8678    
8679        runScript({
8680            .code = R"NKSP_CODE(
8681    on init
8682      exit( pow(3.0ms,4.0) )
8683    end on
8684    )NKSP_CODE",
8685            .expectRealExitResult = 81.0,
8686            .expectExitResultUnitPrefix = { VM_MILLI },
8687            .expectExitResultUnit = VM_SECOND
8688        });
8689    
8690        runScript({
8691            .code = R"NKSP_CODE(
8692    on init
8693      exit( pow(3.0kHz,4.0) )
8694    end on
8695    )NKSP_CODE",
8696            .expectRealExitResult = 81.0,
8697            .expectExitResultUnitPrefix = { VM_KILO },
8698            .expectExitResultUnit = VM_HERTZ
8699        });
8700    
8701        // 'final' ('!') operator tests ...
8702    
8703        runScript({
8704            .code = R"NKSP_CODE(
8705    on init
8706      exit( pow(3.0,4.0) )
8707    end on
8708    )NKSP_CODE",
8709            .expectRealExitResult = 81.0,
8710            .expectExitResultFinal = false
8711        });
8712    
8713        runScript({
8714            .code = R"NKSP_CODE(
8715    on init
8716      exit( pow(!3.0,4.0) )
8717    end on
8718    )NKSP_CODE",
8719            .expectRealExitResult = 81.0,
8720            .expectExitResultFinal = true
8721        });
8722    
8723        runScript({
8724            .code = R"NKSP_CODE(
8725    on init
8726      exit( pow(3.0,!4.0) )
8727    end on
8728    )NKSP_CODE",
8729            .expectParseError = true // because 'final' is meaningless for 2nd argument
8730        });
8731    
8732        #if !SILENT_TEST
8733        std::cout << std::endl;
8734        #endif
8735    }
8736    
8737    static void testBuiltInSinFunction() {
8738        #if !SILENT_TEST
8739        std::cout << "UNIT TEST: built-in sin() function\n";
8740        #endif
8741    
8742        // integer tests ...
8743        // (ATM not allowed for this function)
8744    
8745        runScript({
8746            .code = R"NKSP_CODE(
8747    on init
8748      declare $foo := 1
8749      exit( sin($foo) )
8750    end on
8751    )NKSP_CODE",
8752            .expectParseError = true // integer not allowed for this function ATM
8753        });
8754    
8755        // real number tests ...
8756    
8757        runScript({
8758            .code = R"NKSP_CODE(
8759    on init
8760      exit( sin(0.0) )
8761    end on
8762    )NKSP_CODE",
8763            .expectRealExitResult = 0.0
8764        });
8765    
8766        runScript({
8767            .code = R"NKSP_CODE(
8768    on init
8769      exit( sin(0.5 * ~NI_MATH_PI) )
8770    end on
8771    )NKSP_CODE",
8772            .expectRealExitResult = 1.0
8773        });
8774    
8775        runScript({
8776            .code = R"NKSP_CODE(
8777    on init
8778      exit( sin(~NI_MATH_PI) )
8779    end on
8780    )NKSP_CODE",
8781            .expectRealExitResult = 0.0
8782        });
8783    
8784        runScript({
8785            .code = R"NKSP_CODE(
8786    on init
8787      exit( sin(1.5 * ~NI_MATH_PI) )
8788    end on
8789    )NKSP_CODE",
8790            .expectRealExitResult = -1.0
8791        });
8792    
8793        // std unit tests ...
8794    
8795        runScript({
8796            .code = R"NKSP_CODE(
8797    on init
8798      exit( sin(0.0ms) )
8799    end on
8800    )NKSP_CODE",
8801            .expectRealExitResult = 0.0,
8802            .expectExitResultUnitPrefix = { VM_MILLI },
8803            .expectExitResultUnit = VM_SECOND
8804        });
8805    
8806        runScript({
8807            .code = R"NKSP_CODE(
8808    on init
8809      exit( sin(0.0kHz) )
8810    end on
8811    )NKSP_CODE",
8812            .expectRealExitResult = 0.0,
8813            .expectExitResultUnitPrefix = { VM_KILO },
8814            .expectExitResultUnit = VM_HERTZ
8815        });
8816    
8817        // 'final' ('!') operator tests ...
8818    
8819        runScript({
8820            .code = R"NKSP_CODE(
8821    on init
8822      exit( sin(0.0) )
8823    end on
8824    )NKSP_CODE",
8825            .expectRealExitResult = 0.0,
8826            .expectExitResultFinal = false
8827        });
8828    
8829        runScript({
8830            .code = R"NKSP_CODE(
8831    on init
8832      exit( sin(!0.0) )
8833    end on
8834    )NKSP_CODE",
8835            .expectRealExitResult = 0.0,
8836            .expectExitResultFinal = true
8837        });
8838    
8839        #if !SILENT_TEST
8840        std::cout << std::endl;
8841        #endif
8842    }
8843    
8844    static void testBuiltInCosFunction() {
8845        #if !SILENT_TEST
8846        std::cout << "UNIT TEST: built-in cos() function\n";
8847        #endif
8848    
8849        // integer tests ...
8850        // (ATM not allowed for this function)
8851    
8852        runScript({
8853            .code = R"NKSP_CODE(
8854    on init
8855      declare $foo := 1
8856      exit( cos($foo) )
8857    end on
8858    )NKSP_CODE",
8859            .expectParseError = true // integer not allowed for this function ATM
8860        });
8861    
8862        // real number tests ...
8863    
8864        runScript({
8865            .code = R"NKSP_CODE(
8866    on init
8867      exit( cos(0.0) )
8868    end on
8869    )NKSP_CODE",
8870            .expectRealExitResult = 1.0
8871        });
8872    
8873        runScript({
8874            .code = R"NKSP_CODE(
8875    on init
8876      exit( cos(0.5 * ~NI_MATH_PI) )
8877    end on
8878    )NKSP_CODE",
8879            .expectRealExitResult = 0.0
8880        });
8881    
8882        runScript({
8883            .code = R"NKSP_CODE(
8884    on init
8885      exit( cos(~NI_MATH_PI) )
8886    end on
8887    )NKSP_CODE",
8888            .expectRealExitResult = -1.0
8889        });
8890    
8891        runScript({
8892            .code = R"NKSP_CODE(
8893    on init
8894      exit( cos(1.5 * ~NI_MATH_PI) )
8895    end on
8896    )NKSP_CODE",
8897            .expectRealExitResult = 0.0
8898        });
8899    
8900        // std unit tests ...
8901    
8902        runScript({
8903            .code = R"NKSP_CODE(
8904    on init
8905      exit( cos(0.0ms) )
8906    end on
8907    )NKSP_CODE",
8908            .expectRealExitResult = 1.0,
8909            .expectExitResultUnitPrefix = { VM_MILLI },
8910            .expectExitResultUnit = VM_SECOND
8911        });
8912    
8913        runScript({
8914            .code = R"NKSP_CODE(
8915    on init
8916      exit( cos(0.0kHz) )
8917    end on
8918    )NKSP_CODE",
8919            .expectRealExitResult = 1.0,
8920            .expectExitResultUnitPrefix = { VM_KILO },
8921            .expectExitResultUnit = VM_HERTZ
8922        });
8923    
8924        // 'final' ('!') operator tests ...
8925    
8926        runScript({
8927            .code = R"NKSP_CODE(
8928    on init
8929      exit( cos(0.0) )
8930    end on
8931    )NKSP_CODE",
8932            .expectRealExitResult = 1.0,
8933            .expectExitResultFinal = false
8934        });
8935    
8936        runScript({
8937            .code = R"NKSP_CODE(
8938    on init
8939      exit( cos(!0.0) )
8940    end on
8941    )NKSP_CODE",
8942            .expectRealExitResult = 1.0,
8943            .expectExitResultFinal = true
8944        });
8945    
8946        #if !SILENT_TEST
8947        std::cout << std::endl;
8948        #endif
8949    }
8950    
8951    static void testBuiltInTanFunction() {
8952        #if !SILENT_TEST
8953        std::cout << "UNIT TEST: built-in tan() function\n";
8954        #endif
8955    
8956        // integer tests ...
8957        // (ATM not allowed for this function)
8958    
8959        runScript({
8960            .code = R"NKSP_CODE(
8961    on init
8962      declare $foo := 1
8963      exit( tan($foo) )
8964    end on
8965    )NKSP_CODE",
8966            .expectParseError = true // integer not allowed for this function ATM
8967        });
8968    
8969        // real number tests ...
8970    
8971        runScript({
8972            .code = R"NKSP_CODE(
8973    on init
8974      exit( tan(0.0) )
8975    end on
8976    )NKSP_CODE",
8977            .expectRealExitResult = 0.0
8978        });
8979    
8980        runScript({
8981            .code = R"NKSP_CODE(
8982    on init
8983      exit( tan(0.25 * ~NI_MATH_PI) )
8984    end on
8985    )NKSP_CODE",
8986            .expectRealExitResult = 1.0
8987        });
8988    
8989        // std unit tests ...
8990    
8991        runScript({
8992            .code = R"NKSP_CODE(
8993    on init
8994      exit( tan(0.0ms) )
8995    end on
8996    )NKSP_CODE",
8997            .expectRealExitResult = 0.0,
8998            .expectExitResultUnitPrefix = { VM_MILLI },
8999            .expectExitResultUnit = VM_SECOND
9000        });
9001    
9002        runScript({
9003            .code = R"NKSP_CODE(
9004    on init
9005      exit( tan(0.0kHz) )
9006    end on
9007    )NKSP_CODE",
9008            .expectRealExitResult = 0.0,
9009            .expectExitResultUnitPrefix = { VM_KILO },
9010            .expectExitResultUnit = VM_HERTZ
9011        });
9012    
9013        // 'final' ('!') operator tests ...
9014    
9015        runScript({
9016            .code = R"NKSP_CODE(
9017    on init
9018      exit( tan(0.0) )
9019    end on
9020    )NKSP_CODE",
9021            .expectRealExitResult = 0.0,
9022            .expectExitResultFinal = false
9023        });
9024    
9025        runScript({
9026            .code = R"NKSP_CODE(
9027    on init
9028      exit( tan(!0.0) )
9029    end on
9030    )NKSP_CODE",
9031            .expectRealExitResult = 0.0,
9032            .expectExitResultFinal = true
9033        });
9034    
9035        #if !SILENT_TEST
9036        std::cout << std::endl;
9037        #endif
9038    }
9039    
9040    static void testBuiltInAsinFunction() {
9041        #if !SILENT_TEST
9042        std::cout << "UNIT TEST: built-in asin() function\n";
9043        #endif
9044    
9045        // integer tests ...
9046        // (ATM not allowed for this function)
9047    
9048        runScript({
9049            .code = R"NKSP_CODE(
9050    on init
9051      declare $foo := 1
9052      exit( asin($foo) )
9053    end on
9054    )NKSP_CODE",
9055            .expectParseError = true // integer not allowed for this function ATM
9056        });
9057    
9058        // real number tests ...
9059    
9060        runScript({
9061            .code = R"NKSP_CODE(
9062    on init
9063      exit( asin(0.0) )
9064    end on
9065    )NKSP_CODE",
9066            .expectRealExitResult = 0.0
9067        });
9068    
9069        runScript({
9070            .code = R"NKSP_CODE(
9071    on init
9072      exit( asin(1.0) )
9073    end on
9074    )NKSP_CODE",
9075            .expectRealExitResult = 0.5 * M_PI
9076        });
9077    
9078        runScript({
9079            .code = R"NKSP_CODE(
9080    on init
9081      exit( asin(-1.0) )
9082    end on
9083    )NKSP_CODE",
9084            .expectRealExitResult = -0.5 * M_PI
9085        });
9086    
9087        // std unit tests ...
9088    
9089        runScript({
9090            .code = R"NKSP_CODE(
9091    on init
9092      exit( asin(0.0ms) )
9093    end on
9094    )NKSP_CODE",
9095            .expectRealExitResult = 0.0,
9096            .expectExitResultUnitPrefix = { VM_MILLI },
9097            .expectExitResultUnit = VM_SECOND
9098        });
9099    
9100        runScript({
9101            .code = R"NKSP_CODE(
9102    on init
9103      exit( asin(0.0kHz) )
9104    end on
9105    )NKSP_CODE",
9106            .expectRealExitResult = 0.0,
9107            .expectExitResultUnitPrefix = { VM_KILO },
9108            .expectExitResultUnit = VM_HERTZ
9109        });
9110    
9111        // 'final' ('!') operator tests ...
9112    
9113        runScript({
9114            .code = R"NKSP_CODE(
9115    on init
9116      exit( asin(0.0) )
9117    end on
9118    )NKSP_CODE",
9119            .expectRealExitResult = 0.0,
9120            .expectExitResultFinal = false
9121        });
9122    
9123        runScript({
9124            .code = R"NKSP_CODE(
9125    on init
9126      exit( asin(!0.0) )
9127    end on
9128    )NKSP_CODE",
9129            .expectRealExitResult = 0.0,
9130            .expectExitResultFinal = true
9131        });
9132    
9133        #if !SILENT_TEST
9134        std::cout << std::endl;
9135        #endif
9136    }
9137    
9138    static void testBuiltInAcosFunction() {
9139        #if !SILENT_TEST
9140        std::cout << "UNIT TEST: built-in acos() function\n";
9141        #endif
9142    
9143        // integer tests ...
9144        // (ATM not allowed for this function)
9145    
9146        runScript({
9147            .code = R"NKSP_CODE(
9148    on init
9149      declare $foo := 1
9150      exit( acos($foo) )
9151    end on
9152    )NKSP_CODE",
9153            .expectParseError = true // integer not allowed for this function ATM
9154        });
9155    
9156        // real number tests ...
9157    
9158        runScript({
9159            .code = R"NKSP_CODE(
9160    on init
9161      exit( acos(1.0) )
9162    end on
9163    )NKSP_CODE",
9164            .expectRealExitResult = 0.0
9165        });
9166    
9167        runScript({
9168            .code = R"NKSP_CODE(
9169    on init
9170      exit( acos(0.0) )
9171    end on
9172    )NKSP_CODE",
9173            .expectRealExitResult = 0.5 * M_PI
9174        });
9175    
9176        runScript({
9177            .code = R"NKSP_CODE(
9178    on init
9179      exit( acos(-1.0) )
9180    end on
9181    )NKSP_CODE",
9182            .expectRealExitResult = M_PI
9183        });
9184    
9185        // std unit tests ...
9186    
9187        runScript({
9188            .code = R"NKSP_CODE(
9189    on init
9190      exit( acos(1.0ms) )
9191    end on
9192    )NKSP_CODE",
9193            .expectRealExitResult = 0.0,
9194            .expectExitResultUnitPrefix = { VM_MILLI },
9195            .expectExitResultUnit = VM_SECOND
9196        });
9197    
9198        runScript({
9199            .code = R"NKSP_CODE(
9200    on init
9201      exit( acos(1.0kHz) )
9202    end on
9203    )NKSP_CODE",
9204            .expectRealExitResult = 0.0,
9205            .expectExitResultUnitPrefix = { VM_KILO },
9206            .expectExitResultUnit = VM_HERTZ
9207        });
9208    
9209        // 'final' ('!') operator tests ...
9210    
9211        runScript({
9212            .code = R"NKSP_CODE(
9213    on init
9214      exit( acos(1.0) )
9215    end on
9216    )NKSP_CODE",
9217            .expectRealExitResult = 0.0,
9218            .expectExitResultFinal = false
9219        });
9220    
9221        runScript({
9222            .code = R"NKSP_CODE(
9223    on init
9224      exit( acos(!1.0) )
9225    end on
9226    )NKSP_CODE",
9227            .expectRealExitResult = 0.0,
9228            .expectExitResultFinal = true
9229        });
9230    
9231        #if !SILENT_TEST
9232        std::cout << std::endl;
9233        #endif
9234    }
9235    
9236    static void testBuiltInAtanFunction() {
9237        #if !SILENT_TEST
9238        std::cout << "UNIT TEST: built-in atan() function\n";
9239        #endif
9240    
9241        // integer tests ...
9242        // (ATM not allowed for this function)
9243    
9244        runScript({
9245            .code = R"NKSP_CODE(
9246    on init
9247      declare $foo := 1
9248      exit( atan($foo) )
9249    end on
9250    )NKSP_CODE",
9251            .expectParseError = true // integer not allowed for this function ATM
9252        });
9253    
9254        // real number tests ...
9255    
9256        runScript({
9257            .code = R"NKSP_CODE(
9258    on init
9259      exit( atan(0.0) )
9260    end on
9261    )NKSP_CODE",
9262            .expectRealExitResult = 0.0
9263        });
9264    
9265        runScript({
9266            .code = R"NKSP_CODE(
9267    on init
9268      exit( atan(1.0) )
9269    end on
9270    )NKSP_CODE",
9271            .expectRealExitResult = 0.25 * M_PI
9272        });
9273    
9274        // std unit tests ...
9275    
9276        runScript({
9277            .code = R"NKSP_CODE(
9278    on init
9279      exit( atan(0.0ms) )
9280    end on
9281    )NKSP_CODE",
9282            .expectRealExitResult = 0.0,
9283            .expectExitResultUnitPrefix = { VM_MILLI },
9284            .expectExitResultUnit = VM_SECOND
9285        });
9286    
9287        runScript({
9288            .code = R"NKSP_CODE(
9289    on init
9290      exit( atan(0.0kHz) )
9291    end on
9292    )NKSP_CODE",
9293            .expectRealExitResult = 0.0,
9294            .expectExitResultUnitPrefix = { VM_KILO },
9295            .expectExitResultUnit = VM_HERTZ
9296        });
9297    
9298        // 'final' ('!') operator tests ...
9299    
9300        runScript({
9301            .code = R"NKSP_CODE(
9302    on init
9303      exit( atan(0.0) )
9304    end on
9305    )NKSP_CODE",
9306            .expectRealExitResult = 0.0,
9307            .expectExitResultFinal = false
9308        });
9309    
9310        runScript({
9311            .code = R"NKSP_CODE(
9312    on init
9313      exit( atan(!0.0) )
9314    end on
9315    )NKSP_CODE",
9316            .expectRealExitResult = 0.0,
9317            .expectExitResultFinal = true
9318        });
9319    
9320        #if !SILENT_TEST
9321        std::cout << std::endl;
9322        #endif
9323    }
9324    
9325  static void testBuiltInNumElementsFunction() {  static void testBuiltInNumElementsFunction() {
9326      #if !SILENT_TEST      #if !SILENT_TEST
9327      std::cout << "UNIT TEST: built-in num_elements() function\n";      std::cout << "UNIT TEST: built-in num_elements() function\n";
# Line 8190  int main() { Line 9615  int main() {
9615      testBuiltInRealFunction();      testBuiltInRealFunction();
9616      testBuiltInRealToIntFunction();      testBuiltInRealToIntFunction();
9617      testBuiltInIntFunction();      testBuiltInIntFunction();
9618        testBuiltInRoundFunction();
9619        testBuiltInCeilFunction();
9620        testBuiltInFloorFunction();
9621        testBuiltInSqrtFunction();
9622        testBuiltInLogFunction();
9623        testBuiltInLog2Function();
9624        testBuiltInLog10Function();
9625        testBuiltInExpFunction();
9626        testBuiltInPowFunction();
9627        testBuiltInSinFunction();
9628        testBuiltInCosFunction();
9629        testBuiltInTanFunction();
9630        testBuiltInAsinFunction();
9631        testBuiltInAcosFunction();
9632        testBuiltInAtanFunction();
9633      testBuiltInArrayEqualFunction();      testBuiltInArrayEqualFunction();
9634      testBuiltInSortFunction();      testBuiltInSortFunction();
9635      testBuiltInNumElementsFunction();      testBuiltInNumElementsFunction();

Legend:
Removed from v.3589  
changed lines
  Added in v.3590

  ViewVC Help
Powered by ViewVC