Migrate even more tests

This commit is contained in:
Ayaz Hafiz 2023-04-12 18:26:51 -05:00
parent 7c14b78e5d
commit 721d3836cd
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
50 changed files with 559 additions and 900 deletions

View file

@ -0,0 +1,9 @@
app "test" provides [hash] to "./platform"
MHash has
hash : a -> U64 | a has MHash
Id := U64 has [MHash {hash}]
hash : Id -> U64
#^^^^{-1} Id#hash(3): Id -[[hash(3)]]-> U64

View file

@ -0,0 +1,10 @@
app "test" provides [hash] to "./platform"
MHash has
hash : a -> U64 | a has MHash
Id := U64 has [MHash {hash}]
hash : Id -> U64
hash = \@Id n -> n
#^^^^{-1} Id#hash(3): Id -[[hash(3)]]-> U64

View file

@ -0,0 +1,8 @@
app "test" provides [hashEq] to "./platform"
MHash has
hash : a -> U64 | a has MHash
hashEq : a, a -> Bool | a has MHash
hashEq = \x, y -> hash x == hash y
#^^^^^^{-1} a, a -[[hashEq(0)]]-> Bool | a has MHash

View file

@ -0,0 +1,7 @@
app "test" provides [hashEq] to "./platform"
MHash has
hash : a -> U64 | a has MHash
hashEq = \x, y -> hash x == hash y
#^^^^^^{-1} a, a1 -[[hashEq(0)]]-> Bool | a has MHash, a1 has MHash

View file

@ -0,0 +1,12 @@
app "test" provides [result] to "./platform"
MHash has
hash : a -> U64 | a has MHash
hashEq = \x, y -> hash x == hash y
Id := U64 has [MHash {hash}]
hash = \@Id n -> n
result = hashEq (@Id 100) (@Id 101)
#^^^^^^{-1} Bool

View file

@ -0,0 +1,15 @@
app "test" provides [result] to "./platform"
MHash has
hash : a -> U64 | a has MHash
mulMHashes = \x, y -> hash x * hash y
Id := U64 has [MHash { hash: hashId }]
hashId = \@Id n -> n
Three := {} has [MHash { hash: hashThree }]
hashThree = \@Three _ -> 3
result = mulMHashes (@Id 100) (@Three {})
#^^^^^^{-1} U64

View file

@ -0,0 +1,11 @@
app "test" provides [zero] to "./platform"
MHash has
hash : a -> U64 | a has MHash
Id := U64 has [MHash {hash}]
hash = \@Id n -> n
zero = hash (@Id 0)
#^^^^{-1} U64

View file

@ -0,0 +1,9 @@
app "test" provides [thething] to "./platform"
MHash has
hash : a -> U64 | a has MHash
thething =
#^^^^^^^^{-1} a -[[] + a:hash(2):1]-> U64 | a has MHash
itis = hash
itis

View file

@ -0,0 +1,8 @@
app "test" provides [foo] to "./platform"
MyError : [Error]
MyResult := Result U8 MyError
foo = @MyResult (Err Error)
#^^^{-1} MyResult

View file

@ -0,0 +1,8 @@
app "test" provides [zeroEncoder] to "./platform"
MEncoder fmt := List U8, fmt -> List U8 | fmt has Format
Format has it : fmt -> {} | fmt has Format
zeroEncoder = @MEncoder \lst, _ -> lst
#^^^^^^^^^^^{-1} MEncoder a | a has Format

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
Job : [Job [Command] (List Job)]
job : Job
job
main = entry
# ^^^^^ Job

View file

@ -0,0 +1,9 @@
app "test" provides [foo] to "./platform"
F a : { foo : a }
foo = \arg ->
#^^^{-1} F b -[[foo(0)]]-> b
x : F b
x = arg
x.foo

View file

@ -0,0 +1,6 @@
app "test" provides [main] to "./platform"
MHash has hash : a -> U64 | a has MHash
main = hash
# ^^^^ MHash#hash(2): a -[[] + a:hash(2):1]-> U64 | a has MHash

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Job a : [Job (List (Job a)) a]
job : Job Str
when job is
Job lst s -> P lst s
main = entry
# ^^^^^ [P (List ([Job (List a) Str] as a)) Str]w_b

