Package wyvern.tools.typedAST.interfaces

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


        "def foo():Int = bar()+20\n" +
            "def bar():Int\n" +
            "  9\n" +
            "foo()";
    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(29)");
  }
  @Test
  public void testClass() throws IOException, CopperParserException {
    String input =
View Full Code Here


  public void testClass() throws IOException, CopperParserException {
    String input =
        "class Hello\n" +
        "6";
    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(6)");
  }

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

        "class Hello\n" +
        "  def foo():Int = 7\n" +
        "  val bar:Int = 19\n" +
        "6";
    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(6)");
  }

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

            "  class def create():Hello = new\n" +
            "  def foo():Int = 7\n" +
            "  val bar:Int = 19\n" +
            "Hello.create().foo()";
    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(7)");
  }

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

        "  class def create():Hello = new\n" +
        "  def foo():Foo = Foo.create()\n" +
        "  val bar:Int = 19\n" +
        "Hello.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("IntegerConstant(19)", res.evaluate(Globals.getStandardEnv()).toString());
  }

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

        "class C\n" +
        "  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 {
View Full Code Here

        "    new\n" +
        "  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 {
View Full Code Here

        "    new\n" +
        "  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 {
View Full Code Here

    String input =
        "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 {
View Full Code Here

        "    new\n" +
        "  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 {
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.