Search in sources :

Example 1 with FinalResult

use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.

the class TestL42SuperSlow method test16.

@Test
public void test16() throws IOException {
    String s = TestHelper.multiLine("", "{reuse L42.is/microBase", "NList:Collections.list(N)", "Util:{()", "  class method N max(NList that){", "    if that.isEmpty() (error S\"Empty lists have no max\")", "    var N candidate=that.top()", "    with ei in that.vals() (", "      if ei>candidate (candidate:=ei)", "      )", "    return candidate", "    }", "  }", "C:{", "  list=NList[3N;]", "  if Util.max(list)==3N (return ExitCode.normal())", "  return ExitCode.failure()", "  }", "}");
    try {
        FinalResult res = L42.runSlow(null, s);
        System.out.println(L42.record.toString());
        if (res.getResult() != 0) {
            System.out.println(res);
            TestHelper.reportError(null);
        }
    } catch (ErrorMessage msg) {
        System.out.println(L42.record.toString());
        msg.printStackTrace();
        TestHelper.reportError(msg);
    }
}
Also used : FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage) Test(org.junit.Test)

Example 2 with FinalResult

use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.

the class TestL42SuperSlow method test14.

@Test
public void test14() throws IOException {
    String s = TestHelper.multiLine("", "{reuse L42.is/microBase", "SList:Collections.list(S)", "C:{", //
    "  l1=SList[S\"a\";S\"b\";]", "  l2=SList[S\"c\";]", "  with" + //
    " s1 in l1.valsCut()" + " s2 in l2.valsCut() (", //
    "    use Alu check stringDebug(s1.that()) void", "    use Alu check stringDebug(s2.that()) void", "    )", "  return ExitCode.normal()", "  }", "}");
    try {
        FinalResult res = L42.runSlow(null, s);
        System.out.println(L42.record.toString());
        if (res.getResult() != 0) {
            System.out.println(res);
            TestHelper.reportError(null);
        }
    } catch (ErrorMessage msg) {
        System.out.println(L42.record.toString());
        msg.printStackTrace();
        TestHelper.reportError(msg);
    }
}
Also used : FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage) Test(org.junit.Test)

Example 3 with FinalResult

use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.

the class TestL42SuperSlow method test18.

@Test
public void test18() throws IOException {
    String s = TestHelper.multiLine("", "{reuse L42.is/microBase", "SList:Collections.list(S)", "Util:{()", "  class method S max(SList that){", "    if that.isEmpty() (error S\"Empty lists have no max\")", "    var S candidate=S\"\"", "    with ei in that.vals() (", "      if ei.size()>candidate.size() (candidate:=ei)", "      )", "    return candidate", "    }", "  }", "C:{", "  list=SList[S\"a\";S\"bb\";S\"ccc\";S\"dd\";]", "  if Util.max(list)!=S\"ccc\" (return ExitCode.failure())", "  top=S\"ccc\"(0N)", "  if top!=S\"c\" (return ExitCode.failure())", "  return ExitCode.normal()", "  }", "}");
    try {
        FinalResult res = L42.runSlow(null, s);
        System.out.println(L42.record.toString());
        if (res.getResult() != 0) {
            System.out.println(res);
            TestHelper.reportError(null);
        }
    } catch (ErrorMessage msg) {
        System.out.println(L42.record.toString());
        msg.printStackTrace();
        TestHelper.reportError(msg);
    }
}
Also used : FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage) Test(org.junit.Test)

Example 4 with FinalResult

use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.

the class DeploySimpleLib method testLibCreationGui.

public static void testLibCreationGui() {
    try {
        FinalResult res = L42.runSlow(null, TestHelper.multiLine("", "          {reuse L42.is/deployMini", "            Main:Deploy[S\"Top::Exported\", fileName:S\"localhost/GuiLib.L42\"]<{reuse L42.is/templateBNS", "              Top:This0::Generalize[]<{reuse L42.is/miniBase", "                Exported:{(S id)", "", "                  GuiPlugin:{'@plugin", "                    'L42.is/connected/withHtml", "                    }", "              ", "                  class method", "                  S jsEscape(S that) (", "                    tmp=that.replace(S.doubleQuote(),into:S\"\\\"++S.doubleQuote())", "                    tmp.replace(S\"\'\",into:S\"\\\'\")", "                    )", "                  method", "                  Void close()", "                    use GuiPlugin", "                      check close(wName:this.id().binaryRepr())", "                      error void", "                ", "                  method", "                  Void open(S html, N x, N y)", "                    use GuiPlugin", "                      check open(", "                        wName:this.id().binaryRepr()", "                        html:html.binaryRepr()", "                        x:x.binaryRepr()", "                        y:y.binaryRepr()", "                        )", "                      error void", "                      ", "                  method", "                  Void set(S that,S id) {", "                    cmd=S\"$(\'#\"++This0.jsEscape(id)", "                    ++S\"\').replaceWith(\'\"++This0.jsEscape(that)++S\"\');\"", "                    x=this.executeJs(cmd)", "                    Debug(cmd)", "                    if x!=S\"\" (Debug(x))", "                    return void", "                    }", "                    ", "                  method", "                  S executeJs(S that)", "                    S.#stringParser(use GuiPlugin", "                      check executeJs(wName:this.id().binaryRepr(),command:that.binaryRepr())", "                      error void)", "                ", "                  method", "                  mut Iterator events()", "                    Iterator(id: this.id(), current:S\"\")", "              ", "                  Iterator:{mut(S id, var S current)", "                  ", "                    class method S auxFetchEvent(S id) exception Void {", "                      Library s=use GuiPlugin", "                        check eventPending(wName:id.binaryRepr())", "                        exception void", "                      catch error x (on Library exception void)", "                      return S.#stringParser(s)", "                      }", "                      ", "                    mut method", "                    Void #next() exception Void {", "                      s=Iterator.auxFetchEvent(id:this.id())", "                      return this.current(s)", "                      }", "                      ", "                    read method", "                    Void #checkEnd() void", "                    ", "                    read method", "                    S #inner() (this.current())", "", "                    read method", "                    Void #close() void", "                    }", "            '----------------------", "                  }", "                }", "              }", "            }"));
        System.out.println("------------------------------");
        System.out.println("END: " + res.getErrCode());
    } catch (ErrorMessage msg) {
        //System.out.println(L42.record.toString());
        msg.printStackTrace();
        //Executor.reportError(msg);
        System.out.println(ErrorFormatter.formatError(Program.empty(), msg).getErrorTxt());
    }
}
Also used : FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage)

Example 5 with FinalResult

use of ast.ErrorMessage.FinalResult in project L42 by ElvisResearchGroup.

the class DeploySimpleLib method testLibCreation.

public static void testLibCreation() {
    try {
        FinalResult res = L42.runSlow(null, TestHelper.multiLine("", "          {reuse L42.is/deployMini", "            Main:Deploy[S\"Top\", fileName:S\"localhost/SimpleLib.L42\"]<{reuse L42.is/templateBNS", "              Top:Generalize[]<{reuse L42.is/miniBase", "                Exported:{", "                  class method Void printHelloWorld()", "                    Debug(S\"Hello World \"++42N)", "                  }", "                }", "              }", "            }"));
        System.out.println("------------------------------");
        System.out.println("END: " + res.getErrCode());
    } catch (ErrorMessage msg) {
        //System.out.println(L42.record.toString());
        msg.printStackTrace();
        //Executor.reportError(msg);
        System.out.println(ErrorFormatter.formatError(Program.empty(), msg).getErrorTxt());
    }
}
Also used : FinalResult(ast.ErrorMessage.FinalResult) ErrorMessage(ast.ErrorMessage)

Aggregations

ErrorMessage (ast.ErrorMessage)12 FinalResult (ast.ErrorMessage.FinalResult)12 Test (org.junit.Test)5 Path (java.nio.file.Path)2 ExpCore (ast.ExpCore)1 ClassB (ast.ExpCore.ClassB)1 ParseCancellationException (org.antlr.v4.runtime.misc.ParseCancellationException)1 InjectionOnCore (sugarVisitors.InjectionOnCore)1