Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoux committed Jul 5, 2020
1 parent a4eaa9c commit 2fdbb55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions selfhost/raw.wyv
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def expToString(e:Exp):String = match e:
t:TypeDecl => "type " + t.name + ":\n" + t.decls
t:TypeAlias => "type " + t.name + " = " + t.alias
d:DefDecl => "def " + d.name + "(" + argsToString(d.args) + ")" + d.retTyp
s:SubtypeDecl => "subtype " + s.subtype + " extends " + s.supertype
n:New => "new " + n.thisName + ":" + n.typeName + ":\n" + n.body
s:Seq => s.exps.foldRight[String]((e:Exp, s:String) => s + "\n" + expToString(e), "")
i:Integer => i.str
Expand Down
43 changes: 29 additions & 14 deletions selfhost/tests/typeTest.wyv
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@ type Int:
def +(i:Int):Int
def -(i:Int):Int

type Side:
val len:Int
type Polygon:
def perim(u:Unit):Int

type Triangle:
val s1:Side
val s2:Side
val s3:Side
val s1:Int
val s2:Int
val s3:Int
def perim(u:Unit):Int
subtype Triangle extends Polygon

val tri = new this:Triangle:
val s1 = new x:Side:
val len = 1
val s2 = new x:Side:
val len = 2
val s3 = new x:Side:
val len = 3
type Square:
val s:Int
def perim(u:Unit):Int
subtype Square extends Polygon

val perim = tri.s1.len + tri.s2.len + tri.s3.len
tri.s1.len
type A:
def makeTri(a:Int,b:Int,c:Int):Triangle

val a = new this:A:
def makeTri(a:Int,b:Int,c:Int):Triangle:
new self:Triangle:
val s1 = a
val s2 = b
val s3 = c
def perim(u:Unit):Int:
self.s1 + self.s2 + self.s3
def makeSquare(a:Int):Square:
new self:Square:
val s = a
def perim(u:Unit):Int:
self.s + self.s + self.s + self.s

a.makeTri(1,3,3).perim(())

0 comments on commit 2fdbb55

Please sign in to comment.