Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peachpit-site committed Feb 18, 2025
1 parent e687581 commit bf2c731
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
27 changes: 0 additions & 27 deletions examples/temp.pf
Original file line number Diff line number Diff line change
@@ -1,27 +0,0 @@
newtype

Foo = struct(flerp int, glerp Spoitable)

Bar = struct(blerp int)

Zort = abstract Bar/Foo

Spoitable = interface :
spoit(x self)

def

qux(z Zort) :
z

troz(a Addable) :
a

spoit(b Bar) :
b

respoit(s Spoitable) :
s

goo(g intlike) :
g
19 changes: 19 additions & 0 deletions source/compiler/test-files/interface_test.pf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Qux = enum ZORT, TROZ, BLERP, SPONG

Fnug = clone int using +, -

Grunt = struct(flerp int, glerp Spoitable)

Derp = struct(blerp int)

Zort = abstract Derp/Grunt

Spoitable = interface :
spoit(x self)

def

foo(q Qux) -> int :
Expand All @@ -19,4 +28,14 @@ bar(q Qux) -> int :
(p Qux) + (q Qux) -> Qux :
Qux[(int(p) + int(q)) mod 4]

xuq(z Zort) :
z

troz(a Addable) :
a

spoit(b Derp) :
b

respoit(s Spoitable) :
s
5 changes: 5 additions & 0 deletions source/vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ func TestInterface(t *testing.T) {
{`ZORT in Foobarable`, `true`},
{`true in Addable`, `false`},
{`Fnug(5) in Foobarable`, `false`},
{`Grunt(1, Derp(5))`, `Grunt with (flerp::1, glerp::Derp with (blerp::5))`},
{`Derp(5) in Zort`, `true`},
{`Derp(5) in Spoitable`, `true`},
{`xuq Derp(5)`, `Derp with (blerp::5)`},
{`respoit Derp(5)`, `Derp with (blerp::5)`},
}
test_helper.RunTest(t, "interface_test.pf", tests, test_helper.TestValues)
}
Expand Down

0 comments on commit bf2c731

Please sign in to comment.