use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class TestLibrary method test.
@Test()
public void test() {
Program p = TestProgram.p(sProg);
ClassB cb1Pre = (ClassB) Desugar.of(Parser.parse(null, s1)).accept(new InjectionOnCore());
cb1Pre = new programReduction.Norm().norm(p.evilPush(cb1Pre));
TOut out;
try {
out = TypeSystem.instance().type(TIn.top(Phase.Coherent, p, cb1Pre));
} catch (NotOkToStar coh) {
assert s2 == ErrorKind.LibraryNotCoherent;
return;
}
if (s2 instanceof ErrorKind) {
assert !out.isOk();
ErrorKind kind = out.toError().kind;
assert kind == s2;
} else {
assert out.isOk() : "";
ClassB cb1 = (ClassB) out.toOk().annotated;
ClassB cbExpected = s2 == sameAsFormer ? cb1Pre : (ClassB) Desugar.of(Parser.parse(null, (String) s2)).accept(new InjectionOnCore());
TestHelper.assertEqualExp(cb1, cbExpected);
}
}
use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class L42 method runSlow.
public static ErrorMessage.FinalResult runSlow(String fileName, String code) {
try {
L42.setExecutionStage(ExecutionStage.Parsing);
Expression code1 = Parser.parse(fileName, code);
assert code1 instanceof Expression.ClassB || code1 instanceof Expression.ClassReuse;
L42.setExecutionStage(ExecutionStage.CheckingWellFormedness);
auxiliaryGrammar.WellFormedness.checkAll(code1);
L42.setExecutionStage(ExecutionStage.Desugaring);
Expression code2 = Desugar.of(code1);
assert auxiliaryGrammar.WellFormedness.checkAll(code2);
ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
// L42.usedNames.addAll(CollectDeclaredVarsAndCheckNoDeclaredTwice.of(code2));
//L42.usedNames.addAll(CollectDeclaredClassNamesAndMethodNames.of(code2));
L42.setExecutionStage(ExecutionStage.MetaExecution);
//ClassB result= (ClassB)Executor.stepStar(exe,code3);
//Refresh of position identities, it is used to generate correct Java code.
code3 = (ClassB) code3.accept(new CloneVisitor() {
@Override
public ExpCore visit(ClassB cb) {
Position p = cb.getP();
cb = cb.withP(new Position(p.getFile(), p.getLine1(), p.getPos1(), p.getLine2(), p.getPos2(), p.get_next()));
return super.visit(cb);
}
});
//ClassB result= Configuration.reduction.of(code3);
ClassB result = ProgramReduction.allSteps(code3);
//System.out.println("--------------------------");
return checkFinalError(result);
} finally {
L42.setExecutionStage(ExecutionStage.None);
}
}
use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class TestTypeSystemOk method runTypeSystem.
static ClassB runTypeSystem(String scb1) {
TestHelper.configureForTest();
ClassB cb1 = (ClassB) Desugar.of(Parser.parse(null, scb1)).accept(new InjectionOnCore());
Program p = Program.emptyLibraryProgram();
return TypeSystem.instance().topTypeLib(Phase.Coherent, p.evilPush(cb1));
}
use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class TestCoherentClass method testCoherence.
@Test
public void testCoherence() {
ClassB cb1 = (ClassB) (Parser.parse(null, e).accept(new InjectionOnCore()));
Program p = Program.emptyLibraryProgram();
MethodWithType mwt = (MethodWithType) cb1.getMs().get(0);
//boolean res=Functions.coherent(p, mdf, path, mwt);
//Assert.assertEquals(res,ok);
//TODO: disabled for now
}
use of sugarVisitors.InjectionOnCore in project L42 by ElvisResearchGroup.
the class TestShortPrograms method tp.
public static void tp(String... code) {
TestHelper.configureForTest();
FinalResult res0;
try {
res0 = facade.L42.runSlow(null, TestHelper.multiLine(code));
} catch (ErrorMessage msg) {
ErrorFormatter.topFormatErrorMessage(msg);
throw msg;
}
ClassB res = res0.getTopLevelProgram();
ClassB.NestedClass nc = (ClassB.NestedClass) res.getMs().get(res.getMs().size() - 1);
ExpCore ee2 = Desugar.of(Parser.parse(null, "{//@exitStatus\n//0\n\n}")).accept(new InjectionOnCore());
TestHelper.assertEqualExp(nc.getInner(), ee2);
}
Aggregations