implement List.map in the dev backend

This commit is contained in:
Folkert 2023-04-23 17:35:17 +02:00
parent b62ee37d8e
commit b59ada4bc8
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
8 changed files with 449 additions and 21 deletions

View file

@ -1200,7 +1200,7 @@ fn list_count_if_str() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_on_empty_list_with_int_layout() {
assert_evals_to!(
indoc!(
@ -1218,7 +1218,7 @@ fn list_map_on_empty_list_with_int_layout() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_on_non_empty_list() {
assert_evals_to!(
indoc!(
@ -1236,7 +1236,7 @@ fn list_map_on_non_empty_list() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_changes_input() {
assert_evals_to!(
indoc!(
@ -1254,7 +1254,7 @@ fn list_map_changes_input() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_on_big_list() {
assert_evals_to!(
indoc!(
@ -1274,7 +1274,7 @@ fn list_map_on_big_list() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_with_type_change() {
assert_evals_to!(
indoc!(
@ -1293,7 +1293,7 @@ fn list_map_with_type_change() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_using_defined_function() {
assert_evals_to!(
indoc!(
@ -1315,7 +1315,7 @@ fn list_map_using_defined_function() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_all_inline() {
assert_evals_to!(
indoc!(
@ -1328,9 +1328,30 @@ fn list_map_all_inline() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_map_closure_int() {
assert_evals_to!(
indoc!(
r#"
int : I64
int = 123
single : List I64
single =
[0]
List.map single (\x -> x + int)
"#
),
RocList::from_slice(&[123]),
RocList<i64>
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_map_closure() {
fn list_map_closure_float() {
assert_evals_to!(
indoc!(
r#"

View file

@ -4055,3 +4055,27 @@ fn num_abs_large_bits_min_overflow() {
fn num_abs_float_overflow() {
assert_evals_to!("Num.absDiff Num.maxF64 Num.minF64", f64::INFINITY, f64);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
fn bool_in_switch() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
loop : [ Continue {}, Break {} ]
loop = Continue {}
all = \{} ->
when loop is
Continue {} -> Bool.true
Break {} -> Bool.false
main = all {}
"#
),
true,
bool
);
}

View file

@ -210,7 +210,7 @@ pub fn helper(
let builtins_host_tempfile =
roc_bitcode::host_tempfile().expect("failed to write host builtins object to tempfile");
if false {
if true {
std::fs::copy(&app_o_file, "/tmp/app.o").unwrap();
}