mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
complete merge remote/main into rebuild-platform
This commit is contained in:
parent
8a566dc339
commit
aa98706547
5 changed files with 154 additions and 162 deletions
|
@ -351,39 +351,79 @@ mod cli_tests {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_out = r#"
|
let expected_out = "0 failed and 3 passed in <ignored for test> ms.\n";
|
||||||
0 failed and 3 passed in <ignored for test> ms.
|
|
||||||
"#;
|
|
||||||
|
|
||||||
cli_build.run().assert_clean_stdout(expected_out);
|
cli_build.run().assert_clean_stdout(expected_out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// basic-cli platform doesn't have support for Windows
|
||||||
|
#[cfg_attr(windows, ignore)]
|
||||||
mod test_platform_basic_cli {
|
mod test_platform_basic_cli {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use roc_cli::CMD_RUN;
|
use roc_cli::CMD_RUN;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
fn combine_tasks_with_record_builder() {
|
||||||
|
let cli_build = ExecCli::new(
|
||||||
|
CMD_BUILD,
|
||||||
|
file_from_root(
|
||||||
|
"crates/cli/tests/test-projects/effectful",
|
||||||
|
"combine-tasks.roc",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let expected_output = "For multiple tasks: {a: 123, b: \"abc\", c: [123]}\n";
|
||||||
|
|
||||||
|
cli_build.full_check_build_and_run(
|
||||||
|
expected_output,
|
||||||
|
TEST_LEGACY_LINKER,
|
||||||
|
ALLOW_VALGRIND,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
fn module_params_different_types() {
|
fn module_params_different_types() {
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_RUN,
|
CMD_BUILD,
|
||||||
file_from_root(
|
file_from_root(
|
||||||
"crates/cli/tests/test-projects/module_params",
|
"crates/cli/tests/test-projects/module_params",
|
||||||
"different_types.roc",
|
"different_types.roc",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_out = "Write something:\n42\n";
|
let expected_output = "Write something:\n42\n";
|
||||||
|
|
||||||
cli_build
|
cli_build.full_check_build_and_run(
|
||||||
.run_executable(false, Some("42"), None)
|
expected_output,
|
||||||
.assert_clean_stdout(expected_out);
|
TEST_LEGACY_LINKER,
|
||||||
|
ALLOW_VALGRIND,
|
||||||
|
Some("42\n"),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
|
// NOT SURE WHY THIS TEST IS FAILING
|
||||||
|
//
|
||||||
|
// ---- cli_tests::test_platform_basic_cli::module_params_different_types stdout ----
|
||||||
|
// thread 'cli_tests::test_platform_basic_cli::module_params_different_types' panicked at crates/cli_test_utils/src/command.rs:82:9:
|
||||||
|
// Command failed
|
||||||
|
|
||||||
|
// Command: /Users/luke/Documents/GitHub/roc/target/debug/roc run /Users/luke/Documents/GitHub/roc/crates/cli/tests/test-projects/module_params/different_types.roc
|
||||||
|
|
||||||
|
// Exit Code: exit status: 1
|
||||||
|
|
||||||
|
// Stdout:
|
||||||
|
// Write something:
|
||||||
|
|
||||||
|
// Stderr:
|
||||||
|
// Program exited with error:
|
||||||
|
// (StdinErr EndOfFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
|
||||||
fn module_params_issue_7116() {
|
fn module_params_issue_7116() {
|
||||||
let cli_build = ExecCli::new(
|
let cli_build = ExecCli::new(
|
||||||
CMD_RUN,
|
CMD_RUN,
|
||||||
|
@ -395,6 +435,27 @@ mod cli_tests {
|
||||||
|
|
||||||
cli_build.run().assert_zero_exit();
|
cli_build.run().assert_zero_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn module_params_pass_task() {
|
||||||
|
let cli_build = ExecCli::new(
|
||||||
|
CMD_BUILD,
|
||||||
|
file_from_root(
|
||||||
|
"crates/cli/tests/test-projects/module_params",
|
||||||
|
"pass_task.roc",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let expected_output = "Hi, Agus!\n";
|
||||||
|
|
||||||
|
cli_build.full_check_build_and_run(
|
||||||
|
expected_output,
|
||||||
|
TEST_LEGACY_LINKER,
|
||||||
|
ALLOW_VALGRIND,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_platform_simple_zig {
|
mod test_platform_simple_zig {
|
||||||
|
@ -769,7 +830,8 @@ mod cli_tests {
|
||||||
file_from_root("crates/cli/tests/test-projects/effectful", "print-line.roc"),
|
file_from_root("crates/cli/tests/test-projects/effectful", "print-line.roc"),
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_output = "You entered: hi there!\nIt is known\n";
|
let expected_output =
|
||||||
|
"Welcome!\nWhat's your name?\nYou entered: hi there!\nIt is known\n";
|
||||||
|
|
||||||
cli_build.full_check_build_and_run(
|
cli_build.full_check_build_and_run(
|
||||||
expected_output,
|
expected_output,
|
||||||
|
@ -780,30 +842,6 @@ mod cli_tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg_attr(windows, ignore)]
|
|
||||||
fn combine_tasks_with_record_builder() {
|
|
||||||
build_platform_host();
|
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
|
||||||
CMD_BUILD,
|
|
||||||
file_from_root(
|
|
||||||
"crates/cli/tests/test-projects/effectful",
|
|
||||||
"combine-tasks.roc",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let expected_output = "For multiple tasks: {a: 123, b: \"abc\", c: [123]}\n";
|
|
||||||
|
|
||||||
cli_build.full_check_build_and_run(
|
|
||||||
expected_output,
|
|
||||||
TEST_LEGACY_LINKER,
|
|
||||||
ALLOW_VALGRIND,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn inspect_logging() {
|
fn inspect_logging() {
|
||||||
|
@ -828,30 +866,6 @@ mod cli_tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg_attr(windows, ignore)]
|
|
||||||
fn module_params_pass_task() {
|
|
||||||
build_platform_host();
|
|
||||||
|
|
||||||
let cli_build = ExecCli::new(
|
|
||||||
CMD_BUILD,
|
|
||||||
file_from_root(
|
|
||||||
"crates/cli/tests/test-projects/module_params",
|
|
||||||
"pass_task.roc",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let expected_output = "Hi, Agus!\n";
|
|
||||||
|
|
||||||
cli_build.full_check_build_and_run(
|
|
||||||
expected_output,
|
|
||||||
TEST_LEGACY_LINKER,
|
|
||||||
ALLOW_VALGRIND,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn effectful_form() {
|
fn effectful_form() {
|
||||||
|
@ -862,109 +876,81 @@ mod cli_tests {
|
||||||
file_from_root("crates/cli/tests/test-projects/effectful", "form.roc"),
|
file_from_root("crates/cli/tests/test-projects/effectful", "form.roc"),
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_out = r#"
|
let expected_output = "What's your first name?\nWhat's your last name?\n\nHi, Agus Zubiaga!\n\nHow old are you?\n\nNice! You can vote!\n\nBye! 👋\n";
|
||||||
What's your first name?
|
|
||||||
What's your last name?
|
|
||||||
|
|
||||||
Hi, Agus Zubiaga!
|
cli_build.full_check_build_and_run(
|
||||||
|
expected_output,
|
||||||
How old are you?
|
TEST_LEGACY_LINKER,
|
||||||
|
ALLOW_VALGRIND,
|
||||||
Nice! You can vote!
|
Some("Agus\nZubiaga\n27\n"),
|
||||||
|
None,
|
||||||
Bye! 👋
|
);
|
||||||
"#;
|
|
||||||
|
|
||||||
cli_build
|
|
||||||
.run_executable(false, Some("Agus\nZubiaga\n27\n"), None)
|
|
||||||
.assert_clean_stdout(expected_out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn effectful_hello() {
|
fn effectful_hello() {
|
||||||
todo!();
|
build_platform_host();
|
||||||
// test_roc_app(
|
|
||||||
// "crates/cli/tests/test-projects/effectful",
|
let cli_build = ExecCli::new(
|
||||||
// "hello.roc",
|
roc_cli::CMD_DEV,
|
||||||
// &[],
|
file_from_root("crates/cli/tests/test-projects/effectful/", "hello.roc"),
|
||||||
// &[],
|
);
|
||||||
// &[],
|
|
||||||
// indoc!(
|
let expected_out = "I'm an effect 👻\n";
|
||||||
// r#"
|
|
||||||
// I'm an effect 👻
|
cli_build.run().assert_clean_stdout(expected_out);
|
||||||
// "#
|
|
||||||
// ),
|
|
||||||
// UseValgrind::No,
|
|
||||||
// TestCliCommands::Dev,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn effectful_loops() {
|
fn effectful_loops() {
|
||||||
todo!();
|
build_platform_host();
|
||||||
// test_roc_app(
|
|
||||||
// "crates/cli/tests/test-projects/effectful",
|
let cli_build = ExecCli::new(
|
||||||
// "loops.roc",
|
roc_cli::CMD_DEV,
|
||||||
// &[],
|
file_from_root("crates/cli/tests/test-projects/effectful/", "loops.roc"),
|
||||||
// &[],
|
);
|
||||||
// &[],
|
|
||||||
// indoc!(
|
let expected_out = "Lu\nMarce\nJoaquin\nChloé\nMati\nPedro\n";
|
||||||
// r#"
|
|
||||||
// Lu
|
cli_build.run().assert_clean_stdout(expected_out);
|
||||||
// Marce
|
|
||||||
// Joaquin
|
|
||||||
// Chloé
|
|
||||||
// Mati
|
|
||||||
// Pedro
|
|
||||||
// "#
|
|
||||||
// ),
|
|
||||||
// UseValgrind::No,
|
|
||||||
// TestCliCommands::Dev,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn effectful_untyped_passed_fx() {
|
fn effectful_untyped_passed_fx() {
|
||||||
todo!();
|
build_platform_host();
|
||||||
// test_roc_app(
|
|
||||||
// "crates/cli/tests/test-projects/effectful",
|
let cli_build = ExecCli::new(
|
||||||
// "untyped_passed_fx.roc",
|
roc_cli::CMD_DEV,
|
||||||
// &[],
|
file_from_root(
|
||||||
// &[],
|
"crates/cli/tests/test-projects/effectful/",
|
||||||
// &[],
|
"untyped_passed_fx.roc",
|
||||||
// indoc!(
|
),
|
||||||
// r#"
|
);
|
||||||
// Before hello
|
|
||||||
// Hello, World!
|
let expected_out = "Before hello\nHello, World!\nAfter hello\n";
|
||||||
// After hello
|
|
||||||
// "#
|
cli_build.run().assert_clean_stdout(expected_out);
|
||||||
// ),
|
|
||||||
// UseValgrind::No,
|
|
||||||
// TestCliCommands::Dev,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(windows, ignore)]
|
#[cfg_attr(windows, ignore)]
|
||||||
fn effectful_ignore_result() {
|
fn effectful_ignore_result() {
|
||||||
todo!();
|
build_platform_host();
|
||||||
// test_roc_app(
|
|
||||||
// "crates/cli/tests/test-projects/effectful",
|
let cli_build = ExecCli::new(
|
||||||
// "ignore_result.roc",
|
roc_cli::CMD_DEV,
|
||||||
// &[],
|
file_from_root(
|
||||||
// &[],
|
"crates/cli/tests/test-projects/effectful/",
|
||||||
// &[],
|
"ignore_result.roc",
|
||||||
// indoc!(
|
),
|
||||||
// r#"
|
);
|
||||||
// I asked for input and I ignored it. Deal with it! 😎
|
|
||||||
// "#
|
let expected_out = "I asked for input and I ignored it. Deal with it! 😎\n";
|
||||||
// ),
|
|
||||||
// UseValgrind::No,
|
cli_build.run().assert_clean_stdout(expected_out);
|
||||||
// TestCliCommands::Dev,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
app [main!] { pf: platform "../test-platform-effects-zig/main.roc" }
|
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
|
||||||
|
|
||||||
import pf.PlatformTasks
|
import pf.Stdout
|
||||||
|
|
||||||
main! = \{} ->
|
main =
|
||||||
multipleIn =
|
multipleIn =
|
||||||
{ sequential <-
|
{ sequential <-
|
||||||
a: Ok 123,
|
a: Task.ok 123,
|
||||||
b: Ok "abc",
|
b: Task.ok "abc",
|
||||||
c: Ok [123],
|
c: Task.ok [123],
|
||||||
_d: Ok ["abc"],
|
_d: Task.ok ["abc"],
|
||||||
_: Ok (Dict.single "a" "b"),
|
_: Task.ok (Dict.single "a" "b"),
|
||||||
}?
|
}!
|
||||||
|
|
||||||
PlatformTasks.putLine! "For multiple tasks: $(Inspect.toStr multipleIn)"
|
Stdout.line! "For multiple tasks: $(Inspect.toStr multipleIn)"
|
||||||
|
|
||||||
sequential : Result a err, Result b err, (a, b -> c) -> Result c err
|
sequential : Task a err, Task b err, (a, b -> c) -> Task c err
|
||||||
sequential = \firstTask, secondTask, mapper ->
|
sequential = \firstTask, secondTask, mapper ->
|
||||||
first = firstTask
|
first = firstTask!
|
||||||
second = secondTask
|
second = secondTask!
|
||||||
Ok (mapper first second)
|
Task.ok (mapper first second)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
app [main!] { pf: platform "../test-platform-effects-zig/main.roc" }
|
app [main!] { pf: platform "../test-platform-effects-zig/main.roc" }
|
||||||
|
|
||||||
import pf.PlatformTasks
|
import pf.Effect
|
||||||
import Community
|
import Community
|
||||||
|
|
||||||
main! = \{} ->
|
main! = \{} ->
|
||||||
|
@ -32,4 +32,4 @@ main! = \{} ->
|
||||||
|> Community.addFriend 0 2
|
|> Community.addFriend 0 2
|
||||||
|> Community.addFriend 1 2
|
|> Community.addFriend 1 2
|
||||||
|> Inspect.toStr
|
|> Inspect.toStr
|
||||||
|> PlatformTasks.putLine!
|
|> Effect.putLine!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
app [main!] { pf: platform "../test-platform-effects-zig/main.roc" }
|
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" }
|
||||||
|
|
||||||
import pf.Effect
|
import pf.Stdout
|
||||||
import Menu { echo: \str -> Effect.putLine! str }
|
import Menu { echo: \str -> Stdout.line str }
|
||||||
|
|
||||||
main! = \{} ->
|
main =
|
||||||
Menu.menu "Agus"
|
Menu.menu "Agus"
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
app [main!] { pf: platform "main.roc" }
|
app [main!] { pf: platform "main.roc" }
|
||||||
|
|
||||||
|
import pf.Effect
|
||||||
|
|
||||||
# just a stubbed app for building the test platform
|
# just a stubbed app for building the test platform
|
||||||
main! = Ok {}
|
main! = \{} ->
|
||||||
|
|
||||||
|
Effect.putLine! ""
|
||||||
|
|
||||||
|
{}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue