Package wyvern.tools.typedAST.interfaces

Examples of wyvern.tools.typedAST.interfaces.TypedAST


  }
  @Test
  public void testSimple() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("2+2");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"val temp$0 = 2,val temp$1 = 2,val temp$2 = temp$0 + temp$1,temp$2");;
  }
View Full Code Here


  @Test
  public void testVal() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("val x : Int = 5\n"
        +"x");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"val x = 5,x");;
  }
View Full Code Here

  }
  @Test
  public void testLambdaCall() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("(fn x : Int => (x))(1)");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"def 0$lambda(x : Int) {x},val temp$0 = 0$lambda,val temp$1 = 1,temp$0(temp$1)");;
  }
View Full Code Here

  }
  @Test
  public void testLambdaCallWithAdd() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("(fn x : Int => (x + 1))(3)");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"def 0$lambda(x : Int) {val temp$1 = x,val temp$2 = 1,val temp$3 = temp$1 + temp$2,temp$3},val temp$0 = 0$lambda,val temp$4 = 3,temp$0(temp$4)");;
  }
View Full Code Here

  }
  @Test
  public void testArithmetic() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("3*4+5*6");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"val temp$3 = 3,val temp$4 = 4,val temp$5 = temp$3 * temp$4,val temp$6 = temp$5,val temp$0 = 5,val temp$1 = 6,val temp$2 = temp$0 * temp$1,val temp$7 = temp$2,val temp$8 = temp$6 + temp$7,temp$8");
  }
View Full Code Here

  @Test
  public void testHigherOrderTypes() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("fn f : Int -> Int => (fn x : Int => (f(f(x))))");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"def 1$lambda(f : Int -> Int) {def 0$lambda(x : Int) {val temp$0 = f,val temp$1 = f,val temp$2 = x,val temp$3 = temp$1(temp$2),temp$0(temp$3)},0$lambda},1$lambda");
  }
View Full Code Here

  @Test
  public void testTupleMethodCalls() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("def mult(n:Int,m:Int):Int = n+5*m\n"
        +"mult(3,2)\n");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"def mult(n : Int,m : Int) {val temp$3 = n,val temp$0 = 5,val temp$1 = m,val temp$2 = temp$0 * temp$1,val temp$4 = temp$2,val temp$5 = temp$3 + temp$4,temp$5},val temp$6 = mult,val temp$7 = 3,val temp$8 = 2,val temp$9 = (temp$7,temp$8),temp$6(temp$9)");
  }
View Full Code Here

        +"    \tnew\n"
        +"    val hiString : Str = \"hello\"\n"
        +"\n"
        +"val h : Hello = Hello.make()\n" //hiString: \"hi\")\n"
        +"h.hiString");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"class Hello { static {def make() {new }; def $init() {val hiString = \"hello\"}}; val hiString = \"hello\"},val temp$1 = Hello,val temp$0 = temp$1.make,val temp$3 = (),val h = temp$0(temp$3),val temp$4 = h,temp$4.hiString");
  }
View Full Code Here

        +"  def get5():Int = 5\n"
        +"  def getP():Int = this.get4()+this.get5()\n"
        +"\n"
        +"val h:Hello = Hello.make()\n"
        +"h.getP()");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"class Hello { static {def make() {new }; def $init() {}}; def get4() {4}; def get5() {5}; def getP() {val temp$5 = this,val temp$4 = temp$5.get4,val temp$7 = (),val temp$8 = temp$4(temp$7),val temp$1 = this,val temp$0 = temp$1.get5,val temp$3 = (),val temp$9 = temp$0(temp$3),val temp$10 = temp$8 + temp$9,temp$10}},val temp$12 = Hello,val temp$11 = temp$12.make,val temp$14 = (),val h = temp$11(temp$14),val temp$16 = h,val temp$15 = temp$16.getP,val temp$18 = (),temp$15(temp$18)");
  }
View Full Code Here

  @Test
  public void testVarAssignment2() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("var x:Int = 1\nx=2\nvar y:Int = 3\ny=4\nx=y\nx");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    Assert.assertEquals(join(getResult(pair)),"var x = 1,x = 2,var y = 3,y = 4,x = y,x");
  }
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.interfaces.TypedAST

Copyright © 2018 www.massapicom. 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.