mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-25 21:37:48 +00:00
Move uitests to their own crate
This commit is contained in:
parent
630a8e32d4
commit
2f43aad8d0
65 changed files with 507 additions and 9 deletions
|
|
@ -0,0 +1,45 @@
|
|||
# +opt print:can_decls
|
||||
# +opt infer:print_only_under_alias
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
Parser a : {} -> a
|
||||
|
||||
v1 : {}
|
||||
v1 = {}
|
||||
|
||||
v2 : Str
|
||||
v2 = ""
|
||||
|
||||
apply : Parser (a -> Str), a -> Parser Str
|
||||
apply = \fnParser, valParser ->
|
||||
\{} ->
|
||||
(fnParser {}) (valParser)
|
||||
|
||||
map : a, (a -> Str) -> Parser Str
|
||||
map = \simpleParser, transform ->
|
||||
apply (\{} -> transform) simpleParser
|
||||
|
||||
parseInput = \{} ->
|
||||
when [ map v1 (\{} -> ""), map v2 (\s -> s) ] is
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ List (({} -[[9 (({} -[[12 (Str -[[14]]-> Str)]]-> (Str -[[14]]-> Str))) Str, 9 (({} -[[12 ({} -[[13]]-> Str)]]-> ({} -[[13]]-> Str))) {}]]-> Str))
|
||||
_ -> ""
|
||||
|
||||
main = parseInput {} == ""
|
||||
|
||||
# -emit:can_decls
|
||||
v1 = {}
|
||||
|
||||
v2 = ""
|
||||
|
||||
apply = \fnParser, valParser -> \{} -[9]-> (fnParser {}) valParser
|
||||
|
||||
map = \simpleParser, transform -> apply \{} -[12]-> transform simpleParser
|
||||
|
||||
parseInput = \{} ->
|
||||
when [
|
||||
map v1 \{} -[13]-> "",
|
||||
map v2 \s -[14]-> s,
|
||||
] is
|
||||
_ -> ""
|
||||
|
||||
main = Bool.isEq (parseInput {}) ""
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
app "test" provides [main] to "./platform"
|
||||
|
||||
g = if Bool.true then A else B
|
||||
|
||||
main = g ""
|
||||
# ^ Str -[[2, 3]]-> [A Str, B Str]w_a
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
x = Bool.true
|
||||
y = Bool.false
|
||||
|
||||
a = "foo"
|
||||
b = "bar"
|
||||
|
||||
foo = \{} -> if x then a else bar {}
|
||||
#^^^{-1} {} -[[foo(5) Bool Bool Str Str]]-> Str
|
||||
|
||||
bar = \{} -> if y then b else foo {}
|
||||
#^^^{-1} {} -[[bar(6) Bool Bool Str Str]]-> Str
|
||||
|
||||
bar {}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
compose = \f, g ->
|
||||
closCompose = \x -> g (f x)
|
||||
closCompose
|
||||
|
||||
const = \x ->
|
||||
closConst = \_ -> x
|
||||
closConst
|
||||
|
||||
list = []
|
||||
|
||||
res : Str -> Str
|
||||
res = List.walk list (const "z") (\c1, c2 -> compose c1 c2)
|
||||
# ^^^^^^^ (Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str), (Str -[[]]-> Str) -[[compose(1)]]-> (Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str)
|
||||
# ^^^^^ Str -[[const(2)]]-> (Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str)
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^ (Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str), (Str -[[]]-> Str) -[[11]]-> (Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str)
|
||||
#^^^{-1} Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str
|
||||
|
||||
res "hello"
|
||||
#^^^{-1} Str -[[closCompose(7) (Str -a-> Str) (Str -[[]]-> Str), closConst(10) Str] as a]-> Str
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
app "test" provides [f] to "./platform"
|
||||
|
||||
thenDo = \x, callback ->
|
||||
callback x
|
||||
|
||||
f = \{} ->
|
||||
code = 10u16
|
||||
|
||||
bf = \{} ->
|
||||
#^^{-1} {} -[[bf(5) U16]]-> *
|
||||
thenDo code \_ -> bf {}
|
||||
# ^^^^^^^^^^^ U16 -[[6 U16]]-> *
|
||||
|
||||
bf {}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
x = "abc"
|
||||
|
||||
getX = \{} -> x
|
||||
|
||||
h = \{} -> (getX {})
|
||||
#^{-1} {}* -[[h(3) Str]]-> Str
|
||||
|
||||
h {}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
app "test" provides [main] to "./platform"
|
||||
|
||||
main =
|
||||
h = \{} -> (getX {})
|
||||
#^{-1} {}* -[[h(1) Str]]-> Str
|
||||
|
||||
getX = \{} -> x
|
||||
|
||||
x = "abc"
|
||||
|
||||
h {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue