9755 |
#endif |
#endif |
9756 |
} |
} |
9757 |
|
|
9758 |
|
static void testBuiltInVars() { |
9759 |
|
#if !SILENT_TEST |
9760 |
|
std::cout << "UNIT TEST: built-in variables\n"; |
9761 |
|
#endif |
9762 |
|
|
9763 |
|
runScript({ |
9764 |
|
.code = R"NKSP_CODE( |
9765 |
|
on init |
9766 |
|
exit($NKSP_PERF_TIMER) |
9767 |
|
end on |
9768 |
|
)NKSP_CODE", |
9769 |
|
.expectExitResultIsInt = true, |
9770 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9771 |
|
.expectExitResultUnit = VM_NO_UNIT |
9772 |
|
}); |
9773 |
|
|
9774 |
|
runScript({ |
9775 |
|
.code = R"NKSP_CODE( |
9776 |
|
on init |
9777 |
|
exit($NKSP_REAL_TIMER) |
9778 |
|
end on |
9779 |
|
)NKSP_CODE", |
9780 |
|
.expectExitResultIsInt = true, |
9781 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9782 |
|
.expectExitResultUnit = VM_NO_UNIT |
9783 |
|
}); |
9784 |
|
|
9785 |
|
runScript({ |
9786 |
|
.code = R"NKSP_CODE( |
9787 |
|
on init |
9788 |
|
exit($KSP_TIMER) |
9789 |
|
end on |
9790 |
|
)NKSP_CODE", |
9791 |
|
.expectExitResultIsInt = true, |
9792 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9793 |
|
.expectExitResultUnit = VM_NO_UNIT |
9794 |
|
}); |
9795 |
|
|
9796 |
|
runScript({ |
9797 |
|
.code = R"NKSP_CODE( |
9798 |
|
on init |
9799 |
|
exit(~NI_MATH_PI) |
9800 |
|
end on |
9801 |
|
)NKSP_CODE", |
9802 |
|
.expectExitResultIsReal = true, |
9803 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9804 |
|
.expectExitResultUnit = VM_NO_UNIT |
9805 |
|
}); |
9806 |
|
|
9807 |
|
runScript({ |
9808 |
|
.code = R"NKSP_CODE( |
9809 |
|
on init |
9810 |
|
exit(~NI_MATH_E) |
9811 |
|
end on |
9812 |
|
)NKSP_CODE", |
9813 |
|
.expectExitResultIsReal = true, |
9814 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9815 |
|
.expectExitResultUnit = VM_NO_UNIT |
9816 |
|
}); |
9817 |
|
|
9818 |
|
runScript({ |
9819 |
|
.code = R"NKSP_CODE( |
9820 |
|
on init |
9821 |
|
exit($NI_CB_TYPE_INIT) |
9822 |
|
end on |
9823 |
|
)NKSP_CODE", |
9824 |
|
.expectIntExitResult = VM_EVENT_HANDLER_INIT, |
9825 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9826 |
|
.expectExitResultUnit = VM_NO_UNIT |
9827 |
|
}); |
9828 |
|
|
9829 |
|
runScript({ |
9830 |
|
.code = R"NKSP_CODE( |
9831 |
|
on init |
9832 |
|
exit($NI_CB_TYPE_NOTE) |
9833 |
|
end on |
9834 |
|
)NKSP_CODE", |
9835 |
|
.expectIntExitResult = VM_EVENT_HANDLER_NOTE, |
9836 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9837 |
|
.expectExitResultUnit = VM_NO_UNIT |
9838 |
|
}); |
9839 |
|
|
9840 |
|
runScript({ |
9841 |
|
.code = R"NKSP_CODE( |
9842 |
|
on init |
9843 |
|
exit($NI_CB_TYPE_RELEASE) |
9844 |
|
end on |
9845 |
|
)NKSP_CODE", |
9846 |
|
.expectIntExitResult = VM_EVENT_HANDLER_RELEASE, |
9847 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9848 |
|
.expectExitResultUnit = VM_NO_UNIT |
9849 |
|
}); |
9850 |
|
|
9851 |
|
runScript({ |
9852 |
|
.code = R"NKSP_CODE( |
9853 |
|
on init |
9854 |
|
exit($NI_CB_TYPE_CONTROLLER) |
9855 |
|
end on |
9856 |
|
)NKSP_CODE", |
9857 |
|
.expectIntExitResult = VM_EVENT_HANDLER_CONTROLLER, |
9858 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9859 |
|
.expectExitResultUnit = VM_NO_UNIT |
9860 |
|
}); |
9861 |
|
|
9862 |
|
runScript({ |
9863 |
|
.code = R"NKSP_CODE( |
9864 |
|
on init |
9865 |
|
exit($NI_CB_TYPE_RPN) |
9866 |
|
end on |
9867 |
|
)NKSP_CODE", |
9868 |
|
.expectIntExitResult = VM_EVENT_HANDLER_RPN, |
9869 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9870 |
|
.expectExitResultUnit = VM_NO_UNIT |
9871 |
|
}); |
9872 |
|
|
9873 |
|
runScript({ |
9874 |
|
.code = R"NKSP_CODE( |
9875 |
|
on init |
9876 |
|
exit($NI_CB_TYPE_NRPN) |
9877 |
|
end on |
9878 |
|
)NKSP_CODE", |
9879 |
|
.expectIntExitResult = VM_EVENT_HANDLER_NRPN, |
9880 |
|
.expectExitResultUnitPrefix = { VM_NO_PREFIX }, |
9881 |
|
.expectExitResultUnit = VM_NO_UNIT |
9882 |
|
}); |
9883 |
|
|
9884 |
|
#if !SILENT_TEST |
9885 |
|
std::cout << std::endl; |
9886 |
|
#endif |
9887 |
|
} |
9888 |
|
|
9889 |
#if !NO_MAIN |
#if !NO_MAIN |
9890 |
|
|
9891 |
int main() { |
int main() { |
9946 |
testBuiltInSearchFunction(); |
testBuiltInSearchFunction(); |
9947 |
testIfStatement(); |
testIfStatement(); |
9948 |
testWhileStatement(); |
testWhileStatement(); |
9949 |
|
testBuiltInVars(); |
9950 |
std::cout << "\nAll tests passed successfully. :-)\n"; |
std::cout << "\nAll tests passed successfully. :-)\n"; |
9951 |
return 0; |
return 0; |
9952 |
} |
} |