Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement references #56

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions wasm-calc12/test/Test/Wasm/WasmSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,11 @@ runTestsWithInterpreter title input = it (show title) $ do
Right parsedModule -> case elaborateModule parsedModule of
Left typeErr -> error (show typeErr)
Right typedMod -> do
resp <- testModule typedMod
traverse_ (\(_, result) -> result `shouldBe` True) resp
case validateModule typedMod of
Left e -> error (show e)
Right _ -> do
resp <- testModule typedMod
traverse_ (\(_, result) -> result `shouldBe` True) resp

-- | output actual WASM files for testing
-- test them with node
Expand Down
17 changes: 5 additions & 12 deletions wasm-calc12/test/static/bigfunction.calc
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
function big(
a: Int32,
b: Int32,
c: Int32,
d: Int32,
e: Int32,
f: Int32,
g: Int32,
h: Int32
a: Int32, b: Int32, c: Int32, d: Int32, e: Int32
) -> Int32 {
if True then
2
else
{
let a: Int8 = 100;
let a: Int32 = 100;
if False then
4
a
else
if True then
6
b
else
if True then 8 else if False then 10 else 11
if True then c else if False then d else e
}
}
1 change: 1 addition & 0 deletions wasm-calc12/test/static/lambda3.calc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function useDataTypeInLambda() -> Boolean {
let fn = \(b:YesOrNo) -> YesOrNo {
case b { Yes -> No, No -> Yes }
};
fn(No);
True
}

Expand Down
25 changes: 25 additions & 0 deletions wasm-calc12/test/static/map.calc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type List<a>
= Cons(a, List(a))
| Nil

function mapList(
list: List(Int32), fn: Fn(Int32) -> Int32
) -> List(Int32) {
case list {
Cons(a, rest) -> Cons(fn(a), mapList(rest, fn)),
Nil -> Nil
}
}

function sumList(list: List(Int32)) -> Int32 {
case list { Cons(a, rest) -> a + sumList(rest), Nil -> 0 }
}

function useDataTypeInLambda() -> Boolean {
let inc = \(a:Int32) -> Int32 { a + 1};
let list: List(Int32) = Cons(1, Cons(2, Cons(3, Nil)));
sumList(mapList(list, inc)) == 9
}

test useDataTypeInLambda =
{ useDataTypeInLambda() }
2 changes: 1 addition & 1 deletion wasm-calc12/test/static/noalloc.calc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function [noglobalmutate noallocate noimports] add(

function id<a>(a: a) -> a { a}

export function test(index: Int8) -> Int8 {
export function test() -> Int8 {
let a: Box(Int8) = Box(1);
let b: Box(Int8) = Box(2);
let (Box(c), Box(d)) = (id(a), id(b));
Expand Down
Loading