Fix all tests that don't depend on basic-cli

This commit is contained in:
Sam Mohr 2024-06-26 02:51:16 -07:00
parent 4b7d9c9222
commit 5ea6a8bdcd
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
8 changed files with 31 additions and 20 deletions

View file

@ -5,7 +5,12 @@ import pf.PlatformTask
# adapted from https://github.com/koka-lang/koka/blob/master/test/bench/haskell/cfold.hs # adapted from https://github.com/koka-lang/koka/blob/master/test/bench/haskell/cfold.hs
main : Task {} [] main : Task {} []
main = main =
inputResult <- Task.attempt PlatformTask.getInt { value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is when inputResult is
Ok n -> Ok n ->

View file

@ -7,7 +7,12 @@ IO a : Task a []
main : Task {} [] main : Task {} []
main = main =
inputResult <- Task.attempt PlatformTask.getInt { value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is when inputResult is
Ok n -> Ok n ->

View file

@ -4,7 +4,12 @@ import pf.PlatformTask
main : Task {} [] main : Task {} []
main = main =
inputResult = Task.getInt! { value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is when inputResult is
Ok n -> Ok n ->

View file

@ -1,4 +1,4 @@
hosted hosted PlatformTask
exposes [putLine, putInt, getInt] exposes [putLine, putInt, getInt]
imports [] imports []

View file

@ -39,7 +39,12 @@ fold = \f, tree, b ->
main : Task {} [] main : Task {} []
main = main =
inputResult = PlatformTask.getInt! { value, isError } = PlatformTask.getInt!
inputResult =
if isError then
Err GetIntError
else
Ok value
when inputResult is when inputResult is
Ok n -> Ok n ->

View file

@ -7,15 +7,6 @@ main : Task {} []
main = main =
PlatformTask.putLine! (showBool test1) PlatformTask.putLine! (showBool test1)
n = PlatformTask.getInt!
when n is
1 ->
PlatformTask.putLine (showBool test1)
_ ->
ns = Num.toStr n
PlatformTask.putLine "No test $(ns)"
showBool : Bool -> Str showBool : Bool -> Str
showBool = \b -> showBool = \b ->
if if

View file

@ -10,8 +10,8 @@ main =
when Base64.fromBytes (Str.toUtf8 "Hello World") is when Base64.fromBytes (Str.toUtf8 "Hello World") is
Err _ -> PlatformTask.putLine "sadness" Err _ -> PlatformTask.putLine "sadness"
Ok encoded -> Ok encoded ->
Task.putLine! (Str.concat "encoded: " encoded) PlatformTask.putLine! (Str.concat "encoded: " encoded)
when Base64.toStr encoded is when Base64.toStr encoded is
Ok decoded -> Task.putLine (Str.concat "decoded: " decoded) Ok decoded -> PlatformTask.putLine (Str.concat "decoded: " decoded)
Err _ -> Task.putLine "sadness" Err _ -> PlatformTask.putLine "sadness"

View file

@ -745,11 +745,11 @@ mod cli_run {
r#" r#"
Compiled in <ignored for test> ms. Compiled in <ignored for test> ms.
Direct.roc:
0 failed and 2 passed in <ignored for test> ms.
Transitive.roc: Transitive.roc:
0 failed and 1 passed in <ignored for test> ms. 0 failed and 1 passed in <ignored for test> ms.
Direct.roc:
0 failed and 2 passed in <ignored for test> ms.
"# "#
), ),
); );