Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoux committed Jul 16, 2020
1 parent 52f77d9 commit 5c30c7a
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 97 deletions.
2 changes: 1 addition & 1 deletion selfhost/failtests/badsubtype2.wyv
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ type C:z:
val a:Int

subtype Unit {val a:Int} extends C
subtype Unit {val a:Int} extends A
subtype Unit {type T <= Int, val a:Int} extends B

0
38 changes: 20 additions & 18 deletions selfhost/main.wyv
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,25 @@ def parse(s:String):raw.Exp
pars.results.get(0)

stdout.print("Binding...\n")
val boundExp:types.Statement = binding.bind(parser.results.get(0), s => parse(s))
//val boundExp : exception.Answer[types.Statement,exception.Exception] = exception.try[types.Statement](() => binding.bind(parser.results.get(0), s => parse(s)))
//match boundExp:
// s1: exception.Success =>
// stdout.print("binding success\n")
// val tc:exception.Answer[types.Type,exception.Exception] = exception.try[types.Type](() => typecheck.typecheck(s1.value))
// match tc:
// s1: exception.Success =>
// stdout.print("type: " + typesUtil.typeToString(s1.value) + "\n")
// f1: exception.Failure =>
// match f1.exception:
// exn: error.ErrorReportingException => stdout.print(error.asString(exn)+"\n")
// default => stdout.print("unexpected exception thrown\n")
// f1: exception.Failure =>
// match f1.exception:
// exn: error.ErrorReportingException => stdout.print(error.asString(exn)+"\n")
// default => stdout.print("unexpected exception thrown\n")

//val boundExp:types.Statement = binding.bind(parser.results.get(0), s => parse(s))
val boundExp : exception.Answer[types.Statement,exception.Exception] = exception.try[types.Statement](() => binding.bind(parser.results.get(0), s => parse(s)))
match boundExp:
s1: exception.Success =>
stdout.print("binding success\n")
val tc:exception.Answer[types.Type,exception.Exception] = exception.try[types.Type](() => typecheck.typecheck(s1.value))
match tc:
s1: exception.Success =>
stdout.print("type: " + typesUtil.typeToString(s1.value) + "\n")
f1: exception.Failure =>
match f1.exception:
exn: error.ErrorReportingException => stdout.print(error.asString(exn)+"\n")
default => stdout.print("unexpected exception thrown\n")
f1: exception.Failure =>
match f1.exception:
exn: error.ErrorReportingException => stdout.print(error.asString(exn)+"\n")
default => stdout.print("unexpected exception thrown\n")

/*
val tc = typecheck.typecheck(boundExp)
stdout.print("type: " + typesUtil.typeToString(tc) + "\n")

Expand All @@ -93,3 +94,4 @@ stdout.print(outputFileName)
stdout.print("...\n")

toBytecode.writeExpToFile(ooExp, outputFileName)
*/
6 changes: 3 additions & 3 deletions selfhost/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ wyby main.wyv
node ../backend/boot.js main.wyb > main.js
node main.js $1

echo FINISHED PRODUCING WYB FILE FOR $1 NOW RUNNING IT
node ../backend/boot.js `echo $1 | sed 's/\.wyv/\.wyb/'` > `echo $1 | sed 's/\.wyv/\.js/'`
node `echo $1 | sed 's/\.wyv/\.js/'`
#echo FINISHED PRODUCING WYB FILE FOR $1 NOW RUNNING IT
#node ../backend/boot.js `echo $1 | sed 's/\.wyv/\.wyb/'` > `echo $1 | sed 's/\.wyv/\.js/'`
#node `echo $1 | sed 's/\.wyv/\.js/'`
16 changes: 0 additions & 16 deletions selfhost/tests/aliasTest.wyv

This file was deleted.

4 changes: 2 additions & 2 deletions selfhost/tests/arity.wyv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type A:
type A:z:
def f(x:Int):Int
def g(x:Int,y:Int,z:Int):Int

