module lang::flybytes::tests::DefaultParameters
rascal-0.40.17
flybytes-0.2.8
Usage
import lang::flybytes::tests::DefaultParameters;
Source code
http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/tests/DefaultParameters.rsc
Dependencies
import lang::flybytes::Syntax;
import lang::flybytes::Compiler;
function defParamClass
Class defParamClass()
Tests
test testDefParamSet
test bool testDefParamSet() {
m = loadClass(defParamClass());
// if you pass a string, you get the string back
return m.invokeStatic(methodDesc(string(), "testMethod", [string()]), [prim(string(), "bye!")]).toValue(#str) == "bye!";
}
test testDefParamUnSet
test bool testDefParamUnSet() {
m = loadClass(defParamClass());
// if you pass 'null' you get the default initializer expression for the parameter
return m.invokeStatic(methodDesc(string(), "testMethod", [string()]), [Mirror::null()]).toValue(#str) == "hello!";
}