module lang::flybytes::tests::BranchingTests
rascal-0.40.17
flybytes-0.2.8
Usage
import lang::flybytes::tests::BranchingTests;
Source code
http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/tests/BranchingTests.rsc
Dependencies
import lang::flybytes::Compiler;
import lang::flybytes::Mirror;
import lang::flybytes::api::JavaLang;
import Node;
import util::Math;
function ifClass
Class ifClass(Exp cond)
function testIf
bool testIf(Class c, bool answer)
alias BinOp
Exp (Exp, Exp)
function ifCmpClass
Class ifCmpClass(Type t, BinOp op)
function testIf
bool testIf(Class c, Type t, str mn, Mirror lhs, Mirror rhs, bool answer)
Tests
test testIfTrue
test bool testIfTrue() = testIf(ifClass(\true()), true);
test testIfFalse
test bool testIfFalse() = testIf(ifClass(\false()), false);
test testIfMethodTrue
test bool testIfMethodTrue() = testIf(ifClass(invokeStatic(methodDesc(boolean(),"methodTrue",[]),[])), true);
test testIfMethodFalse
test bool testIfMethodFalse() = testIf(ifClass(invokeStatic(methodDesc(boolean(),"methodFalse",[]),[])), false);
test testIfEqTrue
test bool testIfEqTrue() = testIf(ifClass(eq(iconst(1),iconst(1))), true);
test testIfEqFalse
test bool testIfEqFalse() = testIf(ifClass(eq(iconst(2),iconst(1))), false);
test testIfEqBoolTrue
test bool testIfEqBoolTrue() = testIf(ifClass(eq(\true(), \true())), true);
test testIfEqBoolFalse
test bool testIfEqBoolFalse() = testIf(ifClass(eq(\true(), \false())), false);
test testEqTrue
test bool testEqTrue(int i)
= all (t <- intTypes,
I := prim(t, abs(i) % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, eq), t, cl, I, I, true));
test testEqFalse
test bool testEqFalse(int i)
= all (t <- intTypes,
I := abs(i) % maxIntValue(t), cl <- condTypes,
testIf(ifCmpClass(t, eq), t, cl, prim(t, I), prim(t, I - 1), false));
test testNEqTrue
test bool testNEqTrue(int i)
= all (t <- intTypes,
I := abs(i) % maxIntValue(t), cl <- condTypes,
testIf(ifCmpClass(t, ne), t, cl, prim(t, I), prim(t, I - 1), true));
test testNEqFalse
test bool testNEqFalse(int i)
= all (t <- intTypes,
I := prim(t, abs(i) % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, ne), t, cl, I, I, false));
test testLt
test bool testLt(int i, int j)
= all (t <- intTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, lt), t, cl, prim(t, I), prim(t, J), I < J));
test testGt
test bool testGt(int i, int j)
= all (t <- intTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, gt), t, cl, prim(t, I), prim(t, J), I > J));
test testGe
test bool testGe(int i, int j)
= all (t <- intTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, ge), t, cl, prim(t, I), prim(t, J), I >= J));
test testLe
test bool testLe(int i, int j)
= all (t <- intTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, le), t, cl, prim(t, I), prim(t, J), I <= J));