Expand Down
6 changes: 3 additions & 3 deletions selfhost/tests/counter.wyv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Counter:
type Counter:z:
val a:Int
def next(u:Unit):Counter

type X:
type X:z:
def makeCounter(b:Int):Counter

val x = new self:X:
Expand Down
6 changes: 3 additions & 3 deletions selfhost/tests/fib.wyv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Fib:
type Fib:z:
val a1:Int
val a2:Int
def next(u:Unit):Fib

type X:
type X:z:
def makeFib(x:Int,y:Int):Fib

val x = new self:X:
Expand Down
4 changes: 2 additions & 2 deletions selfhost/tests/loop.wyv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type X:
type X:z:
def f(x:Int):Int
val temp:Int

Expand Down
7 changes: 3 additions & 4 deletions selfhost/tests/newtest.wyv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Foo:
type Foo:z:
def sum(x:Int):Int
val a:Int

Expand All @@ -11,8 +11,7 @@ val foo = new this:Foo:
this.a + x
val a = 5

type Bar = Foo
val bar = new this:Bar:
val bar = new this:Foo:
def sum(x:Int):Int:
this.a + x
val a = 5
Expand Down
17 changes: 17 additions & 0 deletions selfhost/tests/pair.wyv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Pair:z:
type S <= Unit
type T <= Unit
val fst:z.S
val snd:z.T

val p1 = new this:Pair {type S = Int, type T = Unit}:
type S = Int
type T = Unit
val fst:this.S = 3
val snd:this.T = ()

p1
10 changes: 5 additions & 5 deletions selfhost/tests/subtypeTest.wyv
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Foo:
type Foo:z:
def +(i:Int):Foo
def -(i:Int):Foo
subtype Foo extends Int

type A:
type A:z:
def calc(x:Int):A
type B:
type B:z:
def calc(x:Int):B
val z:Int
subtype B extends A
subtype B extends Unit
type C:
type C:z:
def calc(x:Int):C
val z:Int
val y:B
Expand Down
6 changes: 3 additions & 3 deletions selfhost/tests/testFn.wyv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type IntToInt:
type IntToInt:z:
def f(i:Int):Int

val succ = new this:IntToInt:
def f(i:Int):Int:
i+1

type A:
type A:z:
def f(i:IntToInt):Int

val apply0 = new this:A:
Expand Down
2 changes: 1 addition & 1 deletion selfhost/tests/testInt.wyv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

Expand Down
8 changes: 4 additions & 4 deletions selfhost/tests/testShadow.wyv
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type X:
type X:z:
val a:Int

val x = new this:X:
val a = 5

type Fn:
type Fn:z:
def f(x:Int):Int

val fn = new this:Fn:
def f(b:Int):Int:
x.a + b

type X:
type X:z:
val b:Int

val y = new this:X:
Expand Down
4 changes: 2 additions & 2 deletions selfhost/tests/testVar.wyv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type A:
type A:z:
val a:Int

val x = new this:A:
Expand Down
8 changes: 4 additions & 4 deletions selfhost/tests/tree.wyv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Tree:
type Tree:z:
def sum(u:Unit):Int

type Empty:
type Empty:z:
def sum(u:Unit):Int
subtype Empty extends Tree

type Branch:
type Branch:z:
def sum(u:Unit):Int
val a:Int
val left:Tree
Expand Down
10 changes: 5 additions & 5 deletions selfhost/tests/typeTest.wyv
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
type Int:
type Int:z:
def +(i:Int):Int
def -(i:Int):Int

type Polygon:
type Polygon:z:
def perim(u:Unit):Int

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

type Square:
type Square:z:
val s:Int
def perim(u:Unit):Int
subtype Square extends Polygon

type A:
type A:z:
def makeTri(a:Int,b:Int,c:Int):Triangle

val a = new this:A:
Expand Down
Loading

0 comments on commit 5c30c7a

Please sign in to comment.