Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton-4 committed Jan 28, 2025
1 parent 4579d61 commit f4a981f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 4 deletions.
24 changes: 20 additions & 4 deletions crates/cli/tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,21 @@ mod cli_tests {
#[test]
#[cfg_attr(windows, ignore)]
fn roc_check_markdown_docs() {
let cli_build = ExecCli::new(
let cli_check = ExecCli::new(
CMD_CHECK,
file_from_root("crates/cli/tests/markdown", "form.md"),
);

let expected_out =
"0 errors and 0 warnings found in <ignored for test> ms.\n\n0 errors and 0 warnings found in <ignored for test> ms.\n\n";

cli_build.run().assert_clean_stdout(expected_out);
cli_check.run().assert_clean_stdout(expected_out);
}

#[test]
#[cfg_attr(windows, ignore)]
fn import_in_expect() {
let cli_build = ExecCli::new(
let cli_test = ExecCli::new(
CMD_TEST,
file_from_root(
"crates/cli/tests/test-projects/module_params",
Expand All @@ -343,7 +343,23 @@ mod cli_tests {

let expected_out = "0 failed and 3 passed in <ignored for test> ms.\n";

cli_build.run().assert_clean_stdout(expected_out);
cli_test.run().assert_clean_stdout(expected_out);
}

#[test]
#[cfg_attr(windows, ignore)]
// https://github.com/roc-lang/roc/issues/7461
fn issue7461() {
let cli_test = ExecCli::new(
CMD_TEST,
file_from_root("crates/cli/tests/test-projects/", "issue7461.roc"),
);

let expected_out = "0 failed and 1 passed in <ignored for test> ms.\n";

cli_test
.run()
.assert_stdout_and_stderr_ends_with(expected_out);
}
}

Expand Down
65 changes: 65 additions & 0 deletions crates/cli/tests/test-projects/issue7461.roc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module []

expect

_ =
when new_scatter { data : []} is
Ok asdf -> scatter_to_str asdf
Err _ -> crash ""

1 == 1


Trace x := {
data : List { x : x},
orientation : [Vertical],
name : Str,
marker : Marker,
}
implements [Inspect]

new_scatter :
{
data : List { x : x },
orientation ? [Vertical],
name ? Str,
}
-> Result (Trace x) _
new_scatter = \{ data, orientation ? Vertical, name ? ""} ->
Ok
(
@Trace {
data,
orientation,
name,
marker: new_marker? {},
}
)

# CHANING ANYHTING IN HERE SEEMS TO "FIX" IT
scatter_to_str : Trace x -> Str where x implements Inspect
scatter_to_str = \@Trace inner ->

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
data2 = List.walk inner.data ([]) \(xs), { x } -> (List.append xs x)

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
orientation_str = if inner.orientation == Vertical then "\"orientation\":\"v\"" else "\"orientation\":\"h\""

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
name_str = if Str.is_empty inner.name then "" else "\"name\":\"$(inner.name)\""

# NOT USED ... BUT WE CAN"T REMOVE, OR BUG GOES AWAY??
marker_str = marker_to_str inner.marker #"testtt"

""


Marker := {}
implements [Inspect]

new_marker : {} -> Result Marker _
new_marker = \{} -> Ok (@Marker {})

marker_to_str : Marker -> Str
marker_to_str = \_ -> ""

0 comments on commit f4a981f

Please sign in to comment.