Examples of typeCheck()


Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

            "val n:MyNum = { 5 }\n" +
            "n.getValue()";

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");

    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }

  @Test
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

           "n.getValue()";
    WyvernResolver.clearFiles();
    WyvernResolver.addFile("in1", input);
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(in2), "test input");

    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
  @Test
  public void testTrivialDSL4() throws IOException, CopperParserException {
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

  public void testImport1() throws IOException, CopperParserException {
    String input =
        "import java:java.lang.Long\n" +
        "Long.create(\"45\")";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Value result = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals(((Long) ((JavaObj) result).getObj()).longValue(), 45);
  }
 
  @Test
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

        "class C\n" +
        "  def d():Long = Long.create(\"192\")\n" +
        "val k = 4\n";

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Environment out = ((Declaration)res).evalDecl(Globals.getStandardEnv());
  }

  @Test
  public void testImport2() throws IOException, CopperParserException {
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

            "c.d()\n";

    WyvernResolver.clearFiles();
    WyvernResolver.addFile("in1", input1);
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input2), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Value out = res.evaluate(Globals.getStandardEnv());
    Long finalRes = (Long)((JavaObj)out).getObj();
    Assert.assertEquals(192, (long)finalRes);
  }
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

    WyvernResolver.clearFiles();
    WyvernResolver.addFile("in1", input1);
    WyvernResolver.addFile("in2", input2);
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input3), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Value out = res.evaluate(Globals.getStandardEnv());
    int finalRes = ((IntegerConstant)out).getValue();
    Assert.assertEquals(19, (int)finalRes);
  }
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

  public void testSplice1() throws IOException, CopperParserException {
    TypedAST testAST = new Sequence(
        new ValDeclaration("x", new IntegerConstant(4), null),
        new Application(new TSLBlock(new Fn(Arrays.asList(new NameBindingImpl("x", Int.getInstance())),
            new SpliceExn(new Variable(new NameBindingImpl("x", Int.getInstance()), null)))), new IntegerConstant(9), null) );
    Type result = testAST.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Value out = testAST.evaluate(Globals.getStandardEnv());
    int finalRes = ((IntegerConstant)out).getValue();
    Assert.assertEquals(4, finalRes);
  }
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

    WyvernResolver.addFile("tokenizer", tokenizer);
    WyvernResolver.addFile("parser", parser);
    WyvernResolver.addFile("typer", typer);

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(user), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals("Int", result.toString());

    Value out = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals("IntegerConstant(13)", out.toString());
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

    WyvernResolver.clearFiles();
    WyvernResolver.addFile("parser", parser);
    WyvernResolver.addFile("supplier", supplier);

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(client), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
  }
}
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

        "";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
   
    // System.out.println(res.typecheck(Globals.getStandardEnv(), Optional.empty()));
   
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()).toString(), "TYPE()");
   
    // System.out.println(res.evaluate(Globals.getStandardEnv()).toString());
   
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "()");   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.