View file

@ -0,0 +1,9 @@
app "test" provides [main] to "./platform"
entry =
returnFoo = .foo
returnFoo { foo: "foo" }
main = entry
# ^^^^^ Str

View file

@ -0,0 +1,13 @@
app "test" provides [main] to "./platform"
entry =
Foo a : [Blah (Result (Bar a) { val: a })]
Bar a : Foo a
v : Bar U8
v = Blah (Ok (Blah (Err { val: 1 })))
v
main = entry
# ^^^^^ Bar U8

View file

@ -0,0 +1,13 @@
app "test" provides [main] to "./platform"
entry =
Bar a : Foo a
Foo a : [Blah (Result (Bar a) { val: a })]
v : Bar U8
v = Blah (Ok (Blah (Err { val: 1 })))
v
main = entry
# ^^^^^ Bar U8

View file

@ -0,0 +1,7 @@
app "test" provides [main] to "./platform"
entry =
if Bool.true then List.first [] else Str.toI64 ""
main = entry
# ^^^^^ Result I64 [InvalidNumStr, ListWasEmpty]w_a

View file

@ -0,0 +1,10 @@
app "test" provides [effectAlways] to "./platform"
Effect a := {} -> a
effectAlways : a -> Effect a
effectAlways = \x ->
#^^^^^^^^^^^^{-1} a -[[effectAlways(0)]]-> Effect a
inner = \{} -> x
@Effect inner

View file

@ -0,0 +1,8 @@
app "test" provides [main] to "./platform"
entry =
fun = \a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb -> {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb}
fun
main = entry
# ^^^^^ w_a, w_b, w_c, w_d, w_e, w_f, w_g, w_h, w_i, w_j, w_k, w_l, w_m, w_n, w_o, w_p, w_q, w_r, w_s, w_t, w_u, w_v, w_w, w_x, w_y, w_z, w_aa, w_bb -[[fun(2)]]-> { a : w_a, aa : w_aa, b : w_b, bb : w_bb, c : w_c, d : w_d, e : w_e, f : w_f, g : w_g, h : w_h, i : w_i, j : w_j, k : w_k, l : w_l, m : w_m, n : w_n, o : w_o, p : w_p, q : w_q, r : w_r, s : w_s, t : w_t, u : w_u, v : w_v, w : w_w, x : w_x, y : w_y, z : w_z }

View file

@ -0,0 +1,23 @@
app "test" provides [hash, hash32, eq, le] to "./platform"
MHash has
hash : a -> U64 | a has MHash
hash32 : a -> U32 | a has MHash
Ord has
eq : a, a -> Bool | a has Ord
le : a, a -> Bool | a has Ord
Id := U64 has [MHash {hash, hash32}, Ord {eq, le}]
hash = \@Id n -> n
#^^^^{-1} Id#hash(7): Id -[[hash(7)]]-> U64
hash32 = \@Id n -> Num.toU32 n
#^^^^^^{-1} Id#hash32(8): Id -[[hash32(8)]]-> U32
eq = \@Id m, @Id n -> m == n
#^^{-1} Id#eq(9): Id, Id -[[eq(9)]]-> Bool
le = \@Id m, @Id n -> m < n
#^^{-1} Id#le(10): Id, Id -[[le(10)]]-> Bool

View file

@ -0,0 +1,17 @@
app "test" provides [go] to "./platform"
Expr : [
Wrap Expr,
Val I64,
]
go : Expr -> Expr
go = \e ->
#^^{-1} Expr -[[go(0)]]-> Expr
when P e is
P (Wrap (Val _)) -> Wrap e
# This branch should force the first argument to `P` and
# the first argument to `Wrap` to be an open tag union.
# This tests checks that we don't regress on that.
P y1 -> Wrap y1

View file

@ -0,0 +1,9 @@
app "test" provides [always] to "./platform"
Effect a := {} -> a
Task a err : Effect (Result a err)
always : a -> Task a *
always = \x -> @Effect (\{} -> Ok x)
#^^^^^^{-1} a -[[always(0)]]-> Task a *

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
Age := U32
v : Age -> U32
v = \@Age n -> n
v
main = entry
# ^^^^^ Age -[[v(3)]]-> U32

View file

@ -0,0 +1,9 @@
app "test" provides [main] to "./platform"
entry =
Age := U32
\@Age n -> n
main = entry
# ^^^^^ Age -[[entry(1)]]-> U32

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
v : Id a -> a
v = \@Id (Id _ n) -> n
v
main = entry
# ^^^^^ Id a -[[v(3)]]-> a

View file

@ -0,0 +1,17 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
f : Id [A, B, C { a : Str }e] -> Str
f = \id ->
when id is
@Id (Id _ A) -> ""
@Id (Id _ B) -> ""
@Id (Id _ (C { a: "" })) -> ""
@Id (Id _ (C { a: _ })) -> "" # any other string, for exhautiveness
f
main = entry
# ^^^^^ Id [A, B, C { a : Str }e] -[[f(3)]]-> Str

View file

@ -0,0 +1,14 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
\id ->
when id is
@Id (Id _ A) -> ""
@Id (Id _ B) -> ""
@Id (Id _ (C { a: "" })) -> ""
@Id (Id _ (C { a: _ })) -> "" # any other string, for exhautiveness
main = entry
# ^^^^^ Id [A, B, C { a : Str }w_a] -[[entry(1)]]-> Str

View file

@ -0,0 +1,9 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
\@Id (Id _ n) -> n
main = entry
# ^^^^^ Id w_a -[[entry(1)]]-> w_a

View file

@ -0,0 +1,14 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
strToBool : Str -> Bool
v : Id Str -> Bool
v = \@Id (Id _ n) -> strToBool n
v
main = entry
# ^^^^^ Id Str -[[v(4)]]-> Bool

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
strToBool : Str -> Bool
\@Id (Id _ n) -> strToBool n
main = entry
# ^^^^^ Id Str -[[5]]-> Bool

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Age := U32
a : Age
a = @Age 21
a
main = entry
# ^^^^^ Age

View file

@ -0,0 +1,9 @@
app "test" provides [main] to "./platform"
entry =
Age := U32
@Age 21
main = entry
# ^^^^^ Age

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
a : Id Str
a = @Id (Id 21 "sasha")
a
main = entry
# ^^^^^ Id Str

View file

@ -0,0 +1,16 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
condition : Bool
v : Id [Y Str, Z Str]
v =
if condition
then @Id (Id 21 (Y "sasha"))
else @Id (Id 21 (Z "felix"))
v
main = entry
# ^^^^^ Id [Y Str, Z Str]w_a

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
condition : Bool
if condition
then @Id (Id 21 (Y "sasha"))
else @Id (Id 21 (Z "felix"))
main = entry
# ^^^^^ Id [Y Str, Z Str]w_a

View file

@ -0,0 +1,9 @@
app "test" provides [main] to "./platform"
entry =
Id n := [Id U32 n]
@Id (Id 21 "sasha")
main = entry
# ^^^^^ Id Str

View file

@ -0,0 +1,10 @@
app "test" provides [main] to "./platform"
entry =
Other a b : { y: a, z: b }
f : { x : Str }(Other Str Str)
f
main = entry
# ^^^^^ { x : Str, y : Str, z : Str }

View file

@ -0,0 +1,13 @@
app "test" provides [hash, hash32] to "./platform"
MHash has
hash : a -> U64 | a has MHash
hash32 : a -> U32 | a has MHash
Id := U64 has [MHash {hash, hash32}]
hash = \@Id n -> n
#^^^^{-1} Id#hash(4): Id -[[hash(4)]]-> U64
hash32 = \@Id n -> Num.toU32 n
#^^^^^^{-1} Id#hash32(5): Id -[[hash32(5)]]-> U32

View file

@ -0,0 +1,8 @@
app "test" provides [hash] to "./platform"
MHash has hash : a -> U64 | a has MHash
Id := U64 has [MHash {hash}]
hash = \@Id n -> n
#^^^^{-1} Id#hash(3): Id -[[hash(3)]]-> U64

View file

@ -0,0 +1,18 @@
app "test"
imports [Json]
provides [main] to "./platform"
HelloWorld := {} has [Encoding {toEncoder}]
toEncoder = \@HelloWorld {} ->
Encode.custom \bytes, fmt ->
bytes
|> Encode.appendWith (Encode.string "Hello, World!\n") fmt
f =
when Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) Json.toUtf8) is
Ok s -> s
_ -> "<bad>"
main = f
# ^ Str

View file

@ -0,0 +1,10 @@
app "test" provides [main] to "./platform"
entry =
Other : [B, C]
f : [A]Other
f
main = entry
# ^^^^^ [A, B, C]*

View file

@ -0,0 +1,15 @@
app "test" provides [main] to "./platform"
entry =
Outer k := [Empty, Wrapped k]
insert : Outer k, k -> Outer k
insert = \m, var ->
when m is
@Outer Empty -> @Outer (Wrapped var)
@Outer (Wrapped _) -> @Outer (Wrapped var)
insert
main = entry
# ^^^^^ Outer k, k -[[insert(3)]]-> Outer k

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
Outer k := [Empty, Wrapped k]
when (@Outer Empty) is
@Outer Empty -> @Outer (Wrapped "")
@Outer (Wrapped k) -> @Outer (Wrapped k)
main = entry
# ^^^^^ Outer Str

View file

@ -0,0 +1,11 @@
app "test" provides [main] to "./platform"
entry =
Outer := [A, B]
when (@Outer A) is
@Outer A -> @Outer A
@Outer B -> @Outer B
main = entry
# ^^^^^ Outer

View file

@ -0,0 +1,11 @@
app "test" provides [tforever] to "./platform"
Effect a := {} -> a
eforever : Effect a -> Effect b
Task a err : Effect (Result a err)
tforever : Task val err -> Task * *
tforever = \task -> eforever task
#^^^^^^^^{-1} Task val err -[[tforever(0)]]-> Task * *

View file

@ -0,0 +1,10 @@
app "test" provides [main] to "./platform"
entry =
{
toF32: Num.toF32,
toF64: Num.toF64,
}
main = entry
# ^^^^^ { toF32 : Num * -[[Num.toF32(139)]]-> F32, toF64 : Num w_a -[[Num.toF64(141)]]-> F64 }

View file

@ -0,0 +1,19 @@
app "test" provides [main] to "./platform"
entry =
{
toI8: Num.toI8,
toI16: Num.toI16,
toI32: Num.toI32,
toI64: Num.toI64,
toI128: Num.toI128,
toNat: Num.toNat,
toU8: Num.toU8,
toU16: Num.toU16,
toU32: Num.toU32,
toU64: Num.toU64,
toU128: Num.toU128,
}
main = entry
# ^^^^^ { toI128 : Int * -[[Num.toI128(125)]]-> I128, toI16 : Int w_a -[[Num.toI16(119)]]-> I16, toI32 : Int w_b -[[Num.toI32(121)]]-> I32, toI64 : Int w_c -[[Num.toI64(123)]]-> I64, toI8 : Int w_d -[[Num.toI8(117)]]-> I8, toNat : Int w_e -[[Num.toNat(137)]]-> Nat, toU128 : Int w_f -[[Num.toU128(135)]]-> U128, toU16 : Int w_g -[[Num.toU16(129)]]-> U16, toU32 : Int w_h -[[Num.toU32(131)]]-> U32, toU64 : Int w_i -[[Num.toU64(133)]]-> U64, toU8 : Int w_j -[[Num.toU8(127)]]-> U8 }

View file

@ -0,0 +1,12 @@
app "test" provides [main] to "./platform"
entry =
func = \record ->
when record.tag is
A -> { record & tag: B }
B -> { record & tag: A }
func
main = entry
# ^^^^^ { tag : [A, B] }w_a -[[func(2)]]-> { tag : [A, B] }w_a