use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class IfThenElseStepSolverTest method test01.
@Test
public void test01() {
Expression expression = parse("if false then 2 else 3");
Context context = new TrueContext(new CommonTheory());
Expression expectedResult = parse("3");
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
runIfThenElseStepSolverTest(expression, context, expectedResult, testName);
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class IfThenElseStepSolverTest method test06.
@Test
public void test06() {
Expression expression = parse("if (X=1) or (Y=1) then 2 else 3");
String[] symbolsAndTypes = { "X", "0..1", "Y", "0..1" };
Context context = new TrueContext(new CommonTheory()).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression expectedResult = parse("if X = 1 then 2 else if Y = 1 then 2 else 3");
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
runIfThenElseStepSolverTest(expression, context, expectedResult, testName);
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class IfThenElseStepSolverTest method test09.
@Test
public void test09() {
Expression expression = parse("if (X=1) or (Y=1) then 2 else 3");
String[] symbolsAndTypes = { "X", "0..1", "Y", "1..1" };
Context context = new TrueContext(new CommonTheory()).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression expectedResult = parse("2");
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
runIfThenElseStepSolverTest(expression, context, expectedResult, testName);
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class IfThenElseStepSolverTest method test05.
@Test
public void test05() {
Expression expression = parse("if (X=1) and (Y=1) then 2 else 3");
String[] symbolsAndTypes = { "X", "0..1", "Y", "0..1" };
Context context = new TrueContext(new CommonTheory()).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression expectedResult = parse("if X = 1 then if Y = 1 then 2 else 3 else 3");
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
runIfThenElseStepSolverTest(expression, context, expectedResult, testName);
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTestSumOperandsWithFreeVariables.
@Test
public void numericGroupTestSumOperandsWithFreeVariables() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = { "K", "0..5" };
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("sum({{(on I in 3..5) if I != 4 and K != 2 then X else 1 }})"), parse("sum({{(on J in 1..5) if J != 3 then if K != 3 then J else Y else 1 }})") };
Expression[] expectedResultPerGroup = { parse("if K != 2 then if K != 3 then max(2 * X + 1, 13) else max(2 * X + 1, 4 * Y + 1) else 13"), parse("if K != 2 then if K != 3 then (2 * X + 1) * 13 else (2 * X + 1) * (4 * Y + 1) else 39"), parse("if K != 2 then if K != 3 then 2 * X + 14 else 2 * X + 4 * Y + 2 else 16") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
println();
}
Aggregations