dev backend: Box.unbox and List.get str

This commit is contained in:
Folkert 2023-02-09 16:28:12 +01:00
parent 4d1a6b17a8
commit 8df8c19ae2
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 87 additions and 16 deletions

View file

@ -1869,6 +1869,20 @@ fn first_int_list() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn first_str_list() {
assert_evals_to!(
indoc!(
r#"
List.first ["short", "bar"]
"#
),
RocResult::ok(RocStr::from("short")),
RocResult<RocStr, ()>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn first_wildcard_empty_list() {
@ -1981,6 +1995,20 @@ fn get_wildcard_empty_list() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn get_str_list_ok() {
assert_evals_to!(
indoc!(
r#"
List.get ["foo", "bar"] 1
"#
),
RocResult::ok(RocStr::from("bar")),
RocResult<RocStr, ()>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn get_int_list_ok() {

View file

@ -3254,9 +3254,25 @@ fn issue_2322() {
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_and_unbox_small_string() {
assert_evals_to!(
indoc!(
r#"
"short"
|> Box.box
|> Box.unbox
"#
),
RocStr::from("short"),
RocStr
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn box_and_unbox_string() {
fn box_and_unbox_big_string() {
assert_evals_to!(
indoc!(
r#"