Package wyvern.tools.typedAST.interfaces

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


        "  def bar():Int\n" +
        "    9\n" +
        "5";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
 
  @Test
  public void parseClassWithNew() throws IOException, CopperParserException {
    String input =
View Full Code Here


        "  def bar():Int\n" +
        "    9\n" +
        "5";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
 
  @Test
  public void testSimpleClass() throws IOException, CopperParserException {
    String input =
View Full Code Here

        "  def bar():Int\n" +
        "    9\n" +
        "C.create().bar()";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(9)");
  }
 
  @Test
  public void parseSimpleType() throws IOException, CopperParserException {
    String input =
View Full Code Here

        "type T\n" +
        "  def bar():Int\n" +
        "5";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
 
  @Test
  public void testSimpleType() throws IOException, CopperParserException {
    String input =
View Full Code Here

        "  def bar():Int\n" +
        "    9\n" +
        "C.create().bar()";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(9)");
  }

  @Test
  public void testDSL1() throws IOException, CopperParserException {
    String input =
View Full Code Here

            "  val d = 4\n" +
            "  def x():Int = 7\n" +
            "test\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.empty());
    Assert.assertEquals("IntegerConstant(7)",res.evaluate(Globals.getStandardEnv()).toString());
  }
  @Test
  public void testNew3() throws IOException, CopperParserException {
    String input =
        "val test = (new.d.k)+9/3-3\n" +
View Full Code Here

            "    val k = 19\n" +
            "  def x():Int = 7\n" +
            "test\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.empty());
    Assert.assertEquals("IntegerConstant(19)",res.evaluate(Globals.getStandardEnv()).toString());
  }
  @Test
  public void testNew4() throws IOException, CopperParserException {
    String input =
        "val x = 3\n" +
View Full Code Here

        "val test = new\n" +
        "  val x = x\n" +
        "test.x\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.empty());
    Assert.assertEquals("IntegerConstant(3)",res.evaluate(Globals.getStandardEnv()).toString());
  }
 
  // admittedly this is only a starting point....
  @Test
  public void testTrivialDSL() throws IOException, CopperParserException {
View Full Code Here

  @Override
  public void execute() throws IOException, CopperParserException {
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(code+"\n"), "test input");
    Assert.assertEquals(expectedType, res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty()).toString());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals(expectedValue, finalV.toString());
  }
}
View Full Code Here

    }

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(main), "test input");
    Assert.assertEquals(expectedType, res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty()).toString());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals(expectedValue, finalV.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.