module lang::flybytes::tests::CatchTests
rascal-0.40.17
flybytes-0.2.8
Usage
import lang::flybytes::tests::CatchTests;
Source code
http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/tests/CatchTests.rsc
Dependencies
import lang::flybytes::Syntax;
import lang::flybytes::Compiler;
import lang::flybytes::Mirror;
function catchClass
Class catchClass()
function multipleCatchClass
Class multipleCatchClass()
function finallyClass
Class finallyClass()
function finallyContinueClass
Class finallyContinueClass()
function finallyBreakClass
Class finallyBreakClass()
Tests
test testCatch
test bool testCatch() = loadClass(catchClass(), file=just(|project://flybytes/generated/CatchTest.class|))
.invokeStatic(methodDesc(boolean(), "testMethod", []), []).toValue(#bool);
test multipleTestCatch
test bool multipleTestCatch() {
m = loadClass(multipleCatchClass(), file=just(|project://flybytes/generated/MultipleCatchTest.class|));
return m.invokeStatic(methodDesc(boolean(), "testMethod", [boolean()]), [boolean(true)]).toValue(#int) == 1
&& m.invokeStatic(methodDesc(boolean(), "testMethod", [boolean()]), [boolean(false)]).toValue(#int) == 2;
}
test finallyTest
test bool finallyTest() {
m = loadClass(finallyClass(), file=just(|project://flybytes/generated/FinallyTest.class|));
return m.invokeStatic(methodDesc(boolean(), "testMethod", []), []).toValue(#int) == 3 /*should be 3 when return supported finally */;
}
test finallyContinueTest
test bool finallyContinueTest() {
m = loadClass(finallyContinueClass(), debugMode=false, file=just(|project://flybytes/generated/FinallyContinueTest.class|));
return m.invokeStatic(methodDesc(boolean(), "testMethod", []), []).toValue(#int) == 10 /*should be 3 when return supported finally */;
}
test finallyBreakTest
test bool finallyBreakTest() {
m = loadClass(finallyBreakClass(), debugMode=false, file=just(|project://flybytes/generated/FinallyBreakTest.class|));
return m.invokeStatic(methodDesc(boolean(), "testMethod", []), []).toValue(#int) == 1;
}