diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000000..99b20a3c9d --- /dev/null +++ b/.cargo/config @@ -0,0 +1,4 @@ +[alias] +test-gen-llvm = "test -p test_gen" +test-gen-dev = "test -p test_gen --no-default-features --features gen-dev" +test-gen-wasm = "test -p test_gen --no-default-features --features gen-wasm" diff --git a/Cargo.lock b/Cargo.lock index ff4b6057b5..948c8742bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4070,29 +4070,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "test_dev" -version = "0.1.0" -dependencies = [ - "bumpalo", - "indoc", - "libloading 0.7.1", - "roc_build", - "roc_builtins", - "roc_can", - "roc_collections", - "roc_constrain", - "roc_gen_dev", - "roc_load", - "roc_mono", - "roc_parse", - "roc_problem", - "roc_reporting", - "roc_std", - "target-lexicon", - "tempfile", -] - [[package]] name = "test_gen" version = "0.1.0" @@ -4110,7 +4087,9 @@ dependencies = [ "roc_can", "roc_collections", "roc_constrain", + "roc_gen_dev", "roc_gen_llvm", + "roc_gen_wasm", "roc_load", "roc_module", "roc_mono", @@ -4124,7 +4103,6 @@ dependencies = [ "roc_unify", "target-lexicon", "tempfile", - "test_wasm_util", "wasmer", "wasmer-wasi", ] @@ -4154,35 +4132,6 @@ dependencies = [ "syn", ] -[[package]] -name = "test_wasm" -version = "0.1.0" -dependencies = [ - "bumpalo", - "indoc", - "libc", - "roc_builtins", - "roc_can", - "roc_collections", - "roc_gen_wasm", - "roc_load", - "roc_module", - "roc_std", - "roc_types", - "target-lexicon", - "test_wasm_util", - "wasmer", - "wasmer-wasi", -] - -[[package]] -name = "test_wasm_util" -version = "0.1.0" -dependencies = [ - "roc_std", - "wasmer", -] - [[package]] name = "textwrap" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index 403bd97757..da159d2754 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,9 +22,7 @@ members = [ "compiler/gen_wasm", "compiler/build", "compiler/arena_pool", - "compiler/test_dev", "compiler/test_gen", - "compiler/test_wasm", "vendor/ena", "vendor/inkwell", "vendor/pathfinding", @@ -44,7 +42,6 @@ exclude = [ # The tests will still correctly build them. "cli_utils", "compiler/test_mono_macros", - "compiler/test_wasm_util", ] # Needed to be able to run `cargo run -p roc_cli --no-default-features` - # see www/build.sh for more. diff --git a/Earthfile b/Earthfile index e2cb8fc9b8..315bbf1eb1 100644 --- a/Earthfile +++ b/Earthfile @@ -79,10 +79,13 @@ test-rust: # not pre-compiling the host can cause race conditions RUN echo "4" | cargo run --release examples/benchmarks/NQueens.roc RUN --mount=type=cache,target=$SCCACHE_DIR \ - cargo test --release --features with_sound --workspace --exclude test_wasm && sccache --show-stats - # test_wasm has some multithreading problems to do with the wasmer runtime. Run it single-threaded as a separate job + cargo test --release --features with_sound --workspace && sccache --show-stats + # test the dev and wasm backend: they require an explicit feature flag. RUN --mount=type=cache,target=$SCCACHE_DIR \ - cargo test --release --package test_wasm -- --test-threads=1 && sccache --show-stats + cargo test --release --package test_gen --no-default-features --features gen-dev && sccache --show-stats + # gen-wasm has some multithreading problems to do with the wasmer runtime. Run it single-threaded as a separate job + RUN --mount=type=cache,target=$SCCACHE_DIR \ + cargo test --release --package test_gen --no-default-features --features gen-wasm -- --test-threads=1 && sccache --show-stats # run i386 (32-bit linux) cli tests RUN echo "4" | cargo run --release --features="target-x86" -- --backend=x86_32 examples/benchmarks/NQueens.roc RUN --mount=type=cache,target=$SCCACHE_DIR \ diff --git a/compiler/gen_dev/README.md b/compiler/gen_dev/README.md index bd8d8f9e5a..12321accf1 100644 --- a/compiler/gen_dev/README.md +++ b/compiler/gen_dev/README.md @@ -67,10 +67,9 @@ This is the general procedure I follow with some helpful links: 1. Find a feature that is just n+1. For example, since we already have integers, adding a builtin that functions on them should be n+1. On the other hand, since we don't yet have booleans/conditionals, adding if statements may not yet be n+1. - A good place to look for missing features is in the test files for both the [regular](https://github.com/rtfeldman/roc/tree/trunk/compiler/gen/tests) and [dev](https://github.com/rtfeldman/roc/tree/trunk/compiler/gen_dev/tests) backend. - Eventually these test files should be practically identical. + A good place to look for missing features is in the test files for generation in [test_gen](https://github.com/rtfeldman/roc/tree/trunk/compiler/test_gen). Any test that is not enabled for the `gen-dev` feature still needs to be added to the dev backend. Eventually all features should be enabled for the dev backend. 1. Pick/write the simplest test case you can find for the new feature. - Just uncomment/copy over the test if it already exists. + Just add `feature = "gen-dev"` to the `cfg` line for the test case. 1. Uncomment the code to print out procedures [from here](https://github.com/rtfeldman/roc/blob/trunk/compiler/gen_dev/tests/helpers/eval.rs) and run the test. It should fail and print out the mono ir for this test case. Seeing the actual mono ir tends to be very helpful for complex additions. diff --git a/compiler/test_dev/Cargo.toml b/compiler/test_dev/Cargo.toml deleted file mode 100644 index 4a6690a4bd..0000000000 --- a/compiler/test_dev/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "test_dev" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[[test]] -name = "test_dev" -path = "src/tests.rs" - -[dev-dependencies] -roc_collections = { path = "../collections" } -roc_can = { path = "../can" } -roc_build = { path = "../build" } -roc_parse = { path = "../parse" } -roc_reporting = { path = "../reporting" } -roc_load = { path = "../load" } -roc_constrain = { path = "../constrain" } -roc_std = { path = "../../roc_std" } -roc_gen_dev = { path = "../gen_dev" } -roc_mono = { path = "../mono" } -roc_problem = { path = "../problem" } -roc_builtins = { path = "../builtins" } -indoc = "1.0.3" -bumpalo = { version = "3.8.0", features = ["collections"] } -tempfile = "3.2.0" -libloading = "0.7.1" -target-lexicon = "0.12.2" diff --git a/compiler/test_dev/src/dev_num.rs b/compiler/test_dev/src/dev_num.rs deleted file mode 100644 index aabb3aef91..0000000000 --- a/compiler/test_dev/src/dev_num.rs +++ /dev/null @@ -1,871 +0,0 @@ -#![cfg(all(test, any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] - -use crate::assert_evals_to; -use indoc::indoc; - -#[test] -fn i64_values() { - assert_evals_to!("0", 0, i64); - assert_evals_to!("-0", 0, i64); - assert_evals_to!("-1", -1, i64); - assert_evals_to!("1", 1, i64); - assert_evals_to!("9_000_000_000_000", 9_000_000_000_000, i64); - assert_evals_to!("-9_000_000_000_000", -9_000_000_000_000, i64); - assert_evals_to!("0b1010", 0b1010, i64); - assert_evals_to!("0o17", 0o17, i64); - assert_evals_to!("0x1000_0000_0000_0000", 0x1000_0000_0000_0000, i64); -} - -#[test] -fn f64_values() { - assert_evals_to!("0.0", 0.0, f64); - assert_evals_to!("-0.0", 0.0, f64); - assert_evals_to!("1.0", 1.0, f64); - assert_evals_to!("-1.0", -1.0, f64); - assert_evals_to!("3.1415926535897932", 3.141_592_653_589_793, f64); - assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64); - assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64); -} - -#[test] -fn gen_add_i64() { - assert_evals_to!( - indoc!( - r#" - 1 + 2 + 3 - "# - ), - 6, - i64 - ); -} - -#[test] -fn gen_add_f64() { - assert_evals_to!( - indoc!( - r#" - 1.1 + 2.4 + 3 - "# - ), - 6.5, - f64 - ); -} - -#[test] -fn gen_sub_i64() { - assert_evals_to!( - indoc!( - r#" - 1 - 2 - 3 - "# - ), - -4, - i64 - ); -} - -#[test] -fn gen_mul_i64() { - assert_evals_to!( - indoc!( - r#" - 2 * 4 * 6 - "# - ), - 48, - i64 - ); -} - -#[test] -fn i64_force_stack() { - // This claims 33 registers. One more than Arm and RISC-V, and many more than x86-64. - assert_evals_to!( - indoc!( - r#" - a = 0 - b = 1 - c = 2 - d = 3 - e = 4 - f = 5 - g = 6 - h = 7 - i = 8 - j = 9 - k = 10 - l = 11 - m = 12 - n = 13 - o = 14 - p = 15 - q = 16 - r = 17 - s = 18 - t = 19 - u = 20 - v = 21 - w = 22 - x = 23 - y = 24 - z = 25 - aa = 26 - ab = 27 - ac = 28 - ad = 29 - ae = 30 - af = 31 - ag = 32 - - a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z + aa + ab + ac + ad + ae + af + ag - "# - ), - 528, - i64 - ); -} - -#[test] -fn i64_abs() { - assert_evals_to!("Num.abs -6", 6, i64); - assert_evals_to!("Num.abs 7", 7, i64); - assert_evals_to!("Num.abs 0", 0, i64); - assert_evals_to!("Num.abs -0", 0, i64); - assert_evals_to!("Num.abs -1", 1, i64); - assert_evals_to!("Num.abs 1", 1, i64); - assert_evals_to!("Num.abs 9_000_000_000_000", 9_000_000_000_000, i64); - assert_evals_to!("Num.abs -9_000_000_000_000", 9_000_000_000_000, i64); -} - -#[test] -fn gen_int_eq() { - assert_evals_to!( - indoc!( - r#" - 4 == 4 - "# - ), - true, - bool - ); - - assert_evals_to!( - indoc!( - r#" - 3 == 4 - "# - ), - false, - bool - ); -} - -#[test] -fn gen_basic_fn() { - assert_evals_to!( - indoc!( - r#" - always42 : Num.Num (Num.Integer Num.Signed64) -> Num.Num (Num.Integer Num.Signed64) - always42 = \_ -> 42 - - always42 5 - "# - ), - 42, - i64 - ); -} - -#[test] -fn gen_wrap_add_nums() { - assert_evals_to!( - indoc!( - r#" - add2 = \num1, num2 -> num1 + num2 - - add2 4 5 - "# - ), - 9, - i64 - ); -} - -#[test] -fn gen_wrap_add_nums_force_stack() { - assert_evals_to!( - indoc!( - r#" - add9 = \num1, num2, num3, num4, num5, num6, num7, num8, num9 -> num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 - - add9 1 2 3 4 5 6 7 8 9 - "# - ), - 45, - i64 - ); -} - -#[test] -fn pow_int() { - assert_evals_to!("Num.powInt 2 3", 8, i64); -} - -#[test] -fn acos() { - assert_evals_to!("Num.acos 0.5", 1.0471975511965979, f64); -} - -#[test] -fn asin() { - assert_evals_to!("Num.asin 0.5", 0.5235987755982989, f64); -} - -#[test] -fn atan() { - assert_evals_to!("Num.atan 10", 1.4711276743037347, f64); -} - -#[test] -fn gen_if_fn() { - assert_evals_to!( - indoc!( - r#" - limitedNegate = \num -> - x = - if num == 1 then - -1 - else if num == -1 then - 1 - else - num - x - - limitedNegate 1 - "# - ), - -1, - i64 - ); -} - -#[test] -fn gen_fib_fn() { - assert_evals_to!( - indoc!( - r#" - fib = \n -> - if n == 0 then - 0 - else if n == 1 then - 1 - else - (fib (n - 1)) + (fib (n - 2)) - - fib 10 - "# - ), - 55, - i64 - ); -} - -#[test] -fn gen_fast_fib_fn() { - assert_evals_to!( - indoc!( - r#" - fib = \n, a, b -> - if n == 0 then - a - else - fib (n - 1) b (a + b) - fib 10 0 1 - "# - ), - 55, - i64 - ); -} - -#[test] -fn f64_abs() { - assert_evals_to!("Num.abs -4.7", 4.7, f64); - assert_evals_to!("Num.abs 5.8", 5.8, f64); -} - -#[test] -fn f64_round() { - assert_evals_to!("Num.round 3.6", 4, i64); - assert_evals_to!("Num.round 3.4", 3, i64); - assert_evals_to!("Num.round 2.5", 3, i64); - assert_evals_to!("Num.round -2.3", -2, i64); - assert_evals_to!("Num.round -2.5", -3, i64); -} - -// #[test] -// fn f64_sqrt() { -// // FIXME this works with normal types, but fails when checking uniqueness types -// assert_evals_to!( -// indoc!( -// r#" -// when Num.sqrt 100 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 10.0, -// f64 -// ); -// } - -// #[test] -// fn gen_float_eq() { -// assert_evals_to!( -// indoc!( -// r#" -// 1.0 == 1.0 -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn gen_div_f64() { -// // FIXME this works with normal types, but fails when checking uniqueness types -// assert_evals_to!( -// indoc!( -// r#" -// when 48 / 2 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 24.0, -// f64 -// ); -// } - -// #[test] -// fn gen_int_neq() { -// assert_evals_to!( -// indoc!( -// r#" -// 4 != 5 -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn gen_wrap_int_neq() { -// assert_evals_to!( -// indoc!( -// r#" -// wrappedNotEq : a, a -> Bool -// wrappedNotEq = \num1, num2 -> -// num1 != num2 - -// wrappedNotEq 2 3 -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn gen_sub_f64() { -// assert_evals_to!( -// indoc!( -// r#" -// 1.5 - 2.4 - 3 -// "# -// ), -// -3.9, -// f64 -// ); -// } - -// #[test] -// fn gen_div_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when 1000 // 10 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 100, -// i64 -// ); -// } - -// #[test] -// fn gen_div_by_zero_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when 1000 // 0 is -// Err DivByZero -> 99 -// _ -> -24 -// "# -// ), -// 99, -// i64 -// ); -// } - -// #[test] -// fn gen_rem_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.rem 8 3 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 2, -// i64 -// ); -// } - -// #[test] -// fn gen_rem_div_by_zero_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.rem 8 0 is -// Err DivByZero -> 4 -// Ok _ -> -23 -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn gen_is_zero_i64() { -// assert_evals_to!("Num.isZero 0", true, bool); -// assert_evals_to!("Num.isZero 1", false, bool); -// } - -// #[test] -// fn gen_is_positive_i64() { -// assert_evals_to!("Num.isPositive 0", false, bool); -// assert_evals_to!("Num.isPositive 1", true, bool); -// assert_evals_to!("Num.isPositive -5", false, bool); -// } - -// #[test] -// fn gen_is_negative_i64() { -// assert_evals_to!("Num.isNegative 0", false, bool); -// assert_evals_to!("Num.isNegative 3", false, bool); -// assert_evals_to!("Num.isNegative -2", true, bool); -// } - -// #[test] -// fn gen_is_positive_f64() { -// assert_evals_to!("Num.isPositive 0.0", false, bool); -// assert_evals_to!("Num.isPositive 4.7", true, bool); -// assert_evals_to!("Num.isPositive -8.5", false, bool); -// } - -// #[test] -// fn gen_is_negative_f64() { -// assert_evals_to!("Num.isNegative 0.0", false, bool); -// assert_evals_to!("Num.isNegative 9.9", false, bool); -// assert_evals_to!("Num.isNegative -4.4", true, bool); -// } - -// #[test] -// fn gen_is_zero_f64() { -// assert_evals_to!("Num.isZero 0", true, bool); -// assert_evals_to!("Num.isZero 0_0", true, bool); -// assert_evals_to!("Num.isZero 0.0", true, bool); -// assert_evals_to!("Num.isZero 1", false, bool); -// } - -// #[test] -// fn gen_is_odd() { -// assert_evals_to!("Num.isOdd 4", false, bool); -// assert_evals_to!("Num.isOdd 5", true, bool); -// } - -// #[test] -// fn gen_is_even() { -// assert_evals_to!("Num.isEven 6", true, bool); -// assert_evals_to!("Num.isEven 7", false, bool); -// } - -// #[test] -// fn sin() { -// assert_evals_to!("Num.sin 0", 0.0, f64); -// assert_evals_to!("Num.sin 1.41421356237", 0.9877659459922529, f64); -// } - -// #[test] -// fn cos() { -// assert_evals_to!("Num.cos 0", 1.0, f64); -// assert_evals_to!("Num.cos 3.14159265359", -1.0, f64); -// } - -// #[test] -// fn tan() { -// assert_evals_to!("Num.tan 0", 0.0, f64); -// assert_evals_to!("Num.tan 1", 1.557407724654902, f64); -// } - -// #[test] -// fn lt_i64() { -// assert_evals_to!("1 < 2", true, bool); -// assert_evals_to!("1 < 1", false, bool); -// assert_evals_to!("2 < 1", false, bool); -// assert_evals_to!("0 < 0", false, bool); -// } - -// #[test] -// fn lte_i64() { -// assert_evals_to!("1 <= 1", true, bool); -// assert_evals_to!("2 <= 1", false, bool); -// assert_evals_to!("1 <= 2", true, bool); -// assert_evals_to!("0 <= 0", true, bool); -// } - -// #[test] -// fn gt_i64() { -// assert_evals_to!("2 > 1", true, bool); -// assert_evals_to!("2 > 2", false, bool); -// assert_evals_to!("1 > 1", false, bool); -// assert_evals_to!("0 > 0", false, bool); -// } - -// #[test] -// fn gte_i64() { -// assert_evals_to!("1 >= 1", true, bool); -// assert_evals_to!("1 >= 2", false, bool); -// assert_evals_to!("2 >= 1", true, bool); -// assert_evals_to!("0 >= 0", true, bool); -// } - -// #[test] -// fn lt_f64() { -// assert_evals_to!("1.1 < 1.2", true, bool); -// assert_evals_to!("1.1 < 1.1", false, bool); -// assert_evals_to!("1.2 < 1.1", false, bool); -// assert_evals_to!("0.0 < 0.0", false, bool); -// } - -// #[test] -// fn lte_f64() { -// assert_evals_to!("1.1 <= 1.1", true, bool); -// assert_evals_to!("1.2 <= 1.1", false, bool); -// assert_evals_to!("1.1 <= 1.2", true, bool); -// assert_evals_to!("0.0 <= 0.0", true, bool); -// } - -// #[test] -// fn gt_f64() { -// assert_evals_to!("2.2 > 1.1", true, bool); -// assert_evals_to!("2.2 > 2.2", false, bool); -// assert_evals_to!("1.1 > 2.2", false, bool); -// assert_evals_to!("0.0 > 0.0", false, bool); -// } - -// #[test] -// fn gte_f64() { -// assert_evals_to!("1.1 >= 1.1", true, bool); -// assert_evals_to!("1.1 >= 1.2", false, bool); -// assert_evals_to!("1.2 >= 1.1", true, bool); -// assert_evals_to!("0.0 >= 0.0", true, bool); -// } - -#[test] -fn gen_order_of_arithmetic_ops() { - assert_evals_to!( - indoc!( - r#" - 1 + 3 * 7 - 2 - "# - ), - 20, - i64 - ); -} - -// #[test] -// fn gen_order_of_arithmetic_ops_complex_float() { -// assert_evals_to!( -// indoc!( -// r#" -// 3 - 48 * 2.0 -// "# -// ), -// -93.0, -// f64 -// ); -// } - -#[test] -fn if_guard_bind_variable_false() { - assert_evals_to!( - indoc!( - r#" - wrapper = \{} -> - when 10 is - x if x == 5 -> 0 - _ -> 42 - - wrapper {} - "# - ), - 42, - i64 - ); -} - -#[test] -fn if_guard_bind_variable_true() { - assert_evals_to!( - indoc!( - r#" - wrapper = \{} -> - when 10 is - x if x == 10 -> 42 - _ -> 0 - - wrapper {} - "# - ), - 42, - i64 - ); -} - -#[test] -fn tail_call_elimination() { - assert_evals_to!( - indoc!( - r#" - sum = \n, accum -> - when n is - 0 -> accum - _ -> sum (n - 1) (n + accum) - - sum 1_000_000 0 - "# - ), - 500000500000, - i64 - ); -} - -// #[test] -// fn int_negate() { -// assert_evals_to!("Num.neg 123", -123, i64); -// } - -// #[test] -// fn gen_wrap_int_neg() { -// assert_evals_to!( -// indoc!( -// r#" -// wrappedNeg = \num -> -num - -// wrappedNeg 3 -// "# -// ), -// -3, -// i64 -// ); -// } - -// #[test] -// fn int_to_float() { -// assert_evals_to!("Num.toFloat 0x9", 9.0, f64); -// } - -// #[test] -// fn num_to_float() { -// assert_evals_to!("Num.toFloat 9", 9.0, f64); -// } - -// #[test] -// fn float_to_float() { -// assert_evals_to!("Num.toFloat 0.5", 0.5, f64); -// } - -// #[test] -// fn int_compare() { -// assert_evals_to!("Num.compare 0 1", RocOrder::Lt, RocOrder); -// assert_evals_to!("Num.compare 1 1", RocOrder::Eq, RocOrder); -// assert_evals_to!("Num.compare 1 0", RocOrder::Gt, RocOrder); -// } - -// #[test] -// fn float_compare() { -// assert_evals_to!("Num.compare 0.01 3.14", RocOrder::Lt, RocOrder); -// assert_evals_to!("Num.compare 3.14 3.14", RocOrder::Eq, RocOrder); -// assert_evals_to!("Num.compare 3.14 0.01", RocOrder::Gt, RocOrder); -// } - -// #[test] -// fn pow() { -// assert_evals_to!("Num.pow 2.0 2.0", 4.0, f64); -// } - -// #[test] -// fn ceiling() { -// assert_evals_to!("Num.ceiling 1.1", 2, i64); -// } - -// #[test] -// fn floor() { -// assert_evals_to!("Num.floor 1.9", 1, i64); -// } - -// // #[test] -// // #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] -// // fn int_overflow() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // 9_223_372_036_854_775_807 + 1 -// // "# -// // ), -// // 0, -// // i64 -// // ); -// // } - -// #[test] -// fn int_add_checked() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1 2 is -// Ok v -> v -// _ -> -1 -// "# -// ), -// 3, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 9_223_372_036_854_775_807 1 is -// Err Overflow -> -1 -// Ok v -> v -// "# -// ), -// -1, -// i64 -// ); -// } - -// #[test] -// fn int_add_wrap() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.addWrap 9_223_372_036_854_775_807 1 -// "# -// ), -// std::i64::MIN, -// i64 -// ); -// } - -// #[test] -// fn float_add_checked_pass() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1.0 0.0 is -// Ok v -> v -// Err Overflow -> -1.0 -// "# -// ), -// 1.0, -// f64 -// ); -// } - -// #[test] -// fn float_add_checked_fail() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1.7976931348623157e308 1.7976931348623157e308 is -// Err Overflow -> -1 -// Ok v -> v -// "# -// ), -// -1.0, -// f64 -// ); -// } - -// // #[test] -// // #[should_panic(expected = r#"Roc failed with message: "float addition overflowed!"#)] -// // fn float_overflow() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // 1.7976931348623157e308 + 1.7976931348623157e308 -// // "# -// // ), -// // 0.0, -// // f64 -// // ); -// // } - -// #[test] -// fn max_i128() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.maxI128 -// "# -// ), -// i128::MAX, -// i128 -// ); -// } - -// #[test] -// fn num_max_int() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.maxInt -// "# -// ), -// i64::MAX, -// i64 -// ); -// } - -// #[test] -// fn num_min_int() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.minInt -// "# -// ), -// i64::MIN, -// i64 -// ); -// } diff --git a/compiler/test_dev/src/dev_records.rs b/compiler/test_dev/src/dev_records.rs deleted file mode 100644 index cdf5cb07ff..0000000000 --- a/compiler/test_dev/src/dev_records.rs +++ /dev/null @@ -1,933 +0,0 @@ -#![cfg(all(test, any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] - -use crate::assert_evals_to; -use indoc::indoc; - -#[test] -fn basic_record() { - assert_evals_to!( - indoc!( - r#" - { y: 17, x: 15, z: 19 }.x - "# - ), - 15, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: 17, z: 19 }.y - "# - ), - 17, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: 17, z: 19 }.z - "# - ), - 19, - i64 - ); -} - -#[test] -fn nested_record() { - assert_evals_to!( - indoc!( - r#" - { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.x - "# - ), - 15, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.a - "# - ), - 12, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.b - "# - ), - 15, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.c - "# - ), - 2, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.z - "# - ), - 19, - i64 - ); -} - -#[test] -fn f64_record() { - assert_evals_to!( - indoc!( - r#" - rec = { y: 17.2, x: 15.1, z: 19.3 } - - rec.x - "# - ), - 15.1, - f64 - ); - - assert_evals_to!( - indoc!( - r#" - rec = { y: 17.2, x: 15.1, z: 19.3 } - - rec.y - "# - ), - 17.2, - f64 - ); - - assert_evals_to!( - indoc!( - r#" - rec = { y: 17.2, x: 15.1, z: 19.3 } - - rec.z - "# - ), - 19.3, - f64 - ); -} - -// #[test] -// fn fn_record() { -// assert_evals_to!( -// indoc!( -// r#" -// getRec = \x -> { y: 17, x, z: 19 } - -// (getRec 15).x -// "# -// ), -// 15, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.y -// "# -// ), -// 17, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.z -// "# -// ), -// 19, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.z + rec.x -// "# -// ), -// 34, -// i64 -// ); -// } - -#[test] -fn def_record() { - assert_evals_to!( - indoc!( - r#" - rec = { y: 17, x: 15, z: 19 } - - rec.x - "# - ), - 15, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - rec = { x: 15, y: 17, z: 19 } - - rec.y - "# - ), - 17, - i64 - ); - - assert_evals_to!( - indoc!( - r#" - rec = { x: 15, y: 17, z: 19 } - - rec.z - "# - ), - 19, - i64 - ); -} - -#[test] -fn when_on_record() { - assert_evals_to!( - indoc!( - r#" - when { x: 0x2 } is - { x } -> x + 3 - "# - ), - 5, - i64 - ); -} - -#[test] -fn when_record_with_guard_pattern() { - assert_evals_to!( - indoc!( - r#" - when { x: 0x2, y: 3.14 } is - { x: var } -> var + 3 - "# - ), - 5, - i64 - ); -} - -#[test] -fn let_with_record_pattern() { - assert_evals_to!( - indoc!( - r#" - { x } = { x: 0x2, y: 3.14 } - - x - "# - ), - 2, - i64 - ); -} - -#[test] -fn record_guard_pattern() { - assert_evals_to!( - indoc!( - r#" - when { x: 0x2, y: 3.14 } is - { x: 0x4 } -> 5 - { x } -> x + 3 - "# - ), - 5, - i64 - ); -} - -#[test] -fn twice_record_access() { - assert_evals_to!( - indoc!( - r#" - x = {a: 0x2, b: 0x3 } - - x.a + x.b - "# - ), - 5, - i64 - ); -} -#[test] -fn empty_record() { - assert_evals_to!( - indoc!( - r#" - v = {} - - v - "# - ), - (), - () - ); -} - -#[test] -fn i64_record1_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3 } - "# - ), - 3, - i64 - ); -} - -// #[test] -// fn i64_record2_literal() { -// assert_evals_to!( -// indoc!( -// r#" -// { x: 3, y: 5 } -// "# -// ), -// (3, 5), -// (i64, i64) -// ); -// } - -// // #[test] -// // fn i64_record3_literal() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // { x: 3, y: 5, z: 17 } -// // "# -// // ), -// // (3, 5, 17), -// // (i64, i64, i64) -// // ); -// // } - -// #[test] -// fn f64_record2_literal() { -// assert_evals_to!( -// indoc!( -// r#" -// { x: 3.1, y: 5.1 } -// "# -// ), -// (3.1, 5.1), -// (f64, f64) -// ); -// } - -// // #[test] -// // fn f64_record3_literal() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // { x: 3.1, y: 5.1, z: 17.1 } -// // "# -// // ), -// // (3.1, 5.1, 17.1), -// // (f64, f64, f64) -// // ); -// // } - -// // #[test] -// // fn bool_record4_literal() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // record : { a : Bool, b : Bool, c : Bool, d : Bool } -// // record = { a: True, b: True, c : True, d : Bool } - -// // record -// // "# -// // ), -// // (true, false, false, true), -// // (bool, bool, bool, bool) -// // ); -// // } - -// #[test] -// fn i64_record1_literal() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3 } -// "# -// ), -// 3, -// i64 -// ); -// } - -// // #[test] -// // fn i64_record9_literal() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // { a: 3, b: 5, c: 17, d: 1, e: 9, f: 12, g: 13, h: 14, i: 15 } -// // "# -// // ), -// // (3, 5, 17, 1, 9, 12, 13, 14, 15), -// // (i64, i64, i64, i64, i64, i64, i64, i64, i64) -// // ); -// // } - -// // #[test] -// // fn f64_record3_literal() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // { x: 3.1, y: 5.1, z: 17.1 } -// // "# -// // ), -// // (3.1, 5.1, 17.1), -// // (f64, f64, f64) -// // ); -// // } - -// #[test] -// fn bool_literal() { -// assert_evals_to!( -// indoc!( -// r#" -// x : Bool -// x = True - -// x -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn optional_field_when_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// main = -// a = f { x: Blue, y: 7 } -// b = f { x: Blue } -// c = f { x: Red, y: 11 } -// d = f { x: Red } - -// a * b * c * d -// "# -// ), -// 3 * 5 * 7 * 11, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// a = f { x: Blue, y: 7 } -// b = f { x: Blue } -// c = f { x: Red, y: 11 } -// d = f { x: Red } - -// a * b * c * d -// "# -// ), -// 3 * 5 * 7 * 11, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_no_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_no_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// { x ? 10, y } = r -// x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { y: 9 } -// "# -// ), -// 19, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_no_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_no_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// { x ? 10, y } = r -// x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_function_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \{ x ? 10, y } -> x + y - -// f { y: 9 } -// "# -// ), -// 19, -// i64 -// ); -// } - -// #[test] -// #[ignore] -// fn optional_field_function_no_use_default() { -// // blocked on https://github.com/rtfeldman/roc/issues/786 -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \{ x ? 10, y } -> x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// #[ignore] -// fn optional_field_function_no_use_default_nested() { -// // blocked on https://github.com/rtfeldman/roc/issues/786 -// assert_evals_to!( -// indoc!( -// r#" -// f = \{ x ? 10, y } -> x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_singleton_record() { -// assert_evals_to!( -// indoc!( -// r#" -// when { x : 4 } is -// { x ? 3 } -> x -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn optional_field_empty_record() { -// assert_evals_to!( -// indoc!( -// r#" -// when { } is -// { x ? 3 } -> x -// "# -// ), -// 3, -// i64 -// ); -// } - -// #[test] -// fn return_record_2() { -// assert_evals_to!( -// indoc!( -// r#" -// { x: 3, y: 5 } -// "# -// ), -// [3, 5], -// [i64; 2] -// ); -// } - -// #[test] -// fn return_record_3() { -// assert_evals_to!( -// indoc!( -// r#" -// { x: 3, y: 5, z: 4 } -// "# -// ), -// (3, 5, 4), -// (i64, i64, i64) -// ); -// } - -// #[test] -// fn return_record_4() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3, b: 5, c: 4, d: 2 } -// "# -// ), -// [3, 5, 4, 2], -// [i64; 4] -// ); -// } - -// #[test] -// fn return_record_5() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3, b: 5, c: 4, d: 2, e: 1 } -// "# -// ), -// [3, 5, 4, 2, 1], -// [i64; 5] -// ); -// } - -// #[test] -// fn return_record_6() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3, b: 5, c: 4, d: 2, e: 1, f: 7 } -// "# -// ), -// [3, 5, 4, 2, 1, 7], -// [i64; 6] -// ); -// } - -// #[test] -// fn return_record_7() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3, b: 5, c: 4, d: 2, e: 1, f: 7, g: 8 } -// "# -// ), -// [3, 5, 4, 2, 1, 7, 8], -// [i64; 7] -// ); -// } - -// #[test] -// fn return_record_float_int() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 3.14, b: 0x1 } -// "# -// ), -// (3.14, 0x1), -// (f64, i64) -// ); -// } - -// #[test] -// fn return_record_int_float() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 0x1, b: 3.14 } -// "# -// ), -// (0x1, 3.14), -// (i64, f64) -// ); -// } - -// #[test] -// fn return_record_float_float() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 6.28, b: 3.14 } -// "# -// ), -// (6.28, 3.14), -// (f64, f64) -// ); -// } - -// #[test] -// fn return_record_float_float_float() { -// assert_evals_to!( -// indoc!( -// r#" -// { a: 6.28, b: 3.14, c: 0.1 } -// "# -// ), -// (6.28, 3.14, 0.1), -// (f64, f64, f64) -// ); -// } - -// #[test] -// fn return_nested_record() { -// assert_evals_to!( -// indoc!( -// r#" -// { flag: 0x0, payload: { a: 6.28, b: 3.14, c: 0.1 } } -// "# -// ), -// (0x0, (6.28, 3.14, 0.1)), -// (i64, (f64, f64, f64)) -// ); -// } - -// #[test] -// fn accessor() { -// assert_evals_to!( -// indoc!( -// r#" -// .foo { foo: 4 } + .foo { bar: 6.28, foo: 3 } -// "# -// ), -// 7, -// i64 -// ); -// } - -// #[test] -// fn accessor_single_element_record() { -// assert_evals_to!( -// indoc!( -// r#" -// .foo { foo: 4 } -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn update_record() { -// assert_evals_to!( -// indoc!( -// r#" -// rec = { foo: 42, bar: 6 } - -// { rec & foo: rec.foo + 1 } -// "# -// ), -// (6, 43), -// (i64, i64) -// ); -// } - -#[test] -fn update_single_element_record() { - assert_evals_to!( - indoc!( - r#" - rec = { foo: 42} - - { rec & foo: rec.foo + 1 } - "# - ), - 43, - i64 - ); -} - -// #[test] -// fn booleans_in_record() { -// assert_evals_to!( -// indoc!("{ x: 1 == 1, y: 1 == 1 }"), -// (true, true), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 != 1, y: 1 == 1 }"), -// (false, true), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 == 1, y: 1 != 1 }"), -// (true, false), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 != 1, y: 1 != 1 }"), -// (false, false), -// (bool, bool) -// ); -// } - -// #[test] -// fn alignment_in_record() { -// assert_evals_to!( -// indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"), -// (32i64, true, 2u8), -// (i64, bool, u8) -// ); -// } - -// #[test] -// fn blue_and_present() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// f { x: Blue, y: 7 } -// "# -// ), -// 7, -// i64 -// ); -// } - -// #[test] -// fn blue_and_absent() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// f { x: Blue } -// "# -// ), -// 3, -// i64 -// ); -// } diff --git a/compiler/test_dev/src/dev_str.rs b/compiler/test_dev/src/dev_str.rs deleted file mode 100644 index 4002546dc2..0000000000 --- a/compiler/test_dev/src/dev_str.rs +++ /dev/null @@ -1,950 +0,0 @@ -#![cfg(all(test, any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] - -//use indoc::indoc; -use crate::assert_evals_to; - -// use roc_std::{RocList, RocStr}; -// #[test] -// fn str_split_bigger_delimiter_small_str() { -// assert_evals_to!( -// indoc!( -// r#" -// List.len (Str.split "hello" "JJJJ there") -// "# -// ), -// 1, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// when List.first (Str.split "JJJ" "JJJJ there") is -// Ok str -> -// Str.countGraphemes str - -// _ -> -// -1 - -// "# -// ), -// 3, -// i64 -// ); -// } - -// #[test] -// fn str_split_str_concat_repeated() { -// assert_evals_to!( -// indoc!( -// r#" -// when List.first (Str.split "JJJJJ" "JJJJ there") is -// Ok str -> -// str -// |> Str.concat str -// |> Str.concat str -// |> Str.concat str -// |> Str.concat str - -// _ -> -// "Not Str!" - -// "# -// ), -// RocStr::from_slice(b"JJJJJJJJJJJJJJJJJJJJJJJJJ"), -// RocStr -// ); -// } - -// #[test] -// fn str_split_small_str_bigger_delimiter() { -// assert_evals_to!( -// indoc!( -// r#" -// when -// List.first -// (Str.split "JJJ" "0123456789abcdefghi") -// is -// Ok str -> str -// _ -> "" -// "# -// ), -// RocStr::from_slice(b"JJJ"), -// RocStr -// ); -// } - -// #[test] -// fn str_split_big_str_small_delimiter() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split "01234567789abcdefghi?01234567789abcdefghi" "?" -// "# -// ), -// RocList::from_slice(&[ -// RocStr::from_slice(b"01234567789abcdefghi"), -// RocStr::from_slice(b"01234567789abcdefghi") -// ]), -// RocList -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// Str.split "01234567789abcdefghi 3ch 01234567789abcdefghi" "3ch" -// "# -// ), -// RocList::from_slice(&[ -// RocStr::from_slice(b"01234567789abcdefghi "), -// RocStr::from_slice(b" 01234567789abcdefghi") -// ]), -// RocList -// ); -// } - -// #[test] -// fn str_split_small_str_small_delimiter() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split "J!J!J" "!" -// "# -// ), -// RocList::from_slice(&[ -// RocStr::from_slice(b"J"), -// RocStr::from_slice(b"J"), -// RocStr::from_slice(b"J") -// ]), -// RocList -// ); -// } - -// #[test] -// fn str_split_bigger_delimiter_big_strs() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split -// "string to split is shorter" -// "than the delimiter which happens to be very very long" -// "# -// ), -// RocList::from_slice(&[RocStr::from_slice(b"string to split is shorter")]), -// RocList -// ); -// } - -// #[test] -// fn str_split_empty_strs() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split "" "" -// "# -// ), -// RocList::from_slice(&[RocStr::from_slice(b"")]), -// RocList -// ); -// } - -// #[test] -// fn str_split_minimal_example() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split "a," "," -// "# -// ), -// RocList::from_slice(&[RocStr::from_slice(b"a"), RocStr::from_slice(b"")]), -// RocList -// ) -// } - -// #[test] -// fn str_split_small_str_big_delimiter() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split -// "1---- ---- ---- ---- ----2---- ---- ---- ---- ----" -// "---- ---- ---- ---- ----" -// |> List.len -// "# -// ), -// 3, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// Str.split -// "1---- ---- ---- ---- ----2---- ---- ---- ---- ----" -// "---- ---- ---- ---- ----" -// "# -// ), -// RocList::from_slice(&[ -// RocStr::from_slice(b"1"), -// RocStr::from_slice(b"2"), -// RocStr::from_slice(b"") -// ]), -// RocList -// ); -// } - -// #[test] -// fn str_split_small_str_20_char_delimiter() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.split -// "3|-- -- -- -- -- -- |4|-- -- -- -- -- -- |" -// "|-- -- -- -- -- -- |" -// "# -// ), -// RocList::from_slice(&[ -// RocStr::from_slice(b"3"), -// RocStr::from_slice(b"4"), -// RocStr::from_slice(b"") -// ]), -// RocList -// ); -// } - -// #[test] -// fn str_concat_big_to_big() { -// assert_evals_to!( -// indoc!( -// r#" -// Str.concat -// "First string that is fairly long. Longer strings make for different errors. " -// "Second string that is also fairly long. Two long strings test things that might not appear with short strings." -// "# -// ), -// RocStr::from_slice(b"First string that is fairly long. Longer strings make for different errors. Second string that is also fairly long. Two long strings test things that might not appear with short strings."), -// RocStr -// ); -// } - -#[test] -fn small_str_literal() { - assert_evals_to!( - "\"JJJJJJJJJJJJJJJ\"", - [ - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0b1000_1111 - ], - [u8; 16] - ); -} - -// #[test] -// fn small_str_zeroed_literal() { -// // Verifies that we zero out unused bytes in the string. -// // This is important so that string equality tests don't randomly -// // fail due to unused memory being there! -// assert_evals_to!( -// "\"J\"", -// [ -// 0x4a, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0x00, -// 0b1000_0001 -// ], -// [u8; 16] -// ); -// } - -#[test] -fn small_str_concat_empty_first_arg() { - assert_evals_to!( - r#"Str.concat "" "JJJJJJJJJJJJJJJ""#, - [ - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0b1000_1111 - ], - [u8; 16] - ); -} - -#[test] -fn small_str_concat_empty_second_arg() { - assert_evals_to!( - r#"Str.concat "JJJJJJJJJJJJJJJ" """#, - [ - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0b1000_1111 - ], - [u8; 16] - ); -} - -// #[test] -// fn small_str_concat_small_to_big() { -// assert_evals_to!( -// r#"Str.concat "abc" " this is longer than 15 chars""#, -// RocStr::from_slice(b"abc this is longer than 15 chars"), -// RocStr -// ); -// } - -#[test] -fn small_str_concat_small_to_small_staying_small() { - assert_evals_to!( - r#"Str.concat "J" "JJJJJJJJJJJJJJ""#, - [ - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0x4a, - 0b1000_1111 - ], - [u8; 16] - ); -} - -// #[test] -// fn small_str_concat_small_to_small_overflow_to_big() { -// assert_evals_to!( -// r#"Str.concat "abcdefghijklm" "nopqrstuvwxyz""#, -// RocStr::from_slice(b"abcdefghijklmnopqrstuvwxyz"), -// RocStr -// ); -// } - -// #[test] -// fn str_concat_empty() { -// assert_evals_to!(r#"Str.concat "" """#, RocStr::default(), RocStr); -// } - -// #[test] -// fn small_str_is_empty() { -// assert_evals_to!(r#"Str.isEmpty "abc""#, false, bool); -// } - -// #[test] -// fn big_str_is_empty() { -// assert_evals_to!( -// r#"Str.isEmpty "this is more than 15 chars long""#, -// false, -// bool -// ); -// } - -// #[test] -// fn empty_str_is_empty() { -// assert_evals_to!(r#"Str.isEmpty """#, true, bool); -// } - -// #[test] -// fn str_starts_with() { -// assert_evals_to!(r#"Str.startsWith "hello world" "hell""#, true, bool); -// assert_evals_to!(r#"Str.startsWith "hello world" """#, true, bool); -// assert_evals_to!(r#"Str.startsWith "nope" "hello world""#, false, bool); -// assert_evals_to!(r#"Str.startsWith "hell" "hello world""#, false, bool); -// assert_evals_to!(r#"Str.startsWith "" "hello world""#, false, bool); -// } - -// #[test] -// fn str_starts_with_code_point() { -// assert_evals_to!( -// &format!(r#"Str.startsWithCodePt "foobar" {}"#, 'f' as u32), -// true, -// bool -// ); -// assert_evals_to!( -// &format!(r#"Str.startsWithCodePt "zoobar" {}"#, 'f' as u32), -// false, -// bool -// ); -// } - -// #[test] -// fn str_ends_with() { -// assert_evals_to!(r#"Str.endsWith "hello world" "world""#, true, bool); -// assert_evals_to!(r#"Str.endsWith "nope" "hello world""#, false, bool); -// assert_evals_to!(r#"Str.endsWith "" "hello world""#, false, bool); -// } - -// #[test] -// fn str_count_graphemes_small_str() { -// assert_evals_to!(r#"Str.countGraphemes "å🤔""#, 2, usize); -// } - -// #[test] -// fn str_count_graphemes_three_js() { -// assert_evals_to!(r#"Str.countGraphemes "JJJ""#, 3, usize); -// } - -// #[test] -// fn str_count_graphemes_big_str() { -// assert_evals_to!( -// r#"Str.countGraphemes "6🤔å🤔e¥🤔çppkd🙃1jdal🦯asdfa∆ltråø˚waia8918.,🏅jjc""#, -// 45, -// usize -// ); -// } - -// #[test] -// fn str_starts_with_same_big_str() { -// assert_evals_to!( -// r#"Str.startsWith "123456789123456789" "123456789123456789""#, -// true, -// bool -// ); -// } - -// #[test] -// fn str_starts_with_different_big_str() { -// assert_evals_to!( -// r#"Str.startsWith "12345678912345678910" "123456789123456789""#, -// true, -// bool -// ); -// } - -// #[test] -// fn str_starts_with_same_small_str() { -// assert_evals_to!(r#"Str.startsWith "1234" "1234""#, true, bool); -// } - -// #[test] -// fn str_starts_with_different_small_str() { -// assert_evals_to!(r#"Str.startsWith "1234" "12""#, true, bool); -// } -// #[test] -// fn str_starts_with_false_small_str() { -// assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool); -// } - -// #[test] -// fn str_from_int() { -// assert_evals_to!( -// r#"Str.fromInt 1234"#, -// roc_std::RocStr::from_slice("1234".as_bytes()), -// roc_std::RocStr -// ); -// assert_evals_to!( -// r#"Str.fromInt 0"#, -// roc_std::RocStr::from_slice("0".as_bytes()), -// roc_std::RocStr -// ); -// assert_evals_to!( -// r#"Str.fromInt -1"#, -// roc_std::RocStr::from_slice("-1".as_bytes()), -// roc_std::RocStr -// ); - -// let max = format!("{}", i64::MAX); -// assert_evals_to!( -// r#"Str.fromInt Num.maxInt"#, -// RocStr::from_slice(max.as_bytes()), -// RocStr -// ); - -// let min = format!("{}", i64::MIN); -// assert_evals_to!( -// r#"Str.fromInt Num.minInt"#, -// RocStr::from_slice(min.as_bytes()), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_single_ascii() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97 ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_many_ascii() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 98, 99, 0x7E ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("abc~".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_single_unicode() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 0xE2, 0x88, 0x86 ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("∆".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_many_unicode() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 0xE2, 0x88, 0x86, 0xC5, 0x93, 0xC2, 0xAC ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("∆œ¬".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_single_grapheme() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 0xF0, 0x9F, 0x92, 0x96 ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("💖".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_many_grapheme() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 0xF0, 0x9F, 0x92, 0x96, 0xF0, 0x9F, 0xA4, 0xA0, 0xF0, 0x9F, 0x9A, 0x80 ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("💖🤠🚀".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_pass_all() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 0xF0, 0x9F, 0x92, 0x96, 98, 0xE2, 0x88, 0x86 ] is -// Ok val -> val -// Err _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("💖b∆".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_invalid_start_byte() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 98, 0x80, 99 ] is -// Err (BadUtf8 InvalidStartByte byteIndex) -> -// if byteIndex == 2 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_unexpected_end_of_sequence() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 98, 99, 0xC2 ] is -// Err (BadUtf8 UnexpectedEndOfSequence byteIndex) -> -// if byteIndex == 3 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_expected_continuation() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 98, 99, 0xC2, 0x00 ] is -// Err (BadUtf8 ExpectedContinuation byteIndex) -> -// if byteIndex == 3 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_overlong_encoding() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 0xF0, 0x80, 0x80, 0x80 ] is -// Err (BadUtf8 OverlongEncoding byteIndex) -> -// if byteIndex == 1 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_codepoint_too_large() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 0xF4, 0x90, 0x80, 0x80 ] is -// Err (BadUtf8 CodepointTooLarge byteIndex) -> -// if byteIndex == 1 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_fail_surrogate_half() { -// assert_evals_to!( -// indoc!( -// r#" -// when Str.fromUtf8 [ 97, 98, 0xED, 0xA0, 0x80 ] is -// Err (BadUtf8 EncodesSurrogateHalf byteIndex) -> -// if byteIndex == 2 then -// "a" -// else -// "b" -// _ -> "" -// "# -// ), -// roc_std::RocStr::from_slice("a".as_bytes()), -// roc_std::RocStr -// ); -// } - -// #[test] -// fn str_equality() { -// assert_evals_to!(r#""a" == "a""#, true, bool); -// assert_evals_to!( -// r#""loremipsumdolarsitamet" == "loremipsumdolarsitamet""#, -// true, -// bool -// ); -// assert_evals_to!(r#""a" != "b""#, true, bool); -// assert_evals_to!(r#""a" == "b""#, false, bool); -// } - -// #[test] -// fn str_clone() { -// use roc_std::RocStr; -// let long = RocStr::from_slice("loremipsumdolarsitamet".as_bytes()); -// let short = RocStr::from_slice("x".as_bytes()); -// let empty = RocStr::from_slice("".as_bytes()); - -// debug_assert_eq!(long.clone(), long); -// debug_assert_eq!(short.clone(), short); -// debug_assert_eq!(empty.clone(), empty); -// } - -// #[test] -// fn nested_recursive_literal() { -// assert_evals_to!( -// indoc!( -// r#" -// Expr : [ Add Expr Expr, Val I64, Var I64 ] - -// expr : Expr -// expr = Add (Add (Val 3) (Val 1)) (Add (Val 1) (Var 1)) - -// printExpr : Expr -> Str -// printExpr = \e -> -// when e is -// Add a b -> -// "Add (" -// |> Str.concat (printExpr a) -// |> Str.concat ") (" -// |> Str.concat (printExpr b) -// |> Str.concat ")" -// Val v -> "Val " |> Str.concat (Str.fromInt v) -// Var v -> "Var " |> Str.concat (Str.fromInt v) - -// printExpr expr -// "# -// ), -// RocStr::from_slice(b"Add (Add (Val 3) (Val 1)) (Add (Val 1) (Var 1))"), -// RocStr -// ); -// } - -// #[test] -// fn str_join_comma_small() { -// assert_evals_to!( -// r#"Str.joinWith ["1", "2"] ", " "#, -// RocStr::from("1, 2"), -// RocStr -// ); -// } - -// #[test] -// fn str_join_comma_big() { -// assert_evals_to!( -// r#"Str.joinWith ["10000000", "2000000", "30000000"] ", " "#, -// RocStr::from("10000000, 2000000, 30000000"), -// RocStr -// ); -// } - -// #[test] -// fn str_join_comma_single() { -// assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr); -// } - -// #[test] -// fn str_from_float() { -// assert_evals_to!(r#"Str.fromFloat 3.14"#, RocStr::from("3.14"), RocStr); -// } - -// #[test] -// fn str_to_utf8() { -// assert_evals_to!( -// r#"Str.toUtf8 "hello""#, -// RocList::from_slice(&[104, 101, 108, 108, 111]), -// RocList -// ); -// assert_evals_to!( -// r#"Str.toUtf8 "this is a long string""#, -// RocList::from_slice(&[ -// 116, 104, 105, 115, 32, 105, 115, 32, 97, 32, 108, 111, 110, 103, 32, 115, 116, -// 114, 105, 110, 103 -// ]), -// RocList -// ); -// } - -// #[test] -// fn str_from_utf8_range() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { count: 5, start: 0 } is -// Ok utf8String -> utf8String -// _ -> "" -// "# -// ), -// RocStr::from("hello"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_slice() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { count: 4, start: 1 } is -// Ok utf8String -> utf8String -// _ -> "" -// "# -// ), -// RocStr::from("ello"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_slice_not_end() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { count: 3, start: 1 } is -// Ok utf8String -> utf8String -// _ -> "" -// "# -// ), -// RocStr::from("ell"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_order_does_not_matter() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { start: 1, count: 3 } is -// Ok utf8String -> utf8String -// _ -> "" -// "# -// ), -// RocStr::from("ell"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_out_of_bounds_start_value() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { start: 7, count: 3 } is -// Ok _ -> "" -// Err (BadUtf8 _ _) -> "" -// Err OutOfBounds -> "out of bounds" -// "# -// ), -// RocStr::from("out of bounds"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_count_too_high() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { start: 0, count: 6 } is -// Ok _ -> "" -// Err (BadUtf8 _ _) -> "" -// Err OutOfBounds -> "out of bounds" -// "# -// ), -// RocStr::from("out of bounds"), -// RocStr -// ); -// } - -// #[test] -// fn str_from_utf8_range_count_too_high_for_start() { -// assert_evals_to!( -// indoc!( -// r#" -// bytes = Str.toUtf8 "hello" -// when Str.fromUtf8Range bytes { start: 4, count: 3 } is -// Ok _ -> "" -// Err (BadUtf8 _ _) -> "" -// Err OutOfBounds -> "out of bounds" -// "# -// ), -// RocStr::from("out of bounds"), -// RocStr -// ); -// } diff --git a/compiler/test_dev/src/helpers/mod.rs b/compiler/test_dev/src/helpers/mod.rs deleted file mode 100644 index 7e538193f7..0000000000 --- a/compiler/test_dev/src/helpers/mod.rs +++ /dev/null @@ -1,44 +0,0 @@ -extern crate bumpalo; - -#[macro_use] -pub mod eval; - -/// Used in the with_larger_debug_stack() function, for tests that otherwise -/// run out of stack space in debug builds (but don't in --release builds) -#[allow(dead_code)] -const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024; - -/// Without this, some tests pass in `cargo test --release` but fail without -/// the --release flag because they run out of stack space. This increases -/// stack size for debug builds only, while leaving the stack space at the default -/// amount for release builds. -#[allow(dead_code)] -#[cfg(debug_assertions)] -pub fn with_larger_debug_stack(run_test: F) -where - F: FnOnce(), - F: Send, - F: 'static, -{ - std::thread::Builder::new() - .stack_size(EXPANDED_STACK_SIZE) - .spawn(run_test) - .expect("Error while spawning expanded dev stack size thread") - .join() - .expect("Error while joining expanded dev stack size thread") -} - -/// In --release builds, don't increase the stack size. Run the test normally. -/// This way, we find out if any of our tests are blowing the stack even after -/// optimizations in release builds. -#[allow(dead_code)] -#[cfg(not(debug_assertions))] -#[inline(always)] -pub fn with_larger_debug_stack(run_test: F) -where - F: FnOnce() -> (), - F: Send, - F: 'static, -{ - run_test() -} diff --git a/compiler/test_dev/src/tests.rs b/compiler/test_dev/src/tests.rs deleted file mode 100644 index d7ecfccef7..0000000000 --- a/compiler/test_dev/src/tests.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod dev_num; -pub mod dev_records; -pub mod dev_str; -mod helpers; diff --git a/compiler/test_gen/Cargo.toml b/compiler/test_gen/Cargo.toml index 739b1247b5..ce94be492d 100644 --- a/compiler/test_gen/Cargo.toml +++ b/compiler/test_gen/Cargo.toml @@ -11,6 +11,8 @@ path = "src/tests.rs" [dev-dependencies] roc_gen_llvm = { path = "../gen_llvm" } +roc_gen_dev = { path = "../gen_dev" } +roc_gen_wasm = { path = "../gen_wasm" } roc_collections = { path = "../collections" } roc_region = { path = "../region" } roc_module = { path = "../module" } @@ -27,7 +29,6 @@ roc_can = { path = "../can" } roc_parse = { path = "../parse" } roc_build = { path = "../build" } roc_std = { path = "../../roc_std" } -test_wasm_util = { path = "../test_wasm_util" } im = "15.0.0" im-rc = "15.0.0" bumpalo = { version = "3.8.0", features = ["collections"] } @@ -42,5 +43,8 @@ tempfile = "3.2.0" indoc = "1.0.3" [features] -default = [] +default = ["gen-llvm"] +gen-llvm = [] +gen-dev = [] +gen-wasm = [] wasm-cli-run = [] diff --git a/compiler/test_gen/README.md b/compiler/test_gen/README.md new file mode 100644 index 0000000000..cbdb841cdd --- /dev/null +++ b/compiler/test_gen/README.md @@ -0,0 +1,28 @@ +# Running our CodeGen tests + +Our code generation tests are all in this crate. Feature flags are used to run the tests with a specific backend. For convenience, some aliases are added in `.cargo/config`: + +```toml +[alias] +test-gen-llvm = "test -p test_gen" +test-gen-dev = "test -p test_gen --no-default-features --features gen-dev" +test-gen-wasm = "test -p test_gen --no-default-features --features gen-wasm" +``` + +So we can run: + +``` +cargo test-gen-llvm +``` + +To run the gen tests with the LLVM backend. To filter tests, append a filter like so: + +``` +> cargo test-gen-wasm wasm_str::small + Finished test [unoptimized + debuginfo] target(s) in 0.13s + Running src/tests.rs (target/debug/deps/test_gen-b4ad63a9dd50f050) + +running 2 tests +test wasm_str::small_str_literal ... ok +test wasm_str::small_str_zeroed_literal ... ok +``` diff --git a/compiler/test_gen/src/gen_compare.rs b/compiler/test_gen/src/gen_compare.rs index f93026cdd4..e3f6845727 100644 --- a/compiler/test_gen/src/gen_compare.rs +++ b/compiler/test_gen/src/gen_compare.rs @@ -1,196 +1,218 @@ -#[cfg(test)] -mod gen_compare { - use crate::assert_evals_to; - // use crate::assert_wasm_evals_to as assert_evals_to; - use indoc::indoc; +#![cfg(not(feature = "gen-wasm"))] - #[test] - fn eq_i64() { - assert_evals_to!( - indoc!( - r#" +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; + +// use crate::assert_wasm_evals_to as assert_evals_to; +use indoc::indoc; + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn eq_i64() { + assert_evals_to!( + indoc!( + r#" i : I64 i = 1 i == i "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn neq_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn neq_i64() { + assert_evals_to!( + indoc!( + r#" i : I64 i = 1 i != i "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn eq_u64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn eq_u64() { + assert_evals_to!( + indoc!( + r#" i : U64 i = 1 i == i "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn neq_u64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn neq_u64() { + assert_evals_to!( + indoc!( + r#" i : U64 i = 1 i != i "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn eq_f64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_f64() { + assert_evals_to!( + indoc!( + r#" i : F64 i = 1 i == i "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn neq_f64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn neq_f64() { + assert_evals_to!( + indoc!( + r#" i : F64 i = 1 i != i "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn eq_bool_tag() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_bool_tag() { + assert_evals_to!( + indoc!( + r#" true : Bool true = True true == True "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn neq_bool_tag() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn neq_bool_tag() { + assert_evals_to!( + indoc!( + r#" true : Bool true = True true == False "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn empty_record() { - assert_evals_to!("{} == {}", true, bool); - assert_evals_to!("{} != {}", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn empty_record() { + assert_evals_to!("{} == {}", true, bool); + assert_evals_to!("{} != {}", false, bool); +} - #[test] - fn unit() { - assert_evals_to!("Unit == Unit", true, bool); - assert_evals_to!("Unit != Unit", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn unit() { + assert_evals_to!("Unit == Unit", true, bool); + assert_evals_to!("Unit != Unit", false, bool); +} - #[test] - fn newtype() { - assert_evals_to!("Identity 42 == Identity 42", true, bool); - assert_evals_to!("Identity 42 != Identity 42", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn newtype() { + assert_evals_to!("Identity 42 == Identity 42", true, bool); + assert_evals_to!("Identity 42 != Identity 42", false, bool); +} - #[test] - fn small_str() { - assert_evals_to!("\"aaa\" == \"aaa\"", true, bool); - assert_evals_to!("\"aaa\" == \"bbb\"", false, bool); - assert_evals_to!("\"aaa\" != \"aaa\"", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn small_str() { + assert_evals_to!("\"aaa\" == \"aaa\"", true, bool); + assert_evals_to!("\"aaa\" == \"bbb\"", false, bool); + assert_evals_to!("\"aaa\" != \"aaa\"", false, bool); +} - #[test] - fn large_str() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn large_str() { + assert_evals_to!( + indoc!( + r#" x = "Unicode can represent text values which span multiple languages" y = "Unicode can represent text values which span multiple languages" x == y "# - ), - true, - bool - ); + ), + true, + bool + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" x = "Unicode can represent text values which span multiple languages" y = "Here are some valid Roc strings" x != y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn eq_result_tag_true() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_result_tag_true() { + assert_evals_to!( + indoc!( + r#" x : Result I64 I64 x = Ok 1 @@ -199,17 +221,18 @@ mod gen_compare { x == y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn eq_result_tag_false() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_result_tag_false() { + assert_evals_to!( + indoc!( + r#" x : Result I64 I64 x = Ok 1 @@ -218,17 +241,18 @@ mod gen_compare { x == y "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn eq_expr() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_expr() { + assert_evals_to!( + indoc!( + r#" Expr : [ Add Expr Expr, Mul Expr Expr, Val I64, Var I64 ] x : Expr @@ -239,17 +263,18 @@ mod gen_compare { x == y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn eq_linked_list() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_linked_list() { + assert_evals_to!( + indoc!( + r#" LinkedList a : [ Nil, Cons a (LinkedList a) ] x : LinkedList I64 @@ -260,14 +285,14 @@ mod gen_compare { x == y "# - ), - true, - bool - ); + ), + true, + bool + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" LinkedList a : [ Nil, Cons a (LinkedList a) ] x : LinkedList I64 @@ -278,14 +303,14 @@ mod gen_compare { x == y "# - ), - true, - bool - ); + ), + true, + bool + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" LinkedList a : [ Nil, Cons a (LinkedList a) ] x : LinkedList I64 @@ -296,17 +321,18 @@ mod gen_compare { x == y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn eq_linked_list_false() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_linked_list_false() { + assert_evals_to!( + indoc!( + r#" LinkedList a : [ Nil, Cons a (LinkedList a) ] x : LinkedList I64 @@ -317,17 +343,18 @@ mod gen_compare { y == x "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn eq_nullable_expr() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_nullable_expr() { + assert_evals_to!( + indoc!( + r#" Expr : [ Add Expr Expr, Mul Expr Expr, Val I64, Empty ] x : Expr @@ -338,17 +365,18 @@ mod gen_compare { x != y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn eq_rosetree() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn eq_rosetree() { + assert_evals_to!( + indoc!( + r#" Rose a : [ Rose (List (Rose a)) ] x : Rose I64 @@ -359,14 +387,14 @@ mod gen_compare { x == y "# - ), - true, - bool - ); + ), + true, + bool + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" Rose a : [ Rose (List (Rose a)) ] x : Rose I64 @@ -377,20 +405,21 @@ mod gen_compare { x != y "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - #[ignore] - fn rosetree_with_tag() { - // currently stack overflows in type checking +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[ignore] +fn rosetree_with_tag() { + // currently stack overflows in type checking - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" Rose a : [ Rose (Result (List (Rose a)) I64) ] x : Rose I64 @@ -401,53 +430,60 @@ mod gen_compare { x == y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn list_eq_empty() { - assert_evals_to!("[] == []", true, bool); - assert_evals_to!("[] != []", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_eq_empty() { + assert_evals_to!("[] == []", true, bool); + assert_evals_to!("[] != []", false, bool); +} - #[test] - fn list_eq_by_length() { - assert_evals_to!("[1] == []", false, bool); - assert_evals_to!("[] == [1]", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_eq_by_length() { + assert_evals_to!("[1] == []", false, bool); + assert_evals_to!("[] == [1]", false, bool); +} - #[test] - fn list_eq_compare_pointwise() { - assert_evals_to!("[1] == [1]", true, bool); - assert_evals_to!("[2] == [1]", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_eq_compare_pointwise() { + assert_evals_to!("[1] == [1]", true, bool); + assert_evals_to!("[2] == [1]", false, bool); +} - #[test] - fn list_eq_nested() { - assert_evals_to!("[[1]] == [[1]]", true, bool); - assert_evals_to!("[[2]] == [[1]]", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_eq_nested() { + assert_evals_to!("[[1]] == [[1]]", true, bool); + assert_evals_to!("[[2]] == [[1]]", false, bool); +} - #[test] - fn list_neq_compare_pointwise() { - assert_evals_to!("[1] != [1]", false, bool); - assert_evals_to!("[2] != [1]", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_neq_compare_pointwise() { + assert_evals_to!("[1] != [1]", false, bool); + assert_evals_to!("[2] != [1]", true, bool); +} - #[test] - fn list_neq_nested() { - assert_evals_to!("[[1]] != [[1]]", false, bool); - assert_evals_to!("[[2]] != [[1]]", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn list_neq_nested() { + assert_evals_to!("[[1]] != [[1]]", false, bool); + assert_evals_to!("[[2]] != [[1]]", true, bool); +} - #[test] - fn compare_union_same_content() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn compare_union_same_content() { + assert_evals_to!( + indoc!( + r#" Foo : [ A I64, B I64 ] a : Foo @@ -458,17 +494,18 @@ mod gen_compare { a == b "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn compare_recursive_union_same_content() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn compare_recursive_union_same_content() { + assert_evals_to!( + indoc!( + r#" Expr : [ Add Expr Expr, Mul Expr Expr, Val1 I64, Val2 I64 ] v1 : Expr @@ -479,17 +516,18 @@ mod gen_compare { v1 == v2 "# - ), - false, - bool - ); - } + ), + false, + bool + ); +} - #[test] - fn compare_nullable_recursive_union_same_content() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn compare_nullable_recursive_union_same_content() { + assert_evals_to!( + indoc!( + r#" Expr : [ Add Expr Expr, Mul Expr Expr, Val1 I64, Val2 I64, Empty ] v1 : Expr @@ -500,9 +538,8 @@ mod gen_compare { v1 == v2 "# - ), - false, - bool - ); - } + ), + false, + bool + ); } diff --git a/compiler/test_gen/src/gen_dict.rs b/compiler/test_gen/src/gen_dict.rs index bb46b46ad8..d02d550c28 100644 --- a/compiler/test_gen/src/gen_dict.rs +++ b/compiler/test_gen/src/gen_dict.rs @@ -1,10 +1,19 @@ -#![cfg(test)] +#![cfg(feature = "gen-llvm")] + +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; use indoc::indoc; use roc_std::{RocList, RocStr}; #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_empty_len() { assert_evals_to!( indoc!( @@ -18,6 +27,7 @@ fn dict_empty_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_insert_empty() { assert_evals_to!( indoc!( @@ -32,6 +42,7 @@ fn dict_insert_empty() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_empty_contains() { assert_evals_to!( indoc!( @@ -48,6 +59,7 @@ fn dict_empty_contains() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_nonempty_contains() { assert_evals_to!( indoc!( @@ -64,6 +76,7 @@ fn dict_nonempty_contains() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_empty_remove() { assert_evals_to!( indoc!( @@ -82,6 +95,7 @@ fn dict_empty_remove() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_nonempty_remove() { assert_evals_to!( indoc!( @@ -100,6 +114,7 @@ fn dict_nonempty_remove() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn dict_nonempty_get() { assert_evals_to!( indoc!( @@ -142,6 +157,7 @@ fn dict_nonempty_get() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn keys() { assert_evals_to!( indoc!( @@ -163,6 +179,7 @@ fn keys() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn values() { assert_evals_to!( indoc!( @@ -184,6 +201,7 @@ fn values() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn from_list_with_fold() { assert_evals_to!( indoc!( @@ -226,6 +244,7 @@ fn from_list_with_fold() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn small_str_keys() { assert_evals_to!( indoc!( @@ -247,6 +266,7 @@ fn small_str_keys() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn big_str_keys() { assert_evals_to!( indoc!( @@ -272,6 +292,7 @@ fn big_str_keys() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn big_str_values() { assert_evals_to!( indoc!( @@ -296,6 +317,7 @@ fn big_str_values() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn unit_values() { assert_evals_to!( indoc!( @@ -317,6 +339,7 @@ fn unit_values() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn single() { assert_evals_to!( indoc!( @@ -334,6 +357,7 @@ fn single() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn union() { assert_evals_to!( indoc!( @@ -351,6 +375,7 @@ fn union() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn union_prefer_first() { assert_evals_to!( indoc!( @@ -368,6 +393,7 @@ fn union_prefer_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn intersection() { assert_evals_to!( indoc!( @@ -398,6 +424,7 @@ fn intersection() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn intersection_prefer_first() { assert_evals_to!( indoc!( @@ -428,6 +455,7 @@ fn intersection_prefer_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn difference() { assert_evals_to!( indoc!( @@ -458,6 +486,7 @@ fn difference() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn difference_prefer_first() { assert_evals_to!( indoc!( @@ -488,6 +517,7 @@ fn difference_prefer_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn walk_sum_keys() { assert_evals_to!( indoc!( diff --git a/compiler/test_gen/src/gen_list.rs b/compiler/test_gen/src/gen_list.rs index f340fdfd19..d8781221f6 100644 --- a/compiler/test_gen/src/gen_list.rs +++ b/compiler/test_gen/src/gen_list.rs @@ -1,63 +1,34 @@ -#![cfg(test)] +#![cfg(feature = "gen-llvm")] + +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; use crate::helpers::with_larger_debug_stack; //use crate::assert_wasm_evals_to as assert_evals_to; -use core::ffi::c_void; use indoc::indoc; use roc_std::{RocList, RocStr}; -#[no_mangle] -pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void { - libc::malloc(size) -} - -#[no_mangle] -pub unsafe fn roc_realloc( - c_ptr: *mut c_void, - new_size: usize, - _old_size: usize, - _alignment: u32, -) -> *mut c_void { - libc::realloc(c_ptr, new_size) -} - -#[no_mangle] -pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) { - libc::free(c_ptr) -} - -#[no_mangle] -pub unsafe fn roc_panic(c_ptr: *mut c_void, tag_id: u32) { - use roc_gen_llvm::llvm::build::PanicTagId; - - use std::convert::TryFrom; - use std::ffi::CStr; - use std::os::raw::c_char; - - match PanicTagId::try_from(tag_id) { - Ok(PanicTagId::NullTerminatedString) => { - let slice = CStr::from_ptr(c_ptr as *const c_char); - let string = slice.to_str().unwrap(); - eprintln!("Roc hit a panic: {}", string); - std::process::exit(1); - } - Err(_) => unreachable!(), - } -} - #[test] +#[cfg(any(feature = "gen-llvm"))] fn roc_list_construction() { let list = RocList::from_slice(&[1i64; 23]); assert_eq!(&list, &list); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_list_literal() { assert_evals_to!("[]", RocList::from_slice(&[]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_literal_empty_record() { assert_evals_to!("[{}]", RocList::from_slice(&[()]), RocList<()>); } @@ -68,6 +39,7 @@ fn int_singleton_list_literal() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn int_list_literal() { assert_evals_to!("[ 12, 9 ]", RocList::from_slice(&[12, 9]), RocList); assert_evals_to!( @@ -78,6 +50,7 @@ fn int_list_literal() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn bool_list_literal() { // NOTE: make sure to explicitly declare the elements to be of type bool, or // use both True and False; only using one of them causes the list to in practice be @@ -156,6 +129,7 @@ fn bool_list_literal() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn variously_sized_list_literals() { assert_evals_to!("[]", RocList::from_slice(&[]), RocList); assert_evals_to!("[1]", RocList::from_slice(&[1]), RocList); @@ -174,6 +148,7 @@ fn variously_sized_list_literals() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_append() { assert_evals_to!( "List.append [1] 2", @@ -188,6 +163,7 @@ fn list_append() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_take_first() { assert_evals_to!( "List.takeFirst [1, 2, 3] 2", @@ -212,6 +188,7 @@ fn list_take_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop() { assert_evals_to!( "List.drop [1,2,3] 2", @@ -223,6 +200,7 @@ fn list_drop() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop_at() { assert_evals_to!( "List.dropAt [1, 2, 3] 0", @@ -239,6 +217,7 @@ fn list_drop_at() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop_at_shared() { assert_evals_to!( indoc!( @@ -260,6 +239,7 @@ fn list_drop_at_shared() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop_last() { assert_evals_to!( "List.dropLast [1, 2, 3]", @@ -271,6 +251,7 @@ fn list_drop_last() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop_last_mutable() { assert_evals_to!( indoc!( @@ -292,6 +273,7 @@ fn list_drop_last_mutable() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_drop_first() { assert_evals_to!( "List.dropFirst [1, 2, 3]", @@ -303,6 +285,7 @@ fn list_drop_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_swap() { assert_evals_to!("List.swap [] 0 1", RocList::from_slice(&[]), RocList); assert_evals_to!( @@ -338,11 +321,13 @@ fn list_swap() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_append_to_empty_list() { assert_evals_to!("List.append [] 3", RocList::from_slice(&[3]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_append_to_empty_list_of_int() { assert_evals_to!( indoc!( @@ -360,6 +345,7 @@ fn list_append_to_empty_list_of_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_append_bools() { assert_evals_to!( "List.append [ True, False ] True", @@ -369,6 +355,7 @@ fn list_append_bools() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_append_longer_list() { assert_evals_to!( "List.append [ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ] 23", @@ -378,6 +365,7 @@ fn list_append_longer_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_prepend() { assert_evals_to!("List.prepend [] 1", RocList::from_slice(&[1]), RocList); assert_evals_to!( @@ -416,6 +404,7 @@ fn list_prepend() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_prepend_bools() { assert_evals_to!( "List.prepend [ True, False ] True", @@ -425,6 +414,7 @@ fn list_prepend_bools() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_prepend_big_list() { assert_evals_to!( "List.prepend [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 100, 100, 100, 100 ] 9", @@ -436,6 +426,7 @@ fn list_prepend_big_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_backwards_empty_all_inline() { assert_evals_to!( indoc!( @@ -463,6 +454,7 @@ fn list_walk_backwards_empty_all_inline() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_backwards_with_str() { assert_evals_to!( r#"List.walkBackwards [ "x", "y", "z" ] "<" Str.concat"#, @@ -478,6 +470,7 @@ fn list_walk_backwards_with_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_backwards_with_record() { assert_evals_to!( indoc!( @@ -505,6 +498,7 @@ fn list_walk_backwards_with_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_with_str() { assert_evals_to!( r#"List.walk [ "x", "y", "z" ] "<" Str.concat"#, @@ -520,11 +514,13 @@ fn list_walk_with_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_subtraction() { assert_evals_to!(r#"List.walk [ 1, 2 ] 1 Num.sub"#, (1 - 1) - 2, i64); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_until_sum() { assert_evals_to!( r#"List.walkUntil [ 1, 2 ] 0 \a,b -> Continue (a + b)"#, @@ -534,6 +530,7 @@ fn list_walk_until_sum() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_until_even_prefix_sum() { assert_evals_to!( r#" @@ -551,6 +548,7 @@ fn list_walk_until_even_prefix_sum() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_empty_list_of_int() { assert_evals_to!( indoc!( @@ -568,6 +566,7 @@ fn list_keep_if_empty_list_of_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_empty_list() { assert_evals_to!( indoc!( @@ -586,6 +585,7 @@ fn list_keep_if_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_always_true_for_non_empty_list() { assert_evals_to!( indoc!( @@ -607,6 +607,7 @@ fn list_keep_if_always_true_for_non_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_always_false_for_non_empty_list() { assert_evals_to!( indoc!( @@ -624,6 +625,7 @@ fn list_keep_if_always_false_for_non_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_one() { assert_evals_to!( indoc!( @@ -641,6 +643,7 @@ fn list_keep_if_one() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_if_str_is_hello() { assert_evals_to!( indoc!( @@ -657,6 +660,7 @@ fn list_keep_if_str_is_hello() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_on_empty_list_with_int_layout() { assert_evals_to!( indoc!( @@ -674,6 +678,7 @@ fn list_map_on_empty_list_with_int_layout() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_on_non_empty_list() { assert_evals_to!( indoc!( @@ -691,6 +696,7 @@ fn list_map_on_non_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_changes_input() { assert_evals_to!( indoc!( @@ -708,6 +714,7 @@ fn list_map_changes_input() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_on_big_list() { assert_evals_to!( indoc!( @@ -727,6 +734,7 @@ fn list_map_on_big_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_with_type_change() { assert_evals_to!( indoc!( @@ -745,6 +753,7 @@ fn list_map_with_type_change() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_using_defined_function() { assert_evals_to!( indoc!( @@ -766,6 +775,7 @@ fn list_map_using_defined_function() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_all_inline() { assert_evals_to!( indoc!( @@ -779,6 +789,7 @@ fn list_map_all_inline() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_closure() { assert_evals_to!( indoc!( @@ -799,6 +810,7 @@ fn list_map_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map4_group() { assert_evals_to!( indoc!( @@ -812,6 +824,7 @@ fn list_map4_group() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map4_different_length() { assert_evals_to!( indoc!( @@ -830,6 +843,7 @@ fn list_map4_different_length() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map3_group() { assert_evals_to!( indoc!( @@ -843,6 +857,7 @@ fn list_map3_group() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map3_different_length() { assert_evals_to!( indoc!( @@ -860,6 +875,7 @@ fn list_map3_different_length() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map2_pair() { assert_evals_to!( indoc!( @@ -874,6 +890,7 @@ fn list_map2_pair() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map2_different_lengths() { assert_evals_to!( indoc!( @@ -890,11 +907,13 @@ fn list_map2_different_lengths() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_empty_list() { assert_evals_to!("List.join []", RocList::from_slice(&[]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_one_list() { assert_evals_to!( "List.join [ [1, 2, 3 ] ]", @@ -904,6 +923,7 @@ fn list_join_one_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_two_non_empty_lists() { assert_evals_to!( "List.join [ [1, 2, 3 ] , [4 ,5, 6] ]", @@ -913,6 +933,7 @@ fn list_join_two_non_empty_lists() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_two_non_empty_lists_of_float() { assert_evals_to!( "List.join [ [ 1.2, 1.1 ], [ 2.1, 2.2 ] ]", @@ -922,6 +943,7 @@ fn list_join_two_non_empty_lists_of_float() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_to_big_list() { assert_evals_to!( indoc!( @@ -947,6 +969,7 @@ fn list_join_to_big_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_defined_empty_list() { assert_evals_to!( indoc!( @@ -964,6 +987,7 @@ fn list_join_defined_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_all_empty_lists() { assert_evals_to!( "List.join [ [], [], [] ]", @@ -973,6 +997,7 @@ fn list_join_all_empty_lists() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_one_empty_list() { assert_evals_to!( "List.join [ [ 1.2, 1.1 ], [] ]", @@ -982,12 +1007,14 @@ fn list_join_one_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_single() { assert_evals_to!("List.single 1", RocList::from_slice(&[1]), RocList); assert_evals_to!("List.single 5.6", RocList::from_slice(&[5.6]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_repeat() { assert_evals_to!( "List.repeat 5 1", @@ -1028,6 +1055,7 @@ fn list_repeat() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_reverse() { assert_evals_to!( "List.reverse [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]", @@ -1043,6 +1071,7 @@ fn list_reverse() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_reverse_empty_list_of_int() { assert_evals_to!( indoc!( @@ -1060,11 +1089,13 @@ fn list_reverse_empty_list_of_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_reverse_empty_list() { assert_evals_to!("List.reverse []", RocList::from_slice(&[]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn foobarbaz() { assert_evals_to!( indoc!( @@ -1086,11 +1117,13 @@ fn foobarbaz() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_two_empty_lists() { assert_evals_to!("List.concat [] []", RocList::from_slice(&[]), RocList); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_two_empty_lists_of_int() { assert_evals_to!( indoc!( @@ -1112,6 +1145,7 @@ fn list_concat_two_empty_lists_of_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_second_list_is_empty() { assert_evals_to!( "List.concat [ 12, 13 ] []", @@ -1126,6 +1160,7 @@ fn list_concat_second_list_is_empty() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_first_list_is_empty() { assert_evals_to!( "List.concat [] [ 23, 24 ]", @@ -1135,6 +1170,7 @@ fn list_concat_first_list_is_empty() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_two_non_empty_lists() { assert_evals_to!( "List.concat [1, 2 ] [ 3, 4 ]", @@ -1144,6 +1180,7 @@ fn list_concat_two_non_empty_lists() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_two_bigger_non_empty_lists() { assert_evals_to!( "List.concat [ 1.1, 2.2 ] [ 3.3, 4.4, 5.5 ]", @@ -1173,6 +1210,7 @@ fn assert_concat_worked(num_elems1: i64, num_elems2: i64) { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_empty_list() { assert_concat_worked(0, 0); assert_concat_worked(1, 0); @@ -1196,6 +1234,7 @@ fn list_concat_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_nonempty_lists() { assert_concat_worked(1, 1); assert_concat_worked(1, 2); @@ -1211,6 +1250,7 @@ fn list_concat_nonempty_lists() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_concat_large() { with_larger_debug_stack(|| { // these values produce mono ASTs so large that @@ -1223,16 +1263,19 @@ fn list_concat_large() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_list_len() { assert_evals_to!("List.len []", 0, usize); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn basic_int_list_len() { assert_evals_to!("List.len [ 12, 9, 6, 3 ]", 4, usize); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn loaded_int_list_len() { assert_evals_to!( indoc!( @@ -1248,6 +1291,7 @@ fn loaded_int_list_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn fn_int_list_len() { assert_evals_to!( indoc!( @@ -1265,16 +1309,19 @@ fn fn_int_list_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn int_list_is_empty() { assert_evals_to!("List.isEmpty [ 12, 9, 6, 3 ]", false, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_list_is_empty() { assert_evals_to!("List.isEmpty []", true, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn first_int_list() { assert_evals_to!( indoc!( @@ -1290,6 +1337,7 @@ fn first_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn first_wildcard_empty_list() { assert_evals_to!( @@ -1306,6 +1354,7 @@ fn first_wildcard_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn first_empty_list() { assert_evals_to!( indoc!( @@ -1321,6 +1370,7 @@ fn first_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn last_int_list() { assert_evals_to!( indoc!( @@ -1336,6 +1386,7 @@ fn last_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn last_wildcard_empty_list() { assert_evals_to!( @@ -1352,6 +1403,7 @@ fn last_wildcard_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn last_empty_list() { assert_evals_to!( indoc!( @@ -1367,6 +1419,7 @@ fn last_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn get_empty_list() { assert_evals_to!( indoc!( @@ -1382,6 +1435,7 @@ fn get_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn get_wildcard_empty_list() { assert_evals_to!( @@ -1398,6 +1452,7 @@ fn get_wildcard_empty_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn get_int_list_ok() { assert_evals_to!( indoc!( @@ -1413,6 +1468,7 @@ fn get_int_list_ok() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn get_int_list_oob() { assert_evals_to!( indoc!( @@ -1428,6 +1484,7 @@ fn get_int_list_oob() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn get_set_unique_int_list() { assert_evals_to!( indoc!( @@ -1443,6 +1500,7 @@ fn get_set_unique_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn set_unique_int_list() { assert_evals_to!( "List.set [ 12, 9, 7, 1, 5 ] 2 33", @@ -1452,6 +1510,7 @@ fn set_unique_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn set_unique_list_oob() { assert_evals_to!( "List.set [ 3, 17, 4.1 ] 1337 9.25", @@ -1461,6 +1520,7 @@ fn set_unique_list_oob() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn set_shared_int_list() { assert_evals_to!( indoc!( @@ -1488,6 +1548,7 @@ fn set_shared_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn set_shared_list_oob() { assert_evals_to!( indoc!( @@ -1514,6 +1575,7 @@ fn set_shared_list_oob() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn get_unique_int_list() { assert_evals_to!( indoc!( @@ -1531,6 +1593,7 @@ fn get_unique_int_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_wrap_len() { assert_evals_to!( indoc!( @@ -1547,6 +1610,7 @@ fn gen_wrap_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_wrap_first() { assert_evals_to!( indoc!( @@ -1563,6 +1627,7 @@ fn gen_wrap_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_duplicate() { assert_evals_to!( indoc!( @@ -1585,6 +1650,7 @@ fn gen_duplicate() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_swap() { assert_evals_to!( indoc!( @@ -1613,6 +1679,7 @@ fn gen_swap() { } // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn gen_partition() { // assert_evals_to!( // indoc!( @@ -1665,6 +1732,7 @@ fn gen_swap() { // } // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn gen_partition() { // assert_evals_to!( // indoc!( @@ -1702,8 +1770,8 @@ fn gen_swap() { // RocList // ); // } - #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_quicksort() { with_larger_debug_stack(|| { assert_evals_to!( @@ -1775,6 +1843,7 @@ fn gen_quicksort() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn foobar2() { with_larger_debug_stack(|| { assert_evals_to!( @@ -1848,6 +1917,7 @@ fn foobar2() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn foobar() { with_larger_debug_stack(|| { assert_evals_to!( @@ -1921,6 +1991,7 @@ fn foobar() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_list_increment_decrement() { assert_evals_to!( indoc!( @@ -1937,6 +2008,7 @@ fn empty_list_increment_decrement() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_literal_increment_decrement() { assert_evals_to!( indoc!( @@ -1953,6 +2025,7 @@ fn list_literal_increment_decrement() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_pass_to_function() { assert_evals_to!( indoc!( @@ -1972,6 +2045,7 @@ fn list_pass_to_function() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_pass_to_set() { assert_evals_to!( indoc!( @@ -1991,6 +2065,7 @@ fn list_pass_to_set() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_wrap_in_tag() { assert_evals_to!( indoc!( @@ -2008,6 +2083,7 @@ fn list_wrap_in_tag() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_contains() { assert_evals_to!(indoc!("List.contains [1,2,3] 1"), true, bool); @@ -2016,6 +2092,7 @@ fn list_contains() { assert_evals_to!(indoc!("List.contains [] 4"), false, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_min() { assert_evals_to!( indoc!( @@ -2042,6 +2119,7 @@ fn list_min() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_max() { assert_evals_to!( indoc!( @@ -2068,6 +2146,7 @@ fn list_max() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_sum() { assert_evals_to!("List.sum []", 0, i64); assert_evals_to!("List.sum [ 1, 2, 3 ]", 6, i64); @@ -2075,6 +2154,7 @@ fn list_sum() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_product() { assert_evals_to!("List.product []", 1, i64); assert_evals_to!("List.product [ 1, 2, 3 ]", 6, i64); @@ -2082,6 +2162,7 @@ fn list_product() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_oks() { assert_evals_to!("List.keepOks [] (\\x -> x)", 0, i64); assert_evals_to!( @@ -2102,6 +2183,7 @@ fn list_keep_oks() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_keep_errs() { assert_evals_to!("List.keepErrs [] (\\x -> x)", 0, i64); assert_evals_to!( @@ -2127,6 +2209,7 @@ fn list_keep_errs() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_map_with_index() { assert_evals_to!( "List.mapWithIndex [0,0,0] (\\index, x -> Num.intCast index + x)", @@ -2136,6 +2219,7 @@ fn list_map_with_index() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] fn cleanup_because_exception() { assert_evals_to!( @@ -2155,6 +2239,7 @@ fn cleanup_because_exception() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_range() { assert_evals_to!("List.range 0 -1", RocList::from_slice(&[]), RocList); assert_evals_to!("List.range 0 0", RocList::from_slice(&[0]), RocList); @@ -2166,6 +2251,7 @@ fn list_range() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_sort_with() { assert_evals_to!( "List.sortWith [] Num.compare", @@ -2185,6 +2271,7 @@ fn list_sort_with() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_any() { assert_evals_to!("List.any [] (\\e -> e > 3)", false, bool); assert_evals_to!("List.any [ 1, 2, 3 ] (\\e -> e > 3)", false, bool); @@ -2192,6 +2279,7 @@ fn list_any() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn list_any_empty_with_unknown_element_type() { // Segfaults with invalid memory reference. Running this as a stand-alone @@ -2204,6 +2292,7 @@ fn list_any_empty_with_unknown_element_type() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = r#"Roc failed with message: "invalid ret_layout""#)] fn lists_with_incompatible_type_param_in_if() { assert_evals_to!( @@ -2224,6 +2313,7 @@ fn lists_with_incompatible_type_param_in_if() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn map_with_index_multi_record() { // see https://github.com/rtfeldman/roc/issues/1700 assert_evals_to!( @@ -2238,6 +2328,7 @@ fn map_with_index_multi_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_list_of_function_type() { // see https://github.com/rtfeldman/roc/issues/1732 assert_evals_to!( @@ -2266,6 +2357,7 @@ fn empty_list_of_function_type() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_map() { assert_evals_to!( indoc!( @@ -2285,6 +2377,7 @@ fn list_join_map() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_join_map_empty() { assert_evals_to!( indoc!( @@ -2298,6 +2391,7 @@ fn list_join_map_empty() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_find() { assert_evals_to!( indoc!( @@ -2313,6 +2407,7 @@ fn list_find() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_find_not_found() { assert_evals_to!( indoc!( @@ -2328,6 +2423,7 @@ fn list_find_not_found() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_find_empty_typed_list() { assert_evals_to!( indoc!( @@ -2343,6 +2439,7 @@ fn list_find_empty_typed_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore = "Fails because monomorphization can't be done if we don't have a concrete element type!"] fn list_find_empty_layout() { assert_evals_to!( diff --git a/compiler/test_gen/src/gen_num.rs b/compiler/test_gen/src/gen_num.rs index 9d9d9e1390..aa68929547 100644 --- a/compiler/test_gen/src/gen_num.rs +++ b/compiler/test_gen/src/gen_num.rs @@ -1,46 +1,57 @@ -#[cfg(test)] -mod gen_num { - use crate::assert_evals_to; - // use crate::assert_wasm_evals_to as assert_evals_to; - use indoc::indoc; - use roc_std::{RocDec, RocOrder}; +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; - #[test] - fn nat_alias() { - assert_evals_to!( - indoc!( - r#" +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to; + +#[cfg(feature = "gen-wasm")] +use crate::helpers::wasm::assert_evals_to; + +// use crate::assert_wasm_evals_to as assert_evals_to; +#[allow(unused_imports)] +use indoc::indoc; +#[allow(unused_imports)] +use roc_std::{RocDec, RocOrder}; + +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn nat_alias() { + assert_evals_to!( + indoc!( + r#" i : Nat i = 1 i "# - ), - 1, - usize - ); - } + ), + 1, + usize + ); +} - #[test] - fn i128_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn i128_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : I128 i = 128 i "# - ), - 128, - i128 - ); - } - #[test] - fn i64_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 128, + i128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i64_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" app "test" provides [ main ] to "./platform" main = @@ -49,489 +60,522 @@ mod gen_num { i "# - ), - 64, - i64 - ); - } - #[test] - fn i32_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 64, + i64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i32_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : I32 i = 32 i "# - ), - 32, - i32 - ); - } - #[test] - fn i16_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 32, + i32 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i16_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : I16 i = 16 i "# - ), - 16, - i16 - ); - } - #[test] - fn i8_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 16, + i16 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i8_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : I8 i = 8 i "# - ), - 8, - i8 - ); - } + ), + 8, + i8 + ); +} - #[test] - fn i128_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn i128_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : I128 f = 0x123 f "# - ), - 0x123, - i128 - ); - } - #[test] - fn i64_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + i128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i64_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : I64 f = 0x123 f "# - ), - 0x123, - i64 - ); - } - #[test] - fn i32_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + i64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i32_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : I32 f = 0x123 f "# - ), - 0x123, - i32 - ); - } - #[test] - fn i16_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + i32 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i16_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : I16 f = 0x123 f "# - ), - 0x123, - i16 - ); - } - #[test] - fn i8_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + i16 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn i8_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : I8 f = 0xA f "# - ), - 0xA, - i8 - ); - } + ), + 0xA, + i8 + ); +} - #[test] - fn u128_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn u128_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : U128 i = 128 i "# - ), - 128, - u128 - ); - } - #[test] - fn u64_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 128, + u128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u64_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : U64 i = 64 i "# - ), - 64, - u64 - ); - } - #[test] - fn u32_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 64, + u64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u32_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : U32 i = 32 i "# - ), - 32, - u32 - ); - } - #[test] - fn u16_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 32, + u32 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u16_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : U16 i = 16 i "# - ), - 16, - u16 - ); - } - #[test] - fn u8_signed_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 16, + u16 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u8_signed_int_alias() { + assert_evals_to!( + indoc!( + r#" i : U8 i = 8 i "# - ), - 8, - u8 - ); - } + ), + 8, + u8 + ); +} - #[test] - fn u128_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn u128_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : U128 f = 0x123 f "# - ), - 0x123, - i128 - ); - } - #[test] - fn u64_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + i128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u64_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : U64 f = 0x123 f "# - ), - 0x123, - u64 - ); - } - #[test] - fn u32_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + u64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u32_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : U32 f = 0x123 f "# - ), - 0x123, - u32 - ); - } - #[test] - fn u16_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + u32 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u16_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : U16 f = 0x123 f "# - ), - 0x123, - u16 - ); - } - #[test] - fn u8_hex_int_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 0x123, + u16 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn u8_hex_int_alias() { + assert_evals_to!( + indoc!( + r#" f : U8 f = 0xA f "# - ), - 0xA, - u8 - ); - } + ), + 0xA, + u8 + ); +} - #[test] - fn dec_float_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn dec_float_alias() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 2.1 x "# - ), - RocDec::from_str_to_i128_unsafe("2.1"), - i128 - ); - } + ), + RocDec::from_str_to_i128_unsafe("2.1"), + i128 + ); +} - #[test] - fn f64_float_alias() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn f64_float_alias() { + assert_evals_to!( + indoc!( + r#" f : F64 f = 3.6 f "# - ), - 3.6, - f64 - ); - } - #[test] - fn f32_float_alias() { - assert_evals_to!( - indoc!( - r#" + ), + 3.6, + f64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f32_float_alias() { + assert_evals_to!( + indoc!( + r#" f : F32 f = 3.6 f "# - ), - 3.6, - f32 - ); - } + ), + 3.6, + f32 + ); +} - #[test] - fn f64_sqrt() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_sqrt() { + assert_evals_to!( + indoc!( + r#" when Num.sqrt 100 is Ok val -> val Err _ -> -1 "# - ), - 10.0, - f64 - ); - } + ), + 10.0, + f64 + ); +} - #[test] - fn f64_log() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_log() { + assert_evals_to!( + indoc!( + r#" when Num.log 7.38905609893 is Ok val -> val Err _ -> -1 "# - ), - 1.999999999999912, - f64 - ); - } + ), + 1.999999999999912, + f64 + ); +} - #[test] - fn f64_log_one() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_log_one() { + assert_evals_to!( + indoc!( + r#" when Num.log 1 is Ok val -> val Err _ -> -1 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - fn f64_sqrt_zero() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_sqrt_zero() { + assert_evals_to!( + indoc!( + r#" when Num.sqrt 0 is Ok val -> val Err _ -> -1 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - fn f64_sqrt_negative() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_sqrt_negative() { + assert_evals_to!( + indoc!( + r#" when Num.sqrt -1 is Err _ -> 42 Ok val -> val "# - ), - 42.0, - f64 - ); - } + ), + 42.0, + f64 + ); +} - #[test] - fn f64_log_zero() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_log_zero() { + assert_evals_to!( + indoc!( + r#" when Num.log 0 is Err _ -> 42 Ok val -> val "# - ), - 42.0, - f64 - ); - } + ), + 42.0, + f64 + ); +} - #[test] - fn f64_log_negative() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn f64_log_negative() { + assert_evals_to!( + indoc!( + r#" when Num.log -1 is Err _ -> 42 Ok val -> val "# - ), - 42.0, - f64 - ); - } + ), + 42.0, + f64 + ); +} - #[test] - fn f64_round() { - assert_evals_to!("Num.round 3.6", 4, i64); - assert_evals_to!("Num.round 3.4", 3, i64); - assert_evals_to!("Num.round 2.5", 3, i64); - assert_evals_to!("Num.round -2.3", -2, i64); - assert_evals_to!("Num.round -2.5", -3, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn f64_round() { + assert_evals_to!("Num.round 3.6", 4, i64); + assert_evals_to!("Num.round 3.4", 3, i64); + assert_evals_to!("Num.round 2.5", 3, i64); + assert_evals_to!("Num.round -2.3", -2, i64); + assert_evals_to!("Num.round -2.5", -3, i64); +} - #[test] - fn f64_abs() { - assert_evals_to!("Num.abs -4.7", 4.7, f64); - assert_evals_to!("Num.abs 5.8", 5.8, f64); - //assert_evals_to!("Num.abs Num.maxFloat", f64::MAX, f64); - //assert_evals_to!("Num.abs Num.minFloat", -f64::MIN, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn f64_abs() { + assert_evals_to!("Num.abs -4.7", 4.7, f64); + assert_evals_to!("Num.abs 5.8", 5.8, f64); + //assert_evals_to!("Num.abs Num.maxFloat", f64::MAX, f64); + //assert_evals_to!("Num.abs Num.minFloat", -f64::MIN, f64); +} - #[test] - fn i64_abs() { - assert_evals_to!("Num.abs -6", 6, i64); - assert_evals_to!("Num.abs 7", 7, i64); - assert_evals_to!("Num.abs 0", 0, i64); - assert_evals_to!("Num.abs -0", 0, i64); - assert_evals_to!("Num.abs -1", 1, i64); - assert_evals_to!("Num.abs 1", 1, i64); - assert_evals_to!("Num.abs 9_000_000_000_000", 9_000_000_000_000, i64); - assert_evals_to!("Num.abs -9_000_000_000_000", 9_000_000_000_000, i64); - assert_evals_to!("Num.abs Num.maxInt", i64::MAX, i64); - assert_evals_to!("Num.abs (Num.minInt + 1)", -(i64::MIN + 1), i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn i64_abs() { + assert_evals_to!("Num.abs -6", 6, i64); + assert_evals_to!("Num.abs 7", 7, i64); + assert_evals_to!("Num.abs 0", 0, i64); + assert_evals_to!("Num.abs -0", 0, i64); + assert_evals_to!("Num.abs -1", 1, i64); + assert_evals_to!("Num.abs 1", 1, i64); + assert_evals_to!("Num.abs 9_000_000_000_000", 9_000_000_000_000, i64); + assert_evals_to!("Num.abs -9_000_000_000_000", 9_000_000_000_000, i64); + assert_evals_to!("Num.abs Num.maxInt", i64::MAX, i64); + assert_evals_to!("Num.abs (Num.minInt + 1)", -(i64::MIN + 1), i64); +} - #[test] - #[should_panic( - expected = r#"Roc failed with message: "integer absolute overflowed because its argument is the minimum value"# - )] - fn abs_min_int_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic( + expected = r#"Roc failed with message: "integer absolute overflowed because its argument is the minimum value"# +)] +fn abs_min_int_overflow() { + assert_evals_to!( + indoc!( + r#" Num.abs Num.minInt "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - fn gen_if_fn() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn gen_if_fn() { + assert_evals_to!( + indoc!( + r#" limitedNegate = \num -> x = if num == 1 then @@ -544,30 +588,32 @@ mod gen_num { limitedNegate 1 "# - ), - -1, - i64 - ); - } + ), + -1, + i64 + ); +} - #[test] - fn gen_float_eq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_float_eq() { + assert_evals_to!( + indoc!( + r#" 1.0 == 1.0 "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_add_dec() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_add_dec() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 2.1 @@ -579,59 +625,63 @@ mod gen_num { z "# - ), - RocDec::from_str_to_i128_unsafe("5.2"), - i128 - ); - } - #[test] - fn gen_add_f64() { - assert_evals_to!( - indoc!( - r#" + ), + RocDec::from_str_to_i128_unsafe("5.2"), + i128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_add_f64() { + assert_evals_to!( + indoc!( + r#" 1.1 + 2.4 + 3 "# - ), - 6.5, - f64 - ); - } + ), + 6.5, + f64 + ); +} - #[test] - fn gen_wrap_add_nums() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_wrap_add_nums() { + assert_evals_to!( + indoc!( + r#" add2 = \num1, num2 -> num1 + num2 add2 4 5 "# - ), - 9, - i64 - ); - } + ), + 9, + i64 + ); +} - #[test] - fn gen_div_f64() { - // FIXME this works with normal types, but fails when checking uniqueness types - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_div_f64() { + // FIXME this works with normal types, but fails when checking uniqueness types + assert_evals_to!( + indoc!( + r#" when 48 / 2 is Ok val -> val Err _ -> -1 "# - ), - 24.0, - f64 - ); - } - #[test] - fn gen_div_dec() { - assert_evals_to!( - indoc!( - r#" + ), + 24.0, + f64 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_div_dec() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 10 @@ -642,43 +692,46 @@ mod gen_num { Ok val -> val Err _ -> -1 "# - ), - RocDec::from_str_to_i128_unsafe("3.333333333333333333"), - i128 - ); - } + ), + RocDec::from_str_to_i128_unsafe("3.333333333333333333"), + i128 + ); +} - #[test] - fn gen_int_eq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn gen_int_eq() { + assert_evals_to!( + indoc!( + r#" 4 == 4 "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_int_neq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_int_neq() { + assert_evals_to!( + indoc!( + r#" 4 != 5 "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_dec_eq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_dec_eq() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 4 @@ -687,17 +740,18 @@ mod gen_num { x == y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_dec_neq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_dec_neq() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 4 @@ -706,47 +760,50 @@ mod gen_num { x != y "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_wrap_int_neq() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_wrap_int_neq() { + assert_evals_to!( + indoc!( + r#" wrappedNotEq : a, a -> Bool wrappedNotEq = \num1, num2 -> num1 != num2 wrappedNotEq 2 3 "# - ), - true, - bool - ); - } + ), + true, + bool + ); +} - #[test] - fn gen_add_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_add_i64() { + assert_evals_to!( + indoc!( + r#" 1 + 2 + 3 "# - ), - 6, - i64 - ); - } + ), + 6, + i64 + ); +} - #[test] - fn gen_sub_dec() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_sub_dec() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 1.5 @@ -758,43 +815,46 @@ mod gen_num { (x - y) - z "# - ), - RocDec::from_str_to_i128_unsafe("-3.9"), - i128 - ); - } + ), + RocDec::from_str_to_i128_unsafe("-3.9"), + i128 + ); +} - #[test] - fn gen_sub_f64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn gen_sub_f64() { + assert_evals_to!( + indoc!( + r#" 1.5 - 2.4 - 3 "# - ), - -3.9, - f64 - ); - } + ), + -3.9, + f64 + ); +} - #[test] - fn gen_sub_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_sub_i64() { + assert_evals_to!( + indoc!( + r#" 1 - 2 - 3 "# - ), - -4, - i64 - ); - } + ), + -4, + i64 + ); +} - #[test] - fn gen_mul_dec() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_mul_dec() { + assert_evals_to!( + indoc!( + r#" x : Dec x = 2 @@ -806,272 +866,302 @@ mod gen_num { x * y * z "# - ), - RocDec::from_str_to_i128_unsafe("48.0"), - i128 - ); - } - #[test] - fn gen_mul_i64() { - assert_evals_to!( - indoc!( - r#" + ), + RocDec::from_str_to_i128_unsafe("48.0"), + i128 + ); +} +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_mul_i64() { + assert_evals_to!( + indoc!( + r#" 2 * 4 * 6 "# - ), - 48, - i64 - ); - } + ), + 48, + i64 + ); +} - #[test] - fn gen_div_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_div_i64() { + assert_evals_to!( + indoc!( + r#" when 1000 // 10 is Ok val -> val Err _ -> -1 "# - ), - 100, - i64 - ); - } + ), + 100, + i64 + ); +} - #[test] - fn gen_div_by_zero_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_div_by_zero_i64() { + assert_evals_to!( + indoc!( + r#" when 1000 // 0 is Err DivByZero -> 99 _ -> -24 "# - ), - 99, - i64 - ); - } + ), + 99, + i64 + ); +} - #[test] - fn gen_rem_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_rem_i64() { + assert_evals_to!( + indoc!( + r#" when Num.rem 8 3 is Ok val -> val Err _ -> -1 "# - ), - 2, - i64 - ); - } + ), + 2, + i64 + ); +} - #[test] - fn gen_rem_div_by_zero_i64() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_rem_div_by_zero_i64() { + assert_evals_to!( + indoc!( + r#" when Num.rem 8 0 is Err DivByZero -> 4 Ok _ -> -23 "# - ), - 4, - i64 - ); - } + ), + 4, + i64 + ); +} - #[test] - fn gen_is_zero_i64() { - assert_evals_to!("Num.isZero 0", true, bool); - assert_evals_to!("Num.isZero 1", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_zero_i64() { + assert_evals_to!("Num.isZero 0", true, bool); + assert_evals_to!("Num.isZero 1", false, bool); +} - #[test] - fn gen_is_positive_i64() { - assert_evals_to!("Num.isPositive 0", false, bool); - assert_evals_to!("Num.isPositive 1", true, bool); - assert_evals_to!("Num.isPositive -5", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_positive_i64() { + assert_evals_to!("Num.isPositive 0", false, bool); + assert_evals_to!("Num.isPositive 1", true, bool); + assert_evals_to!("Num.isPositive -5", false, bool); +} - #[test] - fn gen_is_negative_i64() { - assert_evals_to!("Num.isNegative 0", false, bool); - assert_evals_to!("Num.isNegative 3", false, bool); - assert_evals_to!("Num.isNegative -2", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_negative_i64() { + assert_evals_to!("Num.isNegative 0", false, bool); + assert_evals_to!("Num.isNegative 3", false, bool); + assert_evals_to!("Num.isNegative -2", true, bool); +} - #[test] - fn gen_is_positive_f64() { - assert_evals_to!("Num.isPositive 0.0", false, bool); - assert_evals_to!("Num.isPositive 4.7", true, bool); - assert_evals_to!("Num.isPositive -8.5", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_positive_f64() { + assert_evals_to!("Num.isPositive 0.0", false, bool); + assert_evals_to!("Num.isPositive 4.7", true, bool); + assert_evals_to!("Num.isPositive -8.5", false, bool); +} - #[test] - fn gen_is_negative_f64() { - assert_evals_to!("Num.isNegative 0.0", false, bool); - assert_evals_to!("Num.isNegative 9.9", false, bool); - assert_evals_to!("Num.isNegative -4.4", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_negative_f64() { + assert_evals_to!("Num.isNegative 0.0", false, bool); + assert_evals_to!("Num.isNegative 9.9", false, bool); + assert_evals_to!("Num.isNegative -4.4", true, bool); +} - #[test] - fn gen_is_zero_f64() { - assert_evals_to!("Num.isZero 0", true, bool); - assert_evals_to!("Num.isZero 0_0", true, bool); - assert_evals_to!("Num.isZero 0.0", true, bool); - assert_evals_to!("Num.isZero 1", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_zero_f64() { + assert_evals_to!("Num.isZero 0", true, bool); + assert_evals_to!("Num.isZero 0_0", true, bool); + assert_evals_to!("Num.isZero 0.0", true, bool); + assert_evals_to!("Num.isZero 1", false, bool); +} - #[test] - fn gen_is_odd() { - assert_evals_to!("Num.isOdd 4", false, bool); - assert_evals_to!("Num.isOdd 5", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_odd() { + assert_evals_to!("Num.isOdd 4", false, bool); + assert_evals_to!("Num.isOdd 5", true, bool); +} - #[test] - fn gen_is_even() { - assert_evals_to!("Num.isEven 6", true, bool); - assert_evals_to!("Num.isEven 7", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_is_even() { + assert_evals_to!("Num.isEven 6", true, bool); + assert_evals_to!("Num.isEven 7", false, bool); +} - #[test] - fn sin() { - assert_evals_to!("Num.sin 0", 0.0, f64); - assert_evals_to!("Num.sin 1.41421356237", 0.9877659459922529, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn sin() { + assert_evals_to!("Num.sin 0", 0.0, f64); + assert_evals_to!("Num.sin 1.41421356237", 0.9877659459922529, f64); +} - #[test] - fn cos() { - assert_evals_to!("Num.cos 0", 1.0, f64); - assert_evals_to!("Num.cos 3.14159265359", -1.0, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn cos() { + assert_evals_to!("Num.cos 0", 1.0, f64); + assert_evals_to!("Num.cos 3.14159265359", -1.0, f64); +} - #[test] - fn tan() { - assert_evals_to!("Num.tan 0", 0.0, f64); - assert_evals_to!("Num.tan 1", 1.557407724654902, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn tan() { + assert_evals_to!("Num.tan 0", 0.0, f64); + assert_evals_to!("Num.tan 1", 1.557407724654902, f64); +} - #[test] - fn bitwise_and() { - assert_evals_to!("Num.bitwiseAnd 20 20", 20, i64); - assert_evals_to!("Num.bitwiseAnd 25 10", 8, i64); - assert_evals_to!("Num.bitwiseAnd 200 0", 0, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bitwise_and() { + assert_evals_to!("Num.bitwiseAnd 20 20", 20, i64); + assert_evals_to!("Num.bitwiseAnd 25 10", 8, i64); + assert_evals_to!("Num.bitwiseAnd 200 0", 0, i64); +} - #[test] - fn bitwise_xor() { - assert_evals_to!("Num.bitwiseXor 20 20", 0, i64); - assert_evals_to!("Num.bitwiseXor 15 14", 1, i64); - assert_evals_to!("Num.bitwiseXor 7 15", 8, i64); - assert_evals_to!("Num.bitwiseXor 200 0", 200, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bitwise_xor() { + assert_evals_to!("Num.bitwiseXor 20 20", 0, i64); + assert_evals_to!("Num.bitwiseXor 15 14", 1, i64); + assert_evals_to!("Num.bitwiseXor 7 15", 8, i64); + assert_evals_to!("Num.bitwiseXor 200 0", 200, i64); +} - #[test] - fn bitwise_or() { - assert_evals_to!("Num.bitwiseOr 1 1", 1, i64); - assert_evals_to!("Num.bitwiseOr 1 2", 3, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bitwise_or() { + assert_evals_to!("Num.bitwiseOr 1 1", 1, i64); + assert_evals_to!("Num.bitwiseOr 1 2", 3, i64); +} - #[test] - fn lt_i64() { - assert_evals_to!("1 < 2", true, bool); - assert_evals_to!("1 < 1", false, bool); - assert_evals_to!("2 < 1", false, bool); - assert_evals_to!("0 < 0", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn lt_i64() { + assert_evals_to!("1 < 2", true, bool); + assert_evals_to!("1 < 1", false, bool); + assert_evals_to!("2 < 1", false, bool); + assert_evals_to!("0 < 0", false, bool); +} - #[test] - fn lte_i64() { - assert_evals_to!("1 <= 1", true, bool); - assert_evals_to!("2 <= 1", false, bool); - assert_evals_to!("1 <= 2", true, bool); - assert_evals_to!("0 <= 0", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn lte_i64() { + assert_evals_to!("1 <= 1", true, bool); + assert_evals_to!("2 <= 1", false, bool); + assert_evals_to!("1 <= 2", true, bool); + assert_evals_to!("0 <= 0", true, bool); +} - #[test] - fn gt_i64() { - assert_evals_to!("2 > 1", true, bool); - assert_evals_to!("2 > 2", false, bool); - assert_evals_to!("1 > 1", false, bool); - assert_evals_to!("0 > 0", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gt_i64() { + assert_evals_to!("2 > 1", true, bool); + assert_evals_to!("2 > 2", false, bool); + assert_evals_to!("1 > 1", false, bool); + assert_evals_to!("0 > 0", false, bool); +} - #[test] - fn gte_i64() { - assert_evals_to!("1 >= 1", true, bool); - assert_evals_to!("1 >= 2", false, bool); - assert_evals_to!("2 >= 1", true, bool); - assert_evals_to!("0 >= 0", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gte_i64() { + assert_evals_to!("1 >= 1", true, bool); + assert_evals_to!("1 >= 2", false, bool); + assert_evals_to!("2 >= 1", true, bool); + assert_evals_to!("0 >= 0", true, bool); +} - #[test] - fn lt_f64() { - assert_evals_to!("1.1 < 1.2", true, bool); - assert_evals_to!("1.1 < 1.1", false, bool); - assert_evals_to!("1.2 < 1.1", false, bool); - assert_evals_to!("0.0 < 0.0", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn lt_f64() { + assert_evals_to!("1.1 < 1.2", true, bool); + assert_evals_to!("1.1 < 1.1", false, bool); + assert_evals_to!("1.2 < 1.1", false, bool); + assert_evals_to!("0.0 < 0.0", false, bool); +} - #[test] - fn lte_f64() { - assert_evals_to!("1.1 <= 1.1", true, bool); - assert_evals_to!("1.2 <= 1.1", false, bool); - assert_evals_to!("1.1 <= 1.2", true, bool); - assert_evals_to!("0.0 <= 0.0", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn lte_f64() { + assert_evals_to!("1.1 <= 1.1", true, bool); + assert_evals_to!("1.2 <= 1.1", false, bool); + assert_evals_to!("1.1 <= 1.2", true, bool); + assert_evals_to!("0.0 <= 0.0", true, bool); +} - #[test] - fn gt_f64() { - assert_evals_to!("2.2 > 1.1", true, bool); - assert_evals_to!("2.2 > 2.2", false, bool); - assert_evals_to!("1.1 > 2.2", false, bool); - assert_evals_to!("0.0 > 0.0", false, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gt_f64() { + assert_evals_to!("2.2 > 1.1", true, bool); + assert_evals_to!("2.2 > 2.2", false, bool); + assert_evals_to!("1.1 > 2.2", false, bool); + assert_evals_to!("0.0 > 0.0", false, bool); +} - #[test] - fn gte_f64() { - assert_evals_to!("1.1 >= 1.1", true, bool); - assert_evals_to!("1.1 >= 1.2", false, bool); - assert_evals_to!("1.2 >= 1.1", true, bool); - assert_evals_to!("0.0 >= 0.0", true, bool); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gte_f64() { + assert_evals_to!("1.1 >= 1.1", true, bool); + assert_evals_to!("1.1 >= 1.2", false, bool); + assert_evals_to!("1.2 >= 1.1", true, bool); + assert_evals_to!("0.0 >= 0.0", true, bool); +} - #[test] - fn gen_order_of_arithmetic_ops() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_order_of_arithmetic_ops() { + assert_evals_to!( + indoc!( + r#" 1 + 3 * 7 - 2 "# - ), - 20, - i64 - ); - } + ), + 20, + i64 + ); +} - #[test] - fn gen_order_of_arithmetic_ops_complex_float() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn gen_order_of_arithmetic_ops_complex_float() { + assert_evals_to!( + indoc!( + r#" 3 - 48 * 2.0 "# - ), - -93.0, - f64 - ); - } + ), + -93.0, + f64 + ); +} - #[test] - fn if_guard_bind_variable_false() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn if_guard_bind_variable_false() { + assert_evals_to!( + indoc!( + r#" wrapper = \{} -> when 10 is x if x == 5 -> 0 @@ -1079,17 +1169,18 @@ mod gen_num { wrapper {} "# - ), - 42, - i64 - ); - } + ), + 42, + i64 + ); +} - #[test] - fn if_guard_bind_variable_true() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn if_guard_bind_variable_true() { + assert_evals_to!( + indoc!( + r#" wrapper = \{} -> when 10 is x if x == 10 -> 42 @@ -1097,17 +1188,18 @@ mod gen_num { wrapper {} "# - ), - 42, - i64 - ); - } + ), + 42, + i64 + ); +} - #[test] - fn tail_call_elimination() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn tail_call_elimination() { + assert_evals_to!( + indoc!( + r#" sum = \n, accum -> when n is 0 -> accum @@ -1115,675 +1207,725 @@ mod gen_num { sum 1_000_000 0 "# - ), - 500000500000, - i64 - ); - } + ), + 500000500000, + i64 + ); +} - #[test] - fn int_negate() { - assert_evals_to!("Num.neg 123", -123, i64); - assert_evals_to!("Num.neg Num.maxInt", -i64::MAX, i64); - assert_evals_to!("Num.neg (Num.minInt + 1)", i64::MAX, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_negate() { + assert_evals_to!("Num.neg 123", -123, i64); + assert_evals_to!("Num.neg Num.maxInt", -i64::MAX, i64); + assert_evals_to!("Num.neg (Num.minInt + 1)", i64::MAX, i64); +} - #[test] - #[should_panic( - expected = r#"Roc failed with message: "integer negation overflowed because its argument is the minimum value"# - )] - fn neg_min_int_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic( + expected = r#"Roc failed with message: "integer negation overflowed because its argument is the minimum value"# +)] +fn neg_min_int_overflow() { + assert_evals_to!( + indoc!( + r#" Num.neg Num.minInt "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - fn gen_wrap_int_neg() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn gen_wrap_int_neg() { + assert_evals_to!( + indoc!( + r#" wrappedNeg = \num -> -num wrappedNeg 3 "# - ), - -3, - i64 - ); - } + ), + -3, + i64 + ); +} - #[test] - fn gen_basic_fn() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] +fn gen_basic_fn() { + assert_evals_to!( + indoc!( + r#" always42 : Num.Num (Num.Integer Num.Signed64) -> Num.Num (Num.Integer Num.Signed64) always42 = \_ -> 42 always42 5 "# - ), - 42, - i64 - ); - } + ), + 42, + i64 + ); +} - #[test] - fn int_to_float() { - assert_evals_to!("Num.toFloat 0x9", 9.0, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_to_float() { + assert_evals_to!("Num.toFloat 0x9", 9.0, f64); +} - #[test] - fn num_to_float() { - assert_evals_to!("Num.toFloat 9", 9.0, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn num_to_float() { + assert_evals_to!("Num.toFloat 9", 9.0, f64); +} - #[test] - fn float_to_float() { - assert_evals_to!("Num.toFloat 0.5", 0.5, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_to_float() { + assert_evals_to!("Num.toFloat 0.5", 0.5, f64); +} - #[test] - fn int_compare() { - assert_evals_to!("Num.compare 0 1", RocOrder::Lt, RocOrder); - assert_evals_to!("Num.compare 1 1", RocOrder::Eq, RocOrder); - assert_evals_to!("Num.compare 1 0", RocOrder::Gt, RocOrder); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_compare() { + assert_evals_to!("Num.compare 0 1", RocOrder::Lt, RocOrder); + assert_evals_to!("Num.compare 1 1", RocOrder::Eq, RocOrder); + assert_evals_to!("Num.compare 1 0", RocOrder::Gt, RocOrder); +} - #[test] - fn float_compare() { - assert_evals_to!("Num.compare 0.01 3.14", RocOrder::Lt, RocOrder); - assert_evals_to!("Num.compare 3.14 3.14", RocOrder::Eq, RocOrder); - assert_evals_to!("Num.compare 3.14 0.01", RocOrder::Gt, RocOrder); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_compare() { + assert_evals_to!("Num.compare 0.01 3.14", RocOrder::Lt, RocOrder); + assert_evals_to!("Num.compare 3.14 3.14", RocOrder::Eq, RocOrder); + assert_evals_to!("Num.compare 3.14 0.01", RocOrder::Gt, RocOrder); +} - #[test] - fn pow() { - assert_evals_to!("Num.pow 2.0 2.0", 4.0, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn pow() { + assert_evals_to!("Num.pow 2.0 2.0", 4.0, f64); +} - #[test] - fn ceiling() { - assert_evals_to!("Num.ceiling 1.1", 2, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn ceiling() { + assert_evals_to!("Num.ceiling 1.1", 2, i64); +} - #[test] - fn floor() { - assert_evals_to!("Num.floor 1.9", 1, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn floor() { + assert_evals_to!("Num.floor 1.9", 1, i64); +} - #[test] - fn pow_int() { - assert_evals_to!("Num.powInt 2 3", 8, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn pow_int() { + assert_evals_to!("Num.powInt 2 3", 8, i64); +} - #[test] - fn atan() { - assert_evals_to!("Num.atan 10", 1.4711276743037347, f64); - } +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] +fn atan() { + assert_evals_to!("Num.atan 10", 1.4711276743037347, f64); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] - fn int_add_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] +fn int_add_overflow() { + assert_evals_to!( + indoc!( + r#" 9_223_372_036_854_775_807 + 1 "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - fn int_add_checked() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_add_checked() { + assert_evals_to!( + indoc!( + r#" when Num.addChecked 1 2 is Ok v -> v _ -> -1 "# - ), - 3, - i64 - ); + ), + 3, + i64 + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" when Num.addChecked 9_223_372_036_854_775_807 1 is Err Overflow -> -1 Ok v -> v "# - ), - -1, - i64 - ); - } + ), + -1, + i64 + ); +} - #[test] - fn int_add_wrap() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_add_wrap() { + assert_evals_to!( + indoc!( + r#" Num.addWrap 9_223_372_036_854_775_807 1 "# - ), - std::i64::MIN, - i64 - ); - } + ), + std::i64::MIN, + i64 + ); +} - #[test] - fn float_add_checked_pass() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_add_checked_pass() { + assert_evals_to!( + indoc!( + r#" when Num.addChecked 1.0 0.0 is Ok v -> v Err Overflow -> -1.0 "# - ), - 1.0, - f64 - ); - } + ), + 1.0, + f64 + ); +} - #[test] - fn float_add_checked_fail() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_add_checked_fail() { + assert_evals_to!( + indoc!( + r#" when Num.addChecked 1.7976931348623157e308 1.7976931348623157e308 is Err Overflow -> -1 Ok v -> v "# - ), - -1.0, - f64 - ); - } + ), + -1.0, + f64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "float addition overflowed!"#)] - fn float_add_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "float addition overflowed!"#)] +fn float_add_overflow() { + assert_evals_to!( + indoc!( + r#" 1.7976931348623157e308 + 1.7976931348623157e308 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - fn num_max_int() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn num_max_int() { + assert_evals_to!( + indoc!( + r#" Num.maxInt "# - ), - i64::MAX, - i64 - ); - } + ), + i64::MAX, + i64 + ); +} - #[test] - fn num_min_int() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] +fn num_min_int() { + assert_evals_to!( + indoc!( + r#" Num.minInt "# - ), - i64::MIN, - i64 - ); - } + ), + i64::MIN, + i64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] - fn int_sub_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "integer subtraction overflowed!"#)] +fn int_sub_overflow() { + assert_evals_to!( + indoc!( + r#" -9_223_372_036_854_775_808 - 1 "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - fn int_sub_wrap() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_sub_wrap() { + assert_evals_to!( + indoc!( + r#" Num.subWrap -9_223_372_036_854_775_808 1 "# - ), - std::i64::MAX, - i64 - ); - } + ), + std::i64::MAX, + i64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "float subtraction overflowed!"#)] - fn float_sub_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "float subtraction overflowed!"#)] +fn float_sub_overflow() { + assert_evals_to!( + indoc!( + r#" -1.7976931348623157e308 - 1.7976931348623157e308 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - fn int_sub_checked() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_sub_checked() { + assert_evals_to!( + indoc!( + r#" when Num.subChecked 5 2 is Ok v -> v _ -> -1 "# - ), - 3, - i64 - ); + ), + 3, + i64 + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" when Num.subChecked Num.minInt 1 is Err Overflow -> -1 Ok v -> v "# - ), - -1, - i64 - ); - } + ), + -1, + i64 + ); +} - #[test] - fn float_sub_checked() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_sub_checked() { + assert_evals_to!( + indoc!( + r#" when Num.subChecked 1.0 0.0 is Ok v -> v Err Overflow -> -1.0 "# - ), - 1.0, - f64 - ); + ), + 1.0, + f64 + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" when Num.subChecked -1.7976931348623157e308 1.7976931348623157e308 is Err Overflow -> -1 Ok v -> v "# - ), - -1.0, - f64 - ); - } + ), + -1.0, + f64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] - fn int_positive_mul_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] +fn int_positive_mul_overflow() { + assert_evals_to!( + indoc!( + r#" 9_223_372_036_854_775_807 * 2 "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] - fn int_negative_mul_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "integer multiplication overflowed!"#)] +fn int_negative_mul_overflow() { + assert_evals_to!( + indoc!( + r#" (-9_223_372_036_854_775_808) * 2 "# - ), - 0, - i64 - ); - } + ), + 0, + i64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "float multiplication overflowed!"#)] - fn float_positive_mul_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "float multiplication overflowed!"#)] +fn float_positive_mul_overflow() { + assert_evals_to!( + indoc!( + r#" 1.7976931348623157e308 * 2 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - #[should_panic(expected = r#"Roc failed with message: "float multiplication overflowed!"#)] - fn float_negative_mul_overflow() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[should_panic(expected = r#"Roc failed with message: "float multiplication overflowed!"#)] +fn float_negative_mul_overflow() { + assert_evals_to!( + indoc!( + r#" -1.7976931348623157e308 * 2 "# - ), - 0.0, - f64 - ); - } + ), + 0.0, + f64 + ); +} - #[test] - fn int_mul_wrap() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_mul_wrap() { + assert_evals_to!( + indoc!( + r#" Num.mulWrap Num.maxInt 2 "# - ), - -2, - i64 - ); - } + ), + -2, + i64 + ); +} - #[test] - fn int_mul_checked() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn int_mul_checked() { + assert_evals_to!( + indoc!( + r#" when Num.mulChecked 20 2 is Ok v -> v _ -> -1 "# - ), - 40, - i64 - ); + ), + 40, + i64 + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" when Num.mulChecked Num.maxInt 2 is Err Overflow -> -1 Ok v -> v "# - ), - -1, - i64 - ); - } + ), + -1, + i64 + ); +} - #[test] - fn float_mul_checked() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn float_mul_checked() { + assert_evals_to!( + indoc!( + r#" when Num.mulChecked 20.0 2.0 is Ok v -> v Err Overflow -> -1.0 "# - ), - 40.0, - f64 - ); + ), + 40.0, + f64 + ); - assert_evals_to!( - indoc!( - r#" + assert_evals_to!( + indoc!( + r#" when Num.mulChecked 1.7976931348623157e308 2 is Err Overflow -> -1 Ok v -> v "# - ), - -1.0, - f64 - ); - } + ), + -1.0, + f64 + ); +} - #[test] - fn shift_left_by() { - assert_evals_to!("Num.shiftLeftBy 0 0b0000_0001", 0b0000_0001, i64); - assert_evals_to!("Num.shiftLeftBy 1 0b0000_0001", 0b0000_0010, i64); - assert_evals_to!("Num.shiftLeftBy 2 0b0000_0011", 0b0000_1100, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn shift_left_by() { + assert_evals_to!("Num.shiftLeftBy 0 0b0000_0001", 0b0000_0001, i64); + assert_evals_to!("Num.shiftLeftBy 1 0b0000_0001", 0b0000_0010, i64); + assert_evals_to!("Num.shiftLeftBy 2 0b0000_0011", 0b0000_1100, i64); +} - #[test] - #[ignore] - fn shift_right_by() { - // Sign Extended Right Shift - assert_evals_to!("Num.shiftRightBy 0 0b0100_0000i8", 0b0001_0000, i8); - assert_evals_to!("Num.shiftRightBy 1 0b1110_0000u8", 0b1111_0000u8 as i8, i8); - assert_evals_to!("Num.shiftRightBy 2 0b1100_0000u8", 0b1111_0000u8 as i8, i8); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[ignore] +fn shift_right_by() { + // Sign Extended Right Shift + assert_evals_to!("Num.shiftRightBy 0 0b0100_0000i8", 0b0001_0000, i8); + assert_evals_to!("Num.shiftRightBy 1 0b1110_0000u8", 0b1111_0000u8 as i8, i8); + assert_evals_to!("Num.shiftRightBy 2 0b1100_0000u8", 0b1111_0000u8 as i8, i8); +} - #[test] - #[ignore] - fn shift_right_zf_by() { - // Logical Right Shift - assert_evals_to!("Num.shiftRightBy 1 0b1100_0000u8", 0b0011_0000, i64); - assert_evals_to!("Num.shiftRightBy 2 0b0000_0010u8", 0b0000_0001, i64); - assert_evals_to!("Num.shiftRightBy 3 0b0000_1100u8", 0b0000_0011, i64); - } +#[test] +#[cfg(any(feature = "gen-llvm"))] +#[ignore] +fn shift_right_zf_by() { + // Logical Right Shift + assert_evals_to!("Num.shiftRightBy 1 0b1100_0000u8", 0b0011_0000, i64); + assert_evals_to!("Num.shiftRightBy 2 0b0000_0010u8", 0b0000_0001, i64); + assert_evals_to!("Num.shiftRightBy 3 0b0000_1100u8", 0b0000_0011, i64); +} - #[test] - fn max_i128() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn max_i128() { + assert_evals_to!( + indoc!( + r#" Num.maxI128 "# - ), - i128::MAX, - i128 - ); - } + ), + i128::MAX, + i128 + ); +} - #[test] - fn is_multiple_of() { - // true - assert_evals_to!("Num.isMultipleOf 5 1", true, bool); - assert_evals_to!("Num.isMultipleOf 5 -1", true, bool); - assert_evals_to!("Num.isMultipleOf 0 0", true, bool); - assert_evals_to!("Num.isMultipleOf 0 1", true, bool); - assert_evals_to!("Num.isMultipleOf 0 -1", true, bool); - // false - assert_evals_to!("Num.isMultipleOf 5 2", false, bool); - assert_evals_to!("Num.isMultipleOf 5 0", false, bool); +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn is_multiple_of() { + // true + assert_evals_to!("Num.isMultipleOf 5 1", true, bool); + assert_evals_to!("Num.isMultipleOf 5 -1", true, bool); + assert_evals_to!("Num.isMultipleOf 0 0", true, bool); + assert_evals_to!("Num.isMultipleOf 0 1", true, bool); + assert_evals_to!("Num.isMultipleOf 0 -1", true, bool); + // false + assert_evals_to!("Num.isMultipleOf 5 2", false, bool); + assert_evals_to!("Num.isMultipleOf 5 0", false, bool); - // overflow - assert_evals_to!("Num.isMultipleOf -9223372036854775808 -1", true, bool); - } + // overflow + assert_evals_to!("Num.isMultipleOf -9223372036854775808 -1", true, bool); +} - #[test] - fn bytes_to_u16_clearly_out_of_bounds() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u16_clearly_out_of_bounds() { + assert_evals_to!( + indoc!( + r#" bytes = Str.toUtf8 "hello" when Num.bytesToU16 bytes 234 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 1, - u16 - ); - } + ), + 1, + u16 + ); +} - #[test] - fn bytes_to_u16_subtly_out_of_bounds() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u16_subtly_out_of_bounds() { + assert_evals_to!( + indoc!( + r#" bytes = Str.toUtf8 "hello" when Num.bytesToU16 bytes 4 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 1, - u16 - ); - } + ), + 1, + u16 + ); +} - #[test] - fn bytes_to_u32_clearly_out_of_bounds() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u32_clearly_out_of_bounds() { + assert_evals_to!( + indoc!( + r#" bytes = Str.toUtf8 "hello" when Num.bytesToU32 bytes 234 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 1, - u32 - ); - } + ), + 1, + u32 + ); +} - #[test] - fn bytes_to_u32_subtly_out_of_bounds() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u32_subtly_out_of_bounds() { + assert_evals_to!( + indoc!( + r#" bytes = Str.toUtf8 "hello" when Num.bytesToU32 bytes 2 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 1, - u32 - ); - } + ), + 1, + u32 + ); +} - #[test] - fn bytes_to_u16_max_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u16_max_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU16 [255, 255] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 65535, - u16 - ); - } + ), + 65535, + u16 + ); +} - #[test] - fn bytes_to_u16_min_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u16_min_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU16 [0, 0] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 0, - u16 - ); - } + ), + 0, + u16 + ); +} - #[test] - fn bytes_to_u16_random_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u16_random_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU16 [164, 215] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 55_204, - u16 - ); - } + ), + 55_204, + u16 + ); +} - #[test] - fn bytes_to_u32_min_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u32_min_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU32 [0, 0, 0, 0] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 0, - u32 - ); - } + ), + 0, + u32 + ); +} - #[test] - fn bytes_to_u32_max_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u32_max_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU32 [255, 255, 255, 255] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 4_294_967_295, - u32 - ); - } + ), + 4_294_967_295, + u32 + ); +} - #[test] - fn bytes_to_u32_random_u8s() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn bytes_to_u32_random_u8s() { + assert_evals_to!( + indoc!( + r#" when Num.bytesToU32 [252, 124, 128, 121] 0 is Ok v -> v Err OutOfBounds -> 1 "# - ), - 2_038_463_740, - u32 - ); - } + ), + 2_038_463_740, + u32 + ); +} - #[test] - fn when_on_i32() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn when_on_i32() { + assert_evals_to!( + indoc!( + r#" app "test" provides [ main ] to "./platform" x : I32 @@ -1795,17 +1937,18 @@ mod gen_num { 0 -> 42 _ -> -1 "# - ), - 42, - i32 - ); - } + ), + 42, + i32 + ); +} - #[test] - fn when_on_i16() { - assert_evals_to!( - indoc!( - r#" +#[test] +#[cfg(any(feature = "gen-llvm"))] +fn when_on_i16() { + assert_evals_to!( + indoc!( + r#" app "test" provides [ main ] to "./platform" x : I16 @@ -1817,9 +1960,8 @@ mod gen_num { 0 -> 42 _ -> -1 "# - ), - 42, - i16 - ); - } + ), + 42, + i16 + ); } diff --git a/compiler/test_gen/src/gen_primitives.rs b/compiler/test_gen/src/gen_primitives.rs index 8dad37e67d..7dbde0b8ea 100644 --- a/compiler/test_gen/src/gen_primitives.rs +++ b/compiler/test_gen/src/gen_primitives.rs @@ -1,22 +1,42 @@ -#![cfg(test)] +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_llvm_evals_to; +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_non_opt_evals_to; + +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to; +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to as assert_llvm_evals_to; +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to as assert_non_opt_evals_to; + +#[cfg(feature = "gen-wasm")] +use crate::helpers::wasm::assert_evals_to; +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to as assert_llvm_evals_to; +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to as assert_non_opt_evals_to; -use crate::assert_evals_to; -use crate::assert_llvm_evals_to; -use crate::assert_non_opt_evals_to; use indoc::indoc; +#[allow(unused_imports)] use roc_std::RocStr; #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn basic_int() { assert_evals_to!("123", 123, i64); } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn basic_float() { assert_evals_to!("1234.0", 1234.0, f64); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn branch_first_float() { assert_evals_to!( indoc!( @@ -32,6 +52,7 @@ fn branch_first_float() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn branch_second_float() { assert_evals_to!( indoc!( @@ -47,6 +68,7 @@ fn branch_second_float() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn branch_third_float() { assert_evals_to!( indoc!( @@ -63,6 +85,7 @@ fn branch_third_float() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn branch_first_int() { assert_evals_to!( indoc!( @@ -78,6 +101,7 @@ fn branch_first_int() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn branch_second_int() { assert_evals_to!( indoc!( @@ -93,6 +117,7 @@ fn branch_second_int() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn branch_third_int() { assert_evals_to!( indoc!( @@ -109,6 +134,7 @@ fn branch_third_int() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn branch_store_variable() { assert_evals_to!( indoc!( @@ -124,6 +150,7 @@ fn branch_store_variable() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn when_one_element_tag() { assert_evals_to!( indoc!( @@ -141,6 +168,7 @@ fn when_one_element_tag() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_two_element_tag_first() { assert_evals_to!( indoc!( @@ -159,6 +187,7 @@ fn when_two_element_tag_first() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_two_element_tag_second() { assert_evals_to!( indoc!( @@ -177,6 +206,7 @@ fn when_two_element_tag_second() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn gen_when_one_branch() { assert_evals_to!( indoc!( @@ -191,6 +221,7 @@ fn gen_when_one_branch() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_large_when_int() { assert_evals_to!( indoc!( @@ -213,6 +244,7 @@ fn gen_large_when_int() { } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn gen_large_when_float() { // assert_evals_to!( // indoc!( @@ -235,6 +267,7 @@ fn gen_large_when_int() { // } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn or_pattern() { assert_evals_to!( indoc!( @@ -250,6 +283,7 @@ fn or_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn apply_identity() { assert_evals_to!( indoc!( @@ -265,6 +299,7 @@ fn apply_identity() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn apply_unnamed_identity() { assert_evals_to!( indoc!( @@ -281,6 +316,7 @@ fn apply_unnamed_identity() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn return_unnamed_fn() { assert_evals_to!( indoc!( @@ -301,6 +337,7 @@ fn return_unnamed_fn() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_when_fn() { assert_evals_to!( indoc!( @@ -320,6 +357,7 @@ fn gen_when_fn() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn gen_basic_def() { assert_evals_to!( indoc!( @@ -347,6 +385,7 @@ fn gen_basic_def() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_multiple_defs() { assert_evals_to!( indoc!( @@ -380,6 +419,7 @@ fn gen_multiple_defs() { // These tests caught a bug in how Defs are converted to the mono IR // but they have UnusedDef or UnusedArgument problems, and don't run any more // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn gen_chained_defs() { // assert_evals_to!( // indoc!( @@ -399,6 +439,7 @@ fn gen_multiple_defs() { // } // // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn gen_nested_defs_old() { // assert_evals_to!( // indoc!( @@ -440,6 +481,7 @@ fn gen_multiple_defs() { // } // // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn let_x_in_x() { // assert_evals_to!( // indoc!( @@ -462,6 +504,7 @@ fn gen_multiple_defs() { // } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn factorial() { assert_evals_to!( indoc!( @@ -483,6 +526,7 @@ fn factorial() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn peano1() { assert_non_opt_evals_to!( indoc!( @@ -503,6 +547,7 @@ fn peano1() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn peano2() { assert_non_opt_evals_to!( indoc!( @@ -524,6 +569,7 @@ fn peano2() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn top_level_constant() { assert_evals_to!( indoc!( @@ -542,6 +588,7 @@ fn top_level_constant() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_len_0() { assert_non_opt_evals_to!( indoc!( @@ -569,6 +616,7 @@ fn linked_list_len_0() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_len_twice_0() { assert_non_opt_evals_to!( indoc!( @@ -596,6 +644,7 @@ fn linked_list_len_twice_0() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_len_1() { assert_non_opt_evals_to!( indoc!( @@ -623,6 +672,7 @@ fn linked_list_len_1() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_len_twice_1() { assert_non_opt_evals_to!( indoc!( @@ -650,6 +700,7 @@ fn linked_list_len_twice_1() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_len_3() { assert_non_opt_evals_to!( indoc!( @@ -678,6 +729,7 @@ fn linked_list_len_3() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_sum_num_a() { assert_non_opt_evals_to!( indoc!( @@ -706,6 +758,7 @@ fn linked_list_sum_num_a() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_sum_int() { assert_non_opt_evals_to!( indoc!( @@ -733,6 +786,7 @@ fn linked_list_sum_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_map() { assert_non_opt_evals_to!( indoc!( @@ -766,6 +820,7 @@ fn linked_list_map() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_nested_maybe() { assert_evals_to!( indoc!( @@ -822,6 +877,7 @@ fn when_nested_maybe() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_peano() { assert_non_opt_evals_to!( indoc!( @@ -879,6 +935,7 @@ fn when_peano() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Roc failed with message: ")] fn overflow_frees_list() { assert_evals_to!( @@ -903,6 +960,7 @@ fn overflow_frees_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Roc failed with message: ")] fn undefined_variable() { assert_evals_to!( @@ -920,6 +978,7 @@ fn undefined_variable() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Roc failed with message: ")] fn annotation_without_body() { assert_evals_to!( @@ -937,6 +996,7 @@ fn annotation_without_body() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn simple_closure() { assert_evals_to!( indoc!( @@ -958,6 +1018,7 @@ fn simple_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_closure() { assert_evals_to!( indoc!( @@ -981,6 +1042,7 @@ fn nested_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn closure_in_list() { assert_evals_to!( indoc!( @@ -1006,6 +1068,7 @@ fn closure_in_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn specialize_closure() { use roc_std::RocList; @@ -1037,6 +1100,7 @@ fn specialize_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn io_poc_effect() { assert_non_opt_evals_to!( indoc!( @@ -1067,6 +1131,7 @@ fn io_poc_effect() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn io_poc_desugared() { assert_evals_to!( indoc!( @@ -1094,6 +1159,7 @@ fn io_poc_desugared() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn return_wrapped_function_pointer() { assert_non_opt_evals_to!( indoc!( @@ -1116,6 +1182,7 @@ fn return_wrapped_function_pointer() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn return_wrapped_function_pointer_b() { assert_non_opt_evals_to!( indoc!( @@ -1137,6 +1204,7 @@ fn return_wrapped_function_pointer_b() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn return_wrapped_closure() { assert_non_opt_evals_to!( indoc!( @@ -1162,6 +1230,7 @@ fn return_wrapped_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_is_singleton() { assert_non_opt_evals_to!( indoc!( @@ -1196,6 +1265,7 @@ fn linked_list_is_singleton() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_is_empty_1() { assert_non_opt_evals_to!( indoc!( @@ -1230,6 +1300,7 @@ fn linked_list_is_empty_1() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_is_empty_2() { assert_non_opt_evals_to!( indoc!( @@ -1261,6 +1332,7 @@ fn linked_list_is_empty_2() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_singleton() { // verifies only that valid llvm is produced assert_non_opt_evals_to!( @@ -1281,6 +1353,7 @@ fn linked_list_singleton() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn recursive_function_with_rigid() { assert_non_opt_evals_to!( indoc!( @@ -1307,6 +1380,7 @@ fn recursive_function_with_rigid() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn rbtree_insert() { assert_non_opt_evals_to!( indoc!( @@ -1394,6 +1468,7 @@ fn rbtree_insert() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn rbtree_balance_3() { assert_non_opt_evals_to!( indoc!( @@ -1418,6 +1493,7 @@ fn rbtree_balance_3() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn rbtree_layout_issue() { // there is a flex var in here somewhere that blows up layout creation @@ -1459,6 +1535,7 @@ fn rbtree_layout_issue() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn rbtree_balance_mono_problem() { // because of how the function is written, only `Red` is used and so in the function's @@ -1512,6 +1589,7 @@ fn rbtree_balance_mono_problem() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn rbtree_balance_full() { assert_non_opt_evals_to!( indoc!( @@ -1563,6 +1641,7 @@ fn rbtree_balance_full() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_pattern_match_two_ways() { // exposed an issue in the ordering of pattern match checks when ran with `--release` mode assert_non_opt_evals_to!( @@ -1616,6 +1695,7 @@ fn nested_pattern_match_two_ways() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_guarded_double_pattern_match() { // the important part here is that the first case (with the nested Cons) does not match // TODO this also has undefined behavior @@ -1647,6 +1727,7 @@ fn linked_list_guarded_double_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn linked_list_double_pattern_match() { assert_non_opt_evals_to!( indoc!( @@ -1672,6 +1753,7 @@ fn linked_list_double_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn binary_tree_double_pattern_match() { assert_non_opt_evals_to!( indoc!( @@ -1697,6 +1779,7 @@ fn binary_tree_double_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn unified_empty_closure_bool() { // none of the Closure tags will have a payload // this was not handled correctly in the past @@ -1721,6 +1804,7 @@ fn unified_empty_closure_bool() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn unified_empty_closure_byte() { // none of the Closure tags will have a payload // this was not handled correctly in the past @@ -1746,6 +1830,7 @@ fn unified_empty_closure_byte() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn task_always_twice() { assert_non_opt_evals_to!( indoc!( @@ -1790,6 +1875,7 @@ fn task_always_twice() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn wildcard_rigid() { assert_non_opt_evals_to!( indoc!( @@ -1819,6 +1905,7 @@ fn wildcard_rigid() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn todo_bad_error_message() { assert_non_opt_evals_to!( @@ -1866,6 +1953,7 @@ fn todo_bad_error_message() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn hof_conditional() { // exposed issue with the if condition being just a symbol assert_evals_to!( @@ -1882,6 +1970,7 @@ fn hof_conditional() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic( expected = "Roc failed with message: \"Shadowing { original_region: |L 3-3, C 4-5|, shadow: |L 6-6, C 8-9| Ident" )] @@ -1901,6 +1990,7 @@ fn pattern_shadowing() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "TODO non-exhaustive pattern")] fn non_exhaustive_pattern_let() { assert_evals_to!( @@ -1920,6 +2010,7 @@ fn non_exhaustive_pattern_let() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] #[should_panic(expected = "")] fn unsupported_pattern_str_interp() { @@ -1937,6 +2028,7 @@ fn unsupported_pattern_str_interp() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn fingertree_basic() { assert_non_opt_evals_to!( @@ -1978,6 +2070,7 @@ fn fingertree_basic() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn case_or_pattern() { // the `0` branch body should only be generated once in the future // it is currently duplicated @@ -1998,6 +2091,7 @@ fn case_or_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn rosetree_basic() { assert_non_opt_evals_to!( @@ -2025,6 +2119,7 @@ fn rosetree_basic() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn case_jump() { // the decision tree will generate a jump to the `1` branch here assert_evals_to!( @@ -2050,6 +2145,7 @@ fn case_jump() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nullable_eval_cfold() { // the decision tree will generate a jump to the `1` branch here assert_evals_to!( @@ -2086,6 +2182,7 @@ fn nullable_eval_cfold() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_switch() { // exposed bug with passing the right symbol/layout down into switch branch generation assert_evals_to!( @@ -2128,6 +2225,7 @@ fn nested_switch() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn count_deriv_x() { // exposed bug with basing the block_of_memory on a specific (smaller) tag layout assert_evals_to!( @@ -2154,6 +2252,7 @@ fn count_deriv_x() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn deriv_pow() { // exposed bug with ordering of variable declarations before switch assert_evals_to!( @@ -2190,6 +2289,7 @@ fn deriv_pow() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn multiple_increment() { // the `leaf` value will be incremented multiple times at once assert_evals_to!( @@ -2223,6 +2323,7 @@ fn multiple_increment() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn switch_fuse_rc_non_exhaustive() { assert_evals_to!( indoc!( @@ -2252,6 +2353,7 @@ fn switch_fuse_rc_non_exhaustive() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn switch_fuse_rc_exhaustive() { assert_evals_to!( indoc!( @@ -2280,6 +2382,7 @@ fn switch_fuse_rc_exhaustive() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn build_then_apply_closure() { assert_evals_to!( indoc!( @@ -2299,6 +2402,7 @@ fn build_then_apply_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn expanded_result() { assert_evals_to!( indoc!( @@ -2329,6 +2433,7 @@ fn expanded_result() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn backpassing_result() { assert_evals_to!( @@ -2362,6 +2467,7 @@ fn backpassing_result() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] #[should_panic( expected = "Shadowing { original_region: |L 3-3, C 4-5|, shadow: |L 5-5, C 6-7| Ident" )] @@ -2380,6 +2486,7 @@ fn function_malformed_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Hit an erroneous type when creating a layout for")] fn call_invalid_layout() { assert_llvm_evals_to!( @@ -2399,6 +2506,7 @@ fn call_invalid_layout() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "An expectation failed!")] fn expect_fail() { assert_evals_to!( @@ -2415,6 +2523,7 @@ fn expect_fail() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn increment_or_double_closure() { assert_evals_to!( indoc!( @@ -2452,6 +2561,7 @@ fn increment_or_double_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn module_thunk_is_function() { assert_evals_to!( indoc!( @@ -2468,6 +2578,7 @@ fn module_thunk_is_function() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Roc failed with message: ")] fn hit_unresolved_type_variable() { assert_evals_to!( @@ -2491,6 +2602,7 @@ fn hit_unresolved_type_variable() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn pattern_match_empty_record() { assert_evals_to!( indoc!( @@ -2510,6 +2622,7 @@ fn pattern_match_empty_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn pattern_match_unit_tag() { assert_evals_to!( indoc!( @@ -2534,6 +2647,7 @@ fn pattern_match_unit_tag() { // see for why this is disabled on wasm32 https://github.com/rtfeldman/roc/issues/1687 #[cfg(not(feature = "wasm-cli-run"))] #[test] +#[cfg(any(feature = "gen-llvm"))] fn mirror_llvm_alignment_padding() { // see https://github.com/rtfeldman/roc/issues/1569 assert_evals_to!( @@ -2556,6 +2670,7 @@ fn mirror_llvm_alignment_padding() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn lambda_set_bool() { assert_evals_to!( indoc!( @@ -2580,6 +2695,7 @@ fn lambda_set_bool() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn lambda_set_byte() { assert_evals_to!( indoc!( @@ -2605,6 +2721,7 @@ fn lambda_set_byte() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn lambda_set_struct_byte() { assert_evals_to!( indoc!( @@ -2632,6 +2749,7 @@ fn lambda_set_struct_byte() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn lambda_set_enum_byte_byte() { assert_evals_to!( indoc!( @@ -2662,6 +2780,7 @@ fn lambda_set_enum_byte_byte() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn list_walk_until() { // see https://github.com/rtfeldman/roc/issues/1576 assert_evals_to!( @@ -2687,6 +2806,7 @@ fn list_walk_until() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn int_literal_not_specialized_with_annotation() { // see https://github.com/rtfeldman/roc/issues/1600 assert_evals_to!( @@ -2714,6 +2834,7 @@ fn int_literal_not_specialized_with_annotation() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn int_literal_not_specialized_no_annotation() { // see https://github.com/rtfeldman/roc/issues/1600 assert_evals_to!( @@ -2740,6 +2861,7 @@ fn int_literal_not_specialized_no_annotation() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn unresolved_tvar_when_capture_is_unused() { // see https://github.com/rtfeldman/roc/issues/1585 assert_evals_to!( @@ -2766,6 +2888,7 @@ fn unresolved_tvar_when_capture_is_unused() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "Roc failed with message: ")] fn value_not_exposed_hits_panic() { assert_evals_to!( @@ -2784,6 +2907,7 @@ fn value_not_exposed_hits_panic() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn mix_function_and_closure() { // see https://github.com/rtfeldman/roc/pull/1706 assert_evals_to!( @@ -2809,6 +2933,7 @@ fn mix_function_and_closure() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn mix_function_and_closure_level_of_indirection() { // see https://github.com/rtfeldman/roc/pull/1706 assert_evals_to!( @@ -2833,6 +2958,7 @@ fn mix_function_and_closure_level_of_indirection() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn do_pass_bool_byte_closure_layout() { // see https://github.com/rtfeldman/roc/pull/1706 // the distinction is actually important, dropping that info means some functions just get @@ -2908,6 +3034,7 @@ fn do_pass_bool_byte_closure_layout() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_rigid_list() { assert_evals_to!( indoc!( @@ -2932,6 +3059,7 @@ fn nested_rigid_list() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn nested_rigid_alias() { assert_evals_to!( indoc!( @@ -2958,6 +3086,7 @@ fn nested_rigid_alias() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn nested_rigid_tag_union() { assert_evals_to!( indoc!( @@ -2982,6 +3111,7 @@ fn nested_rigid_tag_union() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn call_that_needs_closure_parameter() { // here both p2 is lifted to the top-level, which means that `list` must be // passed to it from `manyAux`. diff --git a/compiler/test_gen/src/gen_records.rs b/compiler/test_gen/src/gen_records.rs index 9f6fbe478b..927daf0e18 100644 --- a/compiler/test_gen/src/gen_records.rs +++ b/compiler/test_gen/src/gen_records.rs @@ -1,10 +1,17 @@ -#![cfg(test)] +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to; + +#[cfg(feature = "gen-wasm")] +use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; // use crate::assert_wasm_evals_to as assert_evals_to; use indoc::indoc; #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn basic_record() { assert_evals_to!( indoc!( @@ -38,6 +45,7 @@ fn basic_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn f64_record() { assert_evals_to!( indoc!( @@ -77,6 +85,7 @@ fn f64_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn fn_record() { assert_evals_to!( indoc!( @@ -128,6 +137,7 @@ fn fn_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn def_record() { assert_evals_to!( indoc!( @@ -167,6 +177,7 @@ fn def_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn when_on_record() { assert_evals_to!( indoc!( @@ -181,6 +192,7 @@ fn when_on_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn when_record_with_guard_pattern() { assert_evals_to!( indoc!( @@ -195,6 +207,7 @@ fn when_record_with_guard_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn let_with_record_pattern() { assert_evals_to!( indoc!( @@ -210,6 +223,7 @@ fn let_with_record_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn record_guard_pattern() { assert_evals_to!( indoc!( @@ -225,6 +239,7 @@ fn record_guard_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn twice_record_access() { assert_evals_to!( indoc!( @@ -239,6 +254,7 @@ fn twice_record_access() { ); } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-dev"))] fn empty_record() { assert_evals_to!( indoc!( @@ -253,6 +269,7 @@ fn empty_record() { ); } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn i64_record2_literal() { assert_evals_to!( indoc!( @@ -266,6 +283,7 @@ fn i64_record2_literal() { } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn i64_record3_literal() { // assert_evals_to!( // indoc!( @@ -277,8 +295,8 @@ fn i64_record2_literal() { // (i64, i64, i64) // ); // } - #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn f64_record2_literal() { assert_evals_to!( indoc!( @@ -292,6 +310,7 @@ fn f64_record2_literal() { } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn f64_record3_literal() { // assert_evals_to!( // indoc!( @@ -305,6 +324,7 @@ fn f64_record2_literal() { // } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn bool_record4_literal() { // assert_evals_to!( // indoc!( @@ -319,8 +339,8 @@ fn f64_record2_literal() { // (bool, bool, bool, bool) // ); // } - #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn i64_record1_literal() { assert_evals_to!( indoc!( @@ -334,6 +354,7 @@ fn i64_record1_literal() { } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn i64_record9_literal() { // assert_evals_to!( // indoc!( @@ -347,6 +368,7 @@ fn i64_record1_literal() { // } // #[test] +// #[cfg(any(feature = "gen-llvm"))] // fn f64_record3_literal() { // assert_evals_to!( // indoc!( @@ -358,8 +380,8 @@ fn i64_record1_literal() { // (f64, f64, f64) // ); // } - #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn bool_literal() { assert_evals_to!( indoc!( @@ -376,6 +398,7 @@ fn bool_literal() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record() { assert_evals_to!( indoc!( @@ -392,6 +415,7 @@ fn return_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_when_use_default() { assert_evals_to!( indoc!( @@ -419,6 +443,7 @@ fn optional_field_when_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_when_use_default_nested() { assert_evals_to!( indoc!( @@ -442,6 +467,7 @@ fn optional_field_when_use_default_nested() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_when_no_use_default() { assert_evals_to!( indoc!( @@ -462,6 +488,7 @@ fn optional_field_when_no_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_when_no_use_default_nested() { assert_evals_to!( indoc!( @@ -479,6 +506,7 @@ fn optional_field_when_no_use_default_nested() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn optional_field_let_use_default() { assert_evals_to!( indoc!( @@ -499,6 +527,7 @@ fn optional_field_let_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_let_no_use_default() { assert_evals_to!( indoc!( @@ -519,6 +548,7 @@ fn optional_field_let_no_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn optional_field_let_no_use_default_nested() { assert_evals_to!( indoc!( @@ -536,6 +566,7 @@ fn optional_field_let_no_use_default_nested() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn optional_field_function_use_default() { assert_evals_to!( indoc!( @@ -552,6 +583,7 @@ fn optional_field_function_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn optional_field_function_no_use_default() { // blocked on https://github.com/rtfeldman/roc/issues/786 @@ -572,6 +604,7 @@ fn optional_field_function_no_use_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn optional_field_function_no_use_default_nested() { // blocked on https://github.com/rtfeldman/roc/issues/786 @@ -590,6 +623,7 @@ fn optional_field_function_no_use_default_nested() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn optional_field_singleton_record() { assert_evals_to!( indoc!( @@ -604,6 +638,7 @@ fn optional_field_singleton_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn optional_field_empty_record() { assert_evals_to!( indoc!( @@ -618,6 +653,7 @@ fn optional_field_empty_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_2() { assert_evals_to!( indoc!( @@ -631,6 +667,7 @@ fn return_record_2() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_3() { assert_evals_to!( indoc!( @@ -644,6 +681,7 @@ fn return_record_3() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_4() { assert_evals_to!( indoc!( @@ -657,6 +695,7 @@ fn return_record_4() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_5() { assert_evals_to!( indoc!( @@ -670,6 +709,7 @@ fn return_record_5() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_6() { assert_evals_to!( indoc!( @@ -683,6 +723,7 @@ fn return_record_6() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_7() { assert_evals_to!( indoc!( @@ -696,6 +737,7 @@ fn return_record_7() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_float_int() { assert_evals_to!( indoc!( @@ -709,6 +751,7 @@ fn return_record_float_int() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_int_float() { assert_evals_to!( indoc!( @@ -722,6 +765,7 @@ fn return_record_int_float() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_float_float() { assert_evals_to!( indoc!( @@ -735,6 +779,7 @@ fn return_record_float_float() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_record_float_float_float() { assert_evals_to!( indoc!( @@ -748,6 +793,7 @@ fn return_record_float_float_float() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))] fn return_nested_record() { assert_evals_to!( indoc!( @@ -761,11 +807,13 @@ fn return_nested_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn accessor_twice() { assert_evals_to!(".foo { foo: 4 } + .foo { bar: 6.28, foo: 3 } ", 7, i64); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn accessor_multi_element_record() { assert_evals_to!( indoc!( @@ -779,6 +827,7 @@ fn accessor_multi_element_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn accessor_single_element_record() { assert_evals_to!( indoc!( @@ -792,6 +841,7 @@ fn accessor_single_element_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn update_record() { assert_evals_to!( indoc!( @@ -807,6 +857,7 @@ fn update_record() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn update_single_element_record() { assert_evals_to!( indoc!( @@ -822,6 +873,7 @@ fn update_single_element_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn booleans_in_record() { assert_evals_to!( indoc!("{ x: 1 == 1, y: 1 == 1 }"), @@ -846,6 +898,7 @@ fn booleans_in_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_record() { assert_evals_to!( indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"), @@ -855,6 +908,7 @@ fn alignment_in_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn blue_and_present() { assert_evals_to!( indoc!( @@ -873,6 +927,7 @@ fn blue_and_present() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn blue_and_absent() { assert_evals_to!( indoc!( @@ -891,6 +946,7 @@ fn blue_and_absent() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))] fn update_the_only_field() { assert_evals_to!( indoc!( diff --git a/compiler/test_gen/src/gen_result.rs b/compiler/test_gen/src/gen_result.rs index 6364f590cd..f06fe7ea19 100644 --- a/compiler/test_gen/src/gen_result.rs +++ b/compiler/test_gen/src/gen_result.rs @@ -1,9 +1,18 @@ -#![cfg(test)] +#![cfg(feature = "gen-llvm")] + +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; use indoc::indoc; #[test] +#[cfg(any(feature = "gen-llvm"))] fn with_default() { assert_evals_to!( indoc!( @@ -33,6 +42,7 @@ fn with_default() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn result_map() { assert_evals_to!( indoc!( @@ -66,6 +76,7 @@ fn result_map() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn result_map_err() { assert_evals_to!( indoc!( @@ -99,6 +110,7 @@ fn result_map_err() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn err_type_var() { assert_evals_to!( indoc!( @@ -113,6 +125,7 @@ fn err_type_var() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn err_type_var_annotation() { assert_evals_to!( indoc!( @@ -130,6 +143,7 @@ fn err_type_var_annotation() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn err_empty_tag_union() { assert_evals_to!( indoc!( diff --git a/compiler/test_gen/src/gen_set.rs b/compiler/test_gen/src/gen_set.rs index 41551f7c28..2cd8190ed5 100644 --- a/compiler/test_gen/src/gen_set.rs +++ b/compiler/test_gen/src/gen_set.rs @@ -1,10 +1,19 @@ -#![cfg(test)] +#![cfg(feature = "gen-llvm")] + +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; use indoc::indoc; use roc_std::RocList; #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_len() { assert_evals_to!( indoc!( @@ -18,6 +27,7 @@ fn empty_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn single_len() { assert_evals_to!( indoc!( @@ -31,6 +41,7 @@ fn single_len() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn single_to_list() { assert_evals_to!( indoc!( @@ -64,6 +75,7 @@ fn single_to_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn insert() { assert_evals_to!( indoc!( @@ -81,6 +93,7 @@ fn insert() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn remove() { assert_evals_to!( indoc!( @@ -99,6 +112,7 @@ fn remove() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn union() { assert_evals_to!( indoc!( @@ -119,6 +133,7 @@ fn union() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn difference() { assert_evals_to!( indoc!( @@ -139,6 +154,7 @@ fn difference() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn intersection() { assert_evals_to!( indoc!( @@ -159,6 +175,7 @@ fn intersection() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn walk_sum() { assert_evals_to!( indoc!( @@ -172,6 +189,7 @@ fn walk_sum() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn contains() { assert_evals_to!( indoc!( @@ -195,6 +213,7 @@ fn contains() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn from_list() { assert_evals_to!( indoc!( diff --git a/compiler/test_gen/src/gen_str.rs b/compiler/test_gen/src/gen_str.rs index aebfd70c37..28345025f1 100644 --- a/compiler/test_gen/src/gen_str.rs +++ b/compiler/test_gen/src/gen_str.rs @@ -1,11 +1,22 @@ -#![cfg(test)] +#![cfg(not(feature = "gen-wasm"))] -use crate::assert_evals_to; -use crate::assert_llvm_evals_to; +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_llvm_evals_to; + +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to; +#[cfg(feature = "gen-dev")] +use crate::helpers::dev::assert_evals_to as assert_llvm_evals_to; + +#[allow(unused_imports)] use indoc::indoc; +#[allow(unused_imports)] use roc_std::{RocList, RocStr}; #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_bigger_delimiter_small_str() { assert_evals_to!( indoc!( @@ -35,6 +46,7 @@ fn str_split_bigger_delimiter_small_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_str_concat_repeated() { assert_evals_to!( indoc!( @@ -58,6 +70,7 @@ fn str_split_str_concat_repeated() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_small_str_bigger_delimiter() { assert_evals_to!( indoc!( @@ -76,6 +89,7 @@ fn str_split_small_str_bigger_delimiter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_big_str_small_delimiter() { assert_evals_to!( indoc!( @@ -105,6 +119,7 @@ fn str_split_big_str_small_delimiter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_small_str_small_delimiter() { assert_evals_to!( indoc!( @@ -122,6 +137,7 @@ fn str_split_small_str_small_delimiter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_bigger_delimiter_big_strs() { assert_evals_to!( indoc!( @@ -137,6 +153,7 @@ fn str_split_bigger_delimiter_big_strs() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_empty_strs() { assert_evals_to!( indoc!( @@ -150,6 +167,7 @@ fn str_split_empty_strs() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_minimal_example() { assert_evals_to!( indoc!( @@ -163,6 +181,7 @@ fn str_split_minimal_example() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_small_str_big_delimiter() { assert_evals_to!( indoc!( @@ -195,6 +214,7 @@ fn str_split_small_str_big_delimiter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_split_small_str_20_char_delimiter() { assert_evals_to!( indoc!( @@ -214,6 +234,7 @@ fn str_split_small_str_20_char_delimiter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_concat_big_to_big() { assert_evals_to!( indoc!( @@ -229,6 +250,7 @@ fn str_concat_big_to_big() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_literal() { assert_llvm_evals_to!( "\"JJJJJJJJJJJJJJJ\"", @@ -255,6 +277,7 @@ fn small_str_literal() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_zeroed_literal() { // Verifies that we zero out unused bytes in the string. // This is important so that string equality tests don't randomly @@ -284,6 +307,7 @@ fn small_str_zeroed_literal() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_concat_empty_first_arg() { assert_llvm_evals_to!( r#"Str.concat "" "JJJJJJJJJJJJJJJ""#, @@ -310,6 +334,7 @@ fn small_str_concat_empty_first_arg() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_concat_empty_second_arg() { assert_llvm_evals_to!( r#"Str.concat "JJJJJJJJJJJJJJJ" """#, @@ -336,6 +361,7 @@ fn small_str_concat_empty_second_arg() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn small_str_concat_small_to_big() { assert_evals_to!( r#"Str.concat "abc" " this is longer than 15 chars""#, @@ -345,6 +371,7 @@ fn small_str_concat_small_to_big() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_concat_small_to_small_staying_small() { assert_llvm_evals_to!( r#"Str.concat "J" "JJJJJJJJJJJJJJ""#, @@ -371,6 +398,7 @@ fn small_str_concat_small_to_small_staying_small() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn small_str_concat_small_to_small_overflow_to_big() { assert_evals_to!( r#"Str.concat "abcdefghijklm" "nopqrstuvwxyz""#, @@ -380,16 +408,19 @@ fn small_str_concat_small_to_small_overflow_to_big() { } #[test] +#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))] fn str_concat_empty() { assert_evals_to!(r#"Str.concat "" """#, RocStr::default(), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn small_str_is_empty() { assert_evals_to!(r#"Str.isEmpty "abc""#, false, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn big_str_is_empty() { assert_evals_to!( r#"Str.isEmpty "this is more than 15 chars long""#, @@ -399,11 +430,13 @@ fn big_str_is_empty() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn empty_str_is_empty() { assert_evals_to!(r#"Str.isEmpty """#, true, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with() { assert_evals_to!(r#"Str.startsWith "hello world" "hell""#, true, bool); assert_evals_to!(r#"Str.startsWith "hello world" """#, true, bool); @@ -413,6 +446,7 @@ fn str_starts_with() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_code_point() { assert_evals_to!( &format!(r#"Str.startsWithCodePt "foobar" {}"#, 'f' as u32), @@ -427,6 +461,7 @@ fn str_starts_with_code_point() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_ends_with() { assert_evals_to!(r#"Str.endsWith "hello world" "world""#, true, bool); assert_evals_to!(r#"Str.endsWith "nope" "hello world""#, false, bool); @@ -434,16 +469,19 @@ fn str_ends_with() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_count_graphemes_small_str() { assert_evals_to!(r#"Str.countGraphemes "å🤔""#, 2, usize); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_count_graphemes_three_js() { assert_evals_to!(r#"Str.countGraphemes "JJJ""#, 3, usize); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_count_graphemes_big_str() { assert_evals_to!( r#"Str.countGraphemes "6🤔å🤔e¥🤔çppkd🙃1jdal🦯asdfa∆ltråø˚waia8918.,🏅jjc""#, @@ -453,6 +491,7 @@ fn str_count_graphemes_big_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_same_big_str() { assert_evals_to!( r#"Str.startsWith "123456789123456789" "123456789123456789""#, @@ -462,6 +501,7 @@ fn str_starts_with_same_big_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_different_big_str() { assert_evals_to!( r#"Str.startsWith "12345678912345678910" "123456789123456789""#, @@ -471,20 +511,24 @@ fn str_starts_with_different_big_str() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_same_small_str() { assert_evals_to!(r#"Str.startsWith "1234" "1234""#, true, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_different_small_str() { assert_evals_to!(r#"Str.startsWith "1234" "12""#, true, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_starts_with_false_small_str() { assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_int() { assert_evals_to!( r#"Str.fromInt 1234"#, @@ -518,6 +562,7 @@ fn str_from_int() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_single_ascii() { assert_evals_to!( indoc!( @@ -533,6 +578,7 @@ fn str_from_utf8_pass_single_ascii() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_many_ascii() { assert_evals_to!( indoc!( @@ -548,6 +594,7 @@ fn str_from_utf8_pass_many_ascii() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_single_unicode() { assert_evals_to!( indoc!( @@ -563,6 +610,7 @@ fn str_from_utf8_pass_single_unicode() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_many_unicode() { assert_evals_to!( indoc!( @@ -578,6 +626,7 @@ fn str_from_utf8_pass_many_unicode() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_single_grapheme() { assert_evals_to!( indoc!( @@ -593,6 +642,7 @@ fn str_from_utf8_pass_single_grapheme() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_many_grapheme() { assert_evals_to!( indoc!( @@ -608,6 +658,7 @@ fn str_from_utf8_pass_many_grapheme() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_pass_all() { assert_evals_to!( indoc!( @@ -623,6 +674,7 @@ fn str_from_utf8_pass_all() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_invalid_start_byte() { assert_evals_to!( indoc!( @@ -642,6 +694,7 @@ fn str_from_utf8_fail_invalid_start_byte() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_unexpected_end_of_sequence() { assert_evals_to!( indoc!( @@ -661,6 +714,7 @@ fn str_from_utf8_fail_unexpected_end_of_sequence() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_expected_continuation() { assert_evals_to!( indoc!( @@ -680,6 +734,7 @@ fn str_from_utf8_fail_expected_continuation() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_overlong_encoding() { assert_evals_to!( indoc!( @@ -699,6 +754,7 @@ fn str_from_utf8_fail_overlong_encoding() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_codepoint_too_large() { assert_evals_to!( indoc!( @@ -718,6 +774,7 @@ fn str_from_utf8_fail_codepoint_too_large() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_fail_surrogate_half() { assert_evals_to!( indoc!( @@ -737,6 +794,7 @@ fn str_from_utf8_fail_surrogate_half() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_equality() { assert_evals_to!(r#""a" == "a""#, true, bool); assert_evals_to!( @@ -761,6 +819,7 @@ fn str_clone() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_recursive_literal() { assert_evals_to!( indoc!( @@ -791,6 +850,7 @@ fn nested_recursive_literal() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_join_comma_small() { assert_evals_to!( r#"Str.joinWith ["1", "2"] ", " "#, @@ -800,6 +860,7 @@ fn str_join_comma_small() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_join_comma_big() { assert_evals_to!( r#"Str.joinWith ["10000000", "2000000", "30000000"] ", " "#, @@ -809,16 +870,19 @@ fn str_join_comma_big() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_join_comma_single() { assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_float() { assert_evals_to!(r#"Str.fromFloat 3.14"#, RocStr::from("3.14"), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_to_utf8() { assert_evals_to!( r#"Str.toUtf8 "hello""#, @@ -836,6 +900,7 @@ fn str_to_utf8() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range() { assert_evals_to!( indoc!( @@ -852,6 +917,7 @@ fn str_from_utf8_range() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_slice() { assert_evals_to!( indoc!( @@ -868,6 +934,7 @@ fn str_from_utf8_range_slice() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_slice_not_end() { assert_evals_to!( indoc!( @@ -884,6 +951,7 @@ fn str_from_utf8_range_slice_not_end() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_order_does_not_matter() { assert_evals_to!( indoc!( @@ -900,6 +968,7 @@ fn str_from_utf8_range_order_does_not_matter() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_out_of_bounds_start_value() { assert_evals_to!( indoc!( @@ -917,6 +986,7 @@ fn str_from_utf8_range_out_of_bounds_start_value() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_count_too_high() { assert_evals_to!( indoc!( @@ -934,6 +1004,7 @@ fn str_from_utf8_range_count_too_high() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_from_utf8_range_count_too_high_for_start() { assert_evals_to!( indoc!( @@ -951,6 +1022,7 @@ fn str_from_utf8_range_count_too_high_for_start() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_repeat_small() { assert_evals_to!( indoc!(r#"Str.repeat "Roc" 3"#), @@ -960,6 +1032,7 @@ fn str_repeat_small() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_repeat_big() { assert_evals_to!( indoc!(r#"Str.repeat "more than 16 characters" 2"#), @@ -969,26 +1042,31 @@ fn str_repeat_big() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_repeat_empty_string() { assert_evals_to!(indoc!(r#"Str.repeat "" 3"#), RocStr::from(""), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_repeat_zero_times() { assert_evals_to!(indoc!(r#"Str.repeat "Roc" 0"#), RocStr::from(""), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_empty_string() { assert_evals_to!(indoc!(r#"Str.trim """#), RocStr::from(""), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_small_blank_string() { assert_evals_to!(indoc!(r#"Str.trim " ""#), RocStr::from(""), RocStr); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_small_to_small() { assert_evals_to!( indoc!(r#"Str.trim " hello world ""#), @@ -998,6 +1076,7 @@ fn str_trim_small_to_small() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_large_to_large_unique() { assert_evals_to!( indoc!(r#"Str.trim (Str.concat " " "hello world from a large string ")"#), @@ -1007,6 +1086,7 @@ fn str_trim_large_to_large_unique() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_large_to_small_unique() { assert_evals_to!( indoc!(r#"Str.trim (Str.concat " " "hello world ")"#), @@ -1016,6 +1096,7 @@ fn str_trim_large_to_small_unique() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_large_to_large_shared() { assert_evals_to!( indoc!( @@ -1035,6 +1116,7 @@ fn str_trim_large_to_large_shared() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_large_to_small_shared() { assert_evals_to!( indoc!( @@ -1054,6 +1136,7 @@ fn str_trim_large_to_small_shared() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn str_trim_small_to_small_shared() { assert_evals_to!( indoc!( diff --git a/compiler/test_gen/src/gen_tags.rs b/compiler/test_gen/src/gen_tags.rs index fe50a16cde..7626ef4d03 100644 --- a/compiler/test_gen/src/gen_tags.rs +++ b/compiler/test_gen/src/gen_tags.rs @@ -1,11 +1,20 @@ -#![cfg(test)] +#![cfg(feature = "gen-llvm")] + +#[cfg(feature = "gen-llvm")] +use crate::helpers::llvm::assert_evals_to; + +// #[cfg(feature = "gen-dev")] +// use crate::helpers::dev::assert_evals_to; + +// #[cfg(feature = "gen-wasm")] +// use crate::helpers::wasm::assert_evals_to; -use crate::assert_evals_to; // use crate::assert_wasm_evals_to as assert_evals_to; use indoc::indoc; use roc_std::{RocList, RocStr}; #[test] +#[cfg(any(feature = "gen-llvm"))] fn width_and_alignment_u8_u8() { use roc_mono::layout::Builtin; use roc_mono::layout::Layout; @@ -23,6 +32,7 @@ fn width_and_alignment_u8_u8() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_nothing_ir() { assert_evals_to!( indoc!( @@ -42,6 +52,7 @@ fn applied_tag_nothing_ir() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_nothing() { assert_evals_to!( indoc!( @@ -61,6 +72,7 @@ fn applied_tag_nothing() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_just() { assert_evals_to!( indoc!( @@ -79,6 +91,7 @@ fn applied_tag_just() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_just_ir() { assert_evals_to!( indoc!( @@ -97,6 +110,7 @@ fn applied_tag_just_ir() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_just_enum() { assert_evals_to!( indoc!( @@ -120,6 +134,7 @@ fn applied_tag_just_enum() { } // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn raw_result() { // assert_evals_to!( // indoc!( @@ -134,8 +149,8 @@ fn applied_tag_just_enum() { // i8 // ); // } - #[test] +#[cfg(any(feature = "gen-llvm"))] fn true_is_true() { assert_evals_to!( indoc!( @@ -152,6 +167,7 @@ fn true_is_true() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn false_is_false() { assert_evals_to!( indoc!( @@ -168,6 +184,7 @@ fn false_is_false() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn basic_enum() { assert_evals_to!( indoc!( @@ -189,6 +206,7 @@ fn basic_enum() { } // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn linked_list_empty() { // assert_evals_to!( // indoc!( @@ -207,6 +225,7 @@ fn basic_enum() { // } // // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn linked_list_singleton() { // assert_evals_to!( // indoc!( @@ -225,6 +244,7 @@ fn basic_enum() { // } // // #[test] +#[cfg(any(feature = "gen-llvm"))] // fn linked_list_is_empty() { // assert_evals_to!( // indoc!( @@ -244,8 +264,8 @@ fn basic_enum() { // bool // ); // } - #[test] +#[cfg(any(feature = "gen-llvm"))] fn even_odd() { assert_evals_to!( indoc!( @@ -271,6 +291,7 @@ fn even_odd() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_literal_true() { assert_evals_to!( indoc!( @@ -284,6 +305,7 @@ fn gen_literal_true() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn gen_if_float() { assert_evals_to!( indoc!( @@ -296,6 +318,7 @@ fn gen_if_float() { ); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_on_nothing() { assert_evals_to!( indoc!( @@ -314,6 +337,7 @@ fn when_on_nothing() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_on_just() { assert_evals_to!( indoc!( @@ -332,6 +356,7 @@ fn when_on_just() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_on_result() { assert_evals_to!( indoc!( @@ -350,6 +375,7 @@ fn when_on_result() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_on_these() { assert_evals_to!( indoc!( @@ -371,6 +397,7 @@ fn when_on_these() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn match_on_two_values() { // this will produce a Chain internally assert_evals_to!( @@ -387,6 +414,7 @@ fn match_on_two_values() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn pair_with_guard_pattern() { assert_evals_to!( indoc!( @@ -403,6 +431,7 @@ fn pair_with_guard_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn result_with_guard_pattern() { // This test revealed an issue with hashing Test values assert_evals_to!( @@ -423,6 +452,7 @@ fn result_with_guard_pattern() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn maybe_is_just() { assert_evals_to!( indoc!( @@ -447,6 +477,7 @@ fn maybe_is_just() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn maybe_is_just_nested() { assert_evals_to!( indoc!( @@ -468,6 +499,7 @@ fn maybe_is_just_nested() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_pattern_match() { assert_evals_to!( indoc!( @@ -488,6 +520,7 @@ fn nested_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_vanilla() { assert_evals_to!( indoc!( @@ -503,6 +536,7 @@ fn if_guard_vanilla() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn when_on_single_value_tag() { // this fails because the switched-on symbol is not defined @@ -520,6 +554,7 @@ fn when_on_single_value_tag() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_multiple() { assert_evals_to!( indoc!( @@ -540,6 +575,7 @@ fn if_guard_multiple() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_constructor_switch() { assert_evals_to!( indoc!( @@ -583,6 +619,7 @@ fn if_guard_constructor_switch() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_constructor_chain() { assert_evals_to!( indoc!( @@ -599,6 +636,7 @@ fn if_guard_constructor_chain() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_pattern_false() { assert_evals_to!( indoc!( @@ -617,6 +655,7 @@ fn if_guard_pattern_false() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_switch() { assert_evals_to!( indoc!( @@ -635,6 +674,7 @@ fn if_guard_switch() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_pattern_true() { assert_evals_to!( indoc!( @@ -653,6 +693,7 @@ fn if_guard_pattern_true() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn if_guard_exhaustiveness() { assert_evals_to!( indoc!( @@ -671,6 +712,7 @@ fn if_guard_exhaustiveness() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn when_on_enum() { assert_evals_to!( indoc!( @@ -692,6 +734,7 @@ fn when_on_enum() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn pattern_matching_unit() { assert_evals_to!( indoc!( @@ -750,6 +793,7 @@ fn pattern_matching_unit() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn one_element_tag() { assert_evals_to!( indoc!( @@ -766,6 +810,7 @@ fn one_element_tag() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_tag_union() { assert_evals_to!( indoc!( @@ -786,6 +831,7 @@ fn nested_tag_union() { ); } #[test] +#[cfg(any(feature = "gen-llvm"))] fn unit_type() { assert_evals_to!( indoc!( @@ -804,6 +850,7 @@ fn unit_type() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_record_load() { assert_evals_to!( indoc!( @@ -821,6 +868,7 @@ fn nested_record_load() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn join_point_if() { assert_evals_to!( indoc!( @@ -837,6 +885,7 @@ fn join_point_if() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn join_point_when() { assert_evals_to!( indoc!( @@ -862,6 +911,7 @@ fn join_point_when() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn join_point_with_cond_expr() { assert_evals_to!( indoc!( @@ -900,6 +950,7 @@ fn join_point_with_cond_expr() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_single_tag_construction() { assert_evals_to!(indoc!("Three (1 == 1) 32"), (32i64, true), (i64, bool)); @@ -911,6 +962,7 @@ fn alignment_in_single_tag_construction() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_single_tag_pattern_match() { assert_evals_to!( indoc!( @@ -942,6 +994,7 @@ fn alignment_in_single_tag_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_multi_tag_construction_two() { assert_evals_to!( indoc!( @@ -959,6 +1012,7 @@ fn alignment_in_multi_tag_construction_two() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_multi_tag_construction_three() { assert_evals_to!( indoc!( @@ -975,6 +1029,7 @@ fn alignment_in_multi_tag_construction_three() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn alignment_in_multi_tag_pattern_match() { assert_evals_to!( indoc!( @@ -1013,6 +1068,7 @@ fn alignment_in_multi_tag_pattern_match() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn phantom_polymorphic() { // see https://github.com/rtfeldman/roc/issues/786 and below @@ -1038,6 +1094,7 @@ fn phantom_polymorphic() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[ignore] fn phantom_polymorphic_record() { // see https://github.com/rtfeldman/roc/issues/786 @@ -1065,6 +1122,7 @@ fn phantom_polymorphic_record() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn result_never() { assert_evals_to!( indoc!( @@ -1086,6 +1144,7 @@ fn result_never() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn nested_recursive_literal() { assert_evals_to!( indoc!( @@ -1105,6 +1164,7 @@ fn nested_recursive_literal() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn newtype_wrapper() { assert_evals_to!( indoc!( @@ -1128,6 +1188,7 @@ fn newtype_wrapper() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_function() { assert_evals_to!( indoc!( @@ -1147,6 +1208,7 @@ fn applied_tag_function() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_function_result() { assert_evals_to!( indoc!( @@ -1166,6 +1228,7 @@ fn applied_tag_function_result() { } #[test] +#[cfg(any(feature = "gen-llvm"))] fn applied_tag_function_linked_list() { assert_evals_to!( indoc!( @@ -1186,6 +1249,7 @@ fn applied_tag_function_linked_list() { } #[test] +#[cfg(any(feature = "gen-llvm"))] #[should_panic(expected = "")] fn tag_must_be_its_own_type() { assert_evals_to!( diff --git a/compiler/test_dev/src/helpers/eval.rs b/compiler/test_gen/src/helpers/dev.rs similarity index 97% rename from compiler/test_dev/src/helpers/eval.rs rename to compiler/test_gen/src/helpers/dev.rs index 588854f78c..d49d602931 100644 --- a/compiler/test_dev/src/helpers/eval.rs +++ b/compiler/test_gen/src/helpers/dev.rs @@ -210,7 +210,7 @@ pub fn helper( (main_fn_name, delayed_errors, lib) } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_evals_to { ($src:expr, $expected:expr, $ty:ty) => {{ assert_evals_to!($src, $expected, $ty, (|val| val)); @@ -237,7 +237,7 @@ macro_rules! assert_evals_to { let arena = Bump::new(); let (main_fn_name, errors, lib) = - $crate::helpers::eval::helper(&arena, $src, stdlib, $leak, $lazy_literals); + $crate::helpers::dev::helper(&arena, $src, stdlib, $leak, $lazy_literals); let transform = |success| { let expected = $expected; @@ -247,3 +247,6 @@ macro_rules! assert_evals_to { run_jit_function_raw!(lib, main_fn_name, $ty, transform, errors) }; } + +#[allow(unused_imports)] +pub(crate) use assert_evals_to; diff --git a/compiler/test_wasm_util/src/from_wasm32_memory.rs b/compiler/test_gen/src/helpers/from_wasm32_memory.rs similarity index 100% rename from compiler/test_wasm_util/src/from_wasm32_memory.rs rename to compiler/test_gen/src/helpers/from_wasm32_memory.rs diff --git a/compiler/test_gen/src/helpers/eval.rs b/compiler/test_gen/src/helpers/llvm.rs similarity index 90% rename from compiler/test_gen/src/helpers/eval.rs rename to compiler/test_gen/src/helpers/llvm.rs index ac0fefc0fb..4f665232e1 100644 --- a/compiler/test_gen/src/helpers/eval.rs +++ b/compiler/test_gen/src/helpers/llvm.rs @@ -1,3 +1,4 @@ +use crate::helpers::from_wasm32_memory::FromWasm32Memory; use inkwell::module::Module; use libloading::Library; use roc_build::link::module_to_dylib; @@ -10,7 +11,6 @@ use roc_module::symbol::Symbol; use roc_mono::ir::OptLevel; use roc_types::subs::VarStore; use target_lexicon::Triple; -use test_wasm_util::from_wasm32_memory::FromWasm32Memory; fn promote_expr_to_module(src: &str) -> String { let mut buffer = String::from("app \"test\" provides [ main ] to \"./platform\"\n\nmain =\n"); @@ -469,7 +469,7 @@ where let stdlib = arena.alloc(roc_builtins::std::standard_stdlib()); let is_gen_test = true; - let instance = crate::helpers::eval::helper_wasm( + let instance = crate::helpers::llvm::helper_wasm( &arena, src, stdlib, @@ -480,7 +480,7 @@ where let memory = instance.exports.get_memory("memory").unwrap(); - crate::helpers::eval::MEMORY.with(|f| { + crate::helpers::llvm::MEMORY.with(|f| { *f.borrow_mut() = Some(unsafe { std::mem::transmute(memory) }); }); @@ -494,7 +494,7 @@ where _ => panic!(), }; - let output = ::decode( + let output = ::decode( memory, // skip the RocCallResult tag id address as u32 + 8, @@ -505,10 +505,10 @@ where } } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_wasm_evals_to { ($src:expr, $expected:expr, $ty:ty, $transform:expr, $ignore_problems:expr) => { - match $crate::helpers::eval::assert_wasm_evals_to_help::<$ty>($src, $ignore_problems) { + match $crate::helpers::llvm::assert_wasm_evals_to_help::<$ty>($src, $ignore_problems) { Err(msg) => panic!("Wasm test failed: {:?}", msg), Ok(actual) => { #[allow(clippy::bool_assert_comparison)] @@ -518,15 +518,21 @@ macro_rules! assert_wasm_evals_to { }; ($src:expr, $expected:expr, $ty:ty) => { - $crate::assert_wasm_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity, false); + $crate::helpers::llvm::assert_wasm_evals_to!( + $src, + $expected, + $ty, + $crate::helpers::llvm::identity, + false + ); }; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { - $crate::assert_wasm_evals_to!($src, $expected, $ty, $transform, false); + $crate::helpers::llvm::assert_wasm_evals_to!($src, $expected, $ty, $transform, false); }; } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_llvm_evals_to { ($src:expr, $expected:expr, $ty:ty, $transform:expr, $ignore_problems:expr) => { use bumpalo::Bump; @@ -540,7 +546,7 @@ macro_rules! assert_llvm_evals_to { let stdlib = arena.alloc(roc_builtins::std::standard_stdlib()); let is_gen_test = true; - let (main_fn_name, errors, lib) = $crate::helpers::eval::helper( + let (main_fn_name, errors, lib) = $crate::helpers::llvm::helper( &arena, $src, stdlib, @@ -559,26 +565,32 @@ macro_rules! assert_llvm_evals_to { }; ($src:expr, $expected:expr, $ty:ty) => { - $crate::assert_llvm_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity, false); + $crate::helpers::llvm::assert_llvm_evals_to!( + $src, + $expected, + $ty, + $crate::helpers::llvm::identity, + false + ); }; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { - $crate::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); + $crate::helpers::llvm::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); }; } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_evals_to { ($src:expr, $expected:expr, $ty:ty) => {{ - assert_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity); + assert_evals_to!($src, $expected, $ty, $crate::helpers::llvm::identity); }}; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { // Same as above, except with an additional transformation argument. { #[cfg(feature = "wasm-cli-run")] - $crate::assert_wasm_evals_to!($src, $expected, $ty, $transform, false); + $crate::helpers::llvm::assert_wasm_evals_to!($src, $expected, $ty, $transform, false); - $crate::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); + $crate::helpers::llvm::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); } }; } @@ -588,18 +600,32 @@ pub fn identity(value: T) -> T { value } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_non_opt_evals_to { ($src:expr, $expected:expr, $ty:ty) => {{ - $crate::assert_llvm_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity); + $crate::helpers::llvm::assert_llvm_evals_to!( + $src, + $expected, + $ty, + $crate::helpers::llvm::identity + ); }}; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { // Same as above, except with an additional transformation argument. { - $crate::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); + $crate::helpers::llvm::assert_llvm_evals_to!($src, $expected, $ty, $transform, false); } }; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => {{ - $crate::assert_llvm_evals_to!($src, $expected, $ty, $transform); + $crate::helpers::llvm::assert_llvm_evals_to!($src, $expected, $ty, $transform); }}; } + +#[allow(unused_imports)] +pub(crate) use assert_evals_to; +#[allow(unused_imports)] +pub(crate) use assert_llvm_evals_to; +#[allow(unused_imports)] +pub(crate) use assert_non_opt_evals_to; +#[allow(unused_imports)] +pub(crate) use assert_wasm_evals_to; diff --git a/compiler/test_gen/src/helpers/mod.rs b/compiler/test_gen/src/helpers/mod.rs index 7e538193f7..48ffb29f55 100644 --- a/compiler/test_gen/src/helpers/mod.rs +++ b/compiler/test_gen/src/helpers/mod.rs @@ -1,7 +1,14 @@ extern crate bumpalo; -#[macro_use] -pub mod eval; +#[cfg(feature = "gen-dev")] +pub mod dev; +pub mod from_wasm32_memory; +#[cfg(feature = "gen-llvm")] +pub mod llvm; +#[cfg(feature = "gen-wasm")] +pub mod wasm; +#[cfg(feature = "gen-wasm")] +pub mod wasm32_test_result; /// Used in the with_larger_debug_stack() function, for tests that otherwise /// run out of stack space in debug builds (but don't in --release builds) diff --git a/compiler/test_wasm/src/helpers/eval.rs b/compiler/test_gen/src/helpers/wasm.rs similarity index 89% rename from compiler/test_wasm/src/helpers/eval.rs rename to compiler/test_gen/src/helpers/wasm.rs index d87339b2d4..368515496c 100644 --- a/compiler/test_wasm/src/helpers/eval.rs +++ b/compiler/test_gen/src/helpers/wasm.rs @@ -2,10 +2,10 @@ use std::cell::Cell; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; +use crate::helpers::from_wasm32_memory::FromWasm32Memory; use crate::helpers::wasm32_test_result::Wasm32TestResult; use roc_can::builtins::builtin_defs_map; use roc_collections::all::{MutMap, MutSet}; -use test_wasm_util::from_wasm32_memory::FromWasm32Memory; const TEST_WRAPPER_NAME: &str = "test_wrapper"; @@ -169,7 +169,7 @@ where // NOTE the stdlib must be in the arena; just taking a reference will segfault let stdlib = arena.alloc(roc_builtins::std::standard_stdlib()); - let instance = crate::helpers::eval::helper_wasm(&arena, src, stdlib, &expected); + let instance = crate::helpers::wasm::helper_wasm(&arena, src, stdlib, &expected); let memory = instance.exports.get_memory("memory").unwrap(); @@ -190,10 +190,10 @@ where } } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_wasm_evals_to { ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { - match $crate::helpers::eval::assert_wasm_evals_to_help::<$ty>($src, $expected) { + match $crate::helpers::wasm::assert_wasm_evals_to_help::<$ty>($src, $expected) { Err(msg) => panic!("{:?}", msg), Ok(actual) => { assert_eq!($transform(actual), $expected) @@ -202,23 +202,28 @@ macro_rules! assert_wasm_evals_to { }; ($src:expr, $expected:expr, $ty:ty) => { - $crate::assert_wasm_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity); + $crate::helpers::wasm::assert_wasm_evals_to!( + $src, + $expected, + $ty, + $crate::helpers::wasm::identity + ); }; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { - $crate::assert_wasm_evals_to!($src, $expected, $ty, $transform); + $crate::helpers::wasm::assert_wasm_evals_to!($src, $expected, $ty, $transform); }; } -#[macro_export] +#[allow(unused_macros)] macro_rules! assert_evals_to { ($src:expr, $expected:expr, $ty:ty) => {{ - assert_evals_to!($src, $expected, $ty, $crate::helpers::eval::identity); + assert_evals_to!($src, $expected, $ty, $crate::helpers::wasm::identity); }}; ($src:expr, $expected:expr, $ty:ty, $transform:expr) => { // Same as above, except with an additional transformation argument. { - $crate::assert_wasm_evals_to!($src, $expected, $ty, $transform); + $crate::helpers::wasm::assert_wasm_evals_to!($src, $expected, $ty, $transform); } }; } @@ -227,3 +232,8 @@ macro_rules! assert_evals_to { pub fn identity(value: T) -> T { value } + +#[allow(unused_imports)] +pub(crate) use assert_evals_to; +#[allow(unused_imports)] +pub(crate) use assert_wasm_evals_to; diff --git a/compiler/test_wasm/src/helpers/wasm32_test_result.rs b/compiler/test_gen/src/helpers/wasm32_test_result.rs similarity index 98% rename from compiler/test_wasm/src/helpers/wasm32_test_result.rs rename to compiler/test_gen/src/helpers/wasm32_test_result.rs index a8626770f5..fb6d2e4d9d 100644 --- a/compiler/test_wasm/src/helpers/wasm32_test_result.rs +++ b/compiler/test_gen/src/helpers/wasm32_test_result.rs @@ -1,11 +1,11 @@ use bumpalo::collections::Vec; +use crate::helpers::from_wasm32_memory::FromWasm32Memory; use roc_gen_wasm::wasm_module::opcodes; use roc_gen_wasm::wasm_module::{ Align, CodeBuilder, Export, ExportType, LocalId, Signature, ValueType, WasmModule, }; use roc_std::{RocDec, RocList, RocOrder, RocStr}; -use test_wasm_util::from_wasm32_memory::FromWasm32Memory; pub trait Wasm32TestResult { fn insert_test_wrapper<'a>( @@ -101,6 +101,7 @@ wasm_test_result_primitive!(u32, i32_store, Align::Bytes4); wasm_test_result_primitive!(i32, i32_store, Align::Bytes4); wasm_test_result_primitive!(u64, i64_store, Align::Bytes8); wasm_test_result_primitive!(i64, i64_store, Align::Bytes8); +wasm_test_result_primitive!(usize, i32_store, Align::Bytes4); wasm_test_result_primitive!(f32, f32_store, Align::Bytes8); wasm_test_result_primitive!(f64, f64_store, Align::Bytes8); diff --git a/compiler/test_gen/src/tests.rs b/compiler/test_gen/src/tests.rs index c39c2a09d7..5dfff1ff81 100644 --- a/compiler/test_gen/src/tests.rs +++ b/compiler/test_gen/src/tests.rs @@ -10,8 +10,48 @@ pub mod gen_list; pub mod gen_num; pub mod gen_primitives; pub mod gen_records; -pub mod gen_result; pub mod gen_set; pub mod gen_str; pub mod gen_tags; mod helpers; +pub mod wasm_str; + +use core::ffi::c_void; +#[no_mangle] +pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void { + libc::malloc(size) +} + +#[no_mangle] +pub unsafe fn roc_realloc( + c_ptr: *mut c_void, + new_size: usize, + _old_size: usize, + _alignment: u32, +) -> *mut c_void { + libc::realloc(c_ptr, new_size) +} + +#[no_mangle] +pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) { + libc::free(c_ptr) +} + +#[no_mangle] +pub unsafe fn roc_panic(c_ptr: *mut c_void, tag_id: u32) { + use roc_gen_llvm::llvm::build::PanicTagId; + + use std::convert::TryFrom; + use std::ffi::CStr; + use std::os::raw::c_char; + + match PanicTagId::try_from(tag_id) { + Ok(PanicTagId::NullTerminatedString) => { + let slice = CStr::from_ptr(c_ptr as *const c_char); + let string = slice.to_str().unwrap(); + eprintln!("Roc hit a panic: {}", string); + std::process::exit(1); + } + Err(_) => unreachable!(), + } +} diff --git a/compiler/test_wasm/src/wasm_str.rs b/compiler/test_gen/src/wasm_str.rs similarity index 98% rename from compiler/test_wasm/src/wasm_str.rs rename to compiler/test_gen/src/wasm_str.rs index 571fb44a87..d893f362f1 100644 --- a/compiler/test_wasm/src/wasm_str.rs +++ b/compiler/test_gen/src/wasm_str.rs @@ -1,6 +1,16 @@ -#![cfg(test)] +// Wasm pointers are only 32bit. This effects RocStr. +// These are versions of the str tests assuming 32bit pointers. +#![cfg(not(feature = "gen-dev"))] -use crate::assert_evals_to; +// TODO: We need to make these tests work with the llvm wasm backend. + +// #[cfg(feature = "gen-llvm")] +// use crate::helpers::llvm::assert_wasm_evals_to as assert_evals_to; + +#[cfg(feature = "gen-wasm")] +use crate::helpers::wasm::assert_evals_to; + +#[allow(unused_imports)] use indoc::indoc; // use roc_std::RocStr; @@ -228,6 +238,7 @@ use indoc::indoc; // } #[test] +#[cfg(any(feature = "gen-wasm"))] fn small_str_literal() { assert_evals_to!( "\"JJJJJJJ\"", @@ -237,6 +248,7 @@ fn small_str_literal() { } #[test] +#[cfg(any(feature = "gen-wasm"))] fn small_str_zeroed_literal() { // Verifies that we zero out unused bytes in the string. // This is important so that string equality tests don't randomly diff --git a/compiler/test_wasm/Cargo.toml b/compiler/test_wasm/Cargo.toml deleted file mode 100644 index c053f529d5..0000000000 --- a/compiler/test_wasm/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "test_wasm" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[[test]] -name = "test_wasm" -path = "src/tests.rs" - -[dev-dependencies] -# roc_module = { path = "../module" } -# roc_mono = { path = "../mono" } - -wasmer = { version = "2.0.0", default-features = false, features = ["default-cranelift", "default-universal"] } -wasmer-wasi = "2.0.0" - -roc_collections = { path = "../collections" } -roc_std = { path = "../../roc_std" } -bumpalo = { version = "3.8.0", features = ["collections"] } -roc_gen_wasm = { path = "../gen_wasm" } -roc_can = { path = "../can" } -roc_builtins = { path = "../builtins" } -roc_load = { path = "../load" } -roc_types = { path = "../types" } -roc_module = { path = "../module" } -test_wasm_util = { path = "../test_wasm_util" } -indoc = "1.0.3" -libc = "0.2.106" -target-lexicon = "0.12.2" diff --git a/compiler/test_wasm/src/helpers/mod.rs b/compiler/test_wasm/src/helpers/mod.rs deleted file mode 100644 index 5627bb930a..0000000000 --- a/compiler/test_wasm/src/helpers/mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -#[macro_use] -pub mod eval; -pub mod wasm32_test_result; - -/// Used in the with_larger_debug_stack() function, for tests that otherwise -/// run out of stack space in debug builds (but don't in --release builds) -#[allow(dead_code)] -const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024; - -/// Without this, some tests pass in `cargo test --release` but fail without -/// the --release flag because they run out of stack space. This increases -/// stack size for debug builds only, while leaving the stack space at the default -/// amount for release builds. -#[allow(dead_code)] -#[cfg(debug_assertions)] -pub fn with_larger_debug_stack(run_test: F) -where - F: FnOnce(), - F: Send, - F: 'static, -{ - std::thread::Builder::new() - .stack_size(EXPANDED_STACK_SIZE) - .spawn(run_test) - .expect("Error while spawning expanded dev stack size thread") - .join() - .expect("Error while joining expanded dev stack size thread") -} - -/// In --release builds, don't increase the stack size. Run the test normally. -/// This way, we find out if any of our tests are blowing the stack even after -/// optimizations in release builds. -#[allow(dead_code)] -#[cfg(not(debug_assertions))] -#[inline(always)] -pub fn with_larger_debug_stack(run_test: F) -where - F: FnOnce() -> (), - F: Send, - F: 'static, -{ - run_test() -} diff --git a/compiler/test_wasm/src/tests.rs b/compiler/test_wasm/src/tests.rs deleted file mode 100644 index f990ef3e3b..0000000000 --- a/compiler/test_wasm/src/tests.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod helpers; -pub mod wasm_num; -pub mod wasm_records; -pub mod wasm_str; diff --git a/compiler/test_wasm/src/wasm_num.rs b/compiler/test_wasm/src/wasm_num.rs deleted file mode 100644 index abd2fb6d2b..0000000000 --- a/compiler/test_wasm/src/wasm_num.rs +++ /dev/null @@ -1,1052 +0,0 @@ -#![cfg(all(test, any(target_os = "linux", target_os = "macos"), any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] -use crate::assert_evals_to; -use indoc::indoc; - -#[test] -fn i64_values() { - assert_evals_to!("0", 0, i64); - assert_evals_to!("-0", 0, i64); - assert_evals_to!("-1", -1, i64); - assert_evals_to!("1", 1, i64); - assert_evals_to!("9_000_000_000_000", 9_000_000_000_000, i64); - assert_evals_to!("-9_000_000_000_000", -9_000_000_000_000, i64); - assert_evals_to!("0b1010", 0b1010, i64); - assert_evals_to!("0o17", 0o17, i64); - assert_evals_to!("0x1000_0000_0000_0000", 0x1000_0000_0000_0000, i64); -} - -#[test] -fn f64_values() { - assert_evals_to!("0.0", 0.0, f64); - assert_evals_to!("-0.0", 0.0, f64); - assert_evals_to!("1.0", 1.0, f64); - assert_evals_to!("-1.0", -1.0, f64); - assert_evals_to!("3.1415926535897932", 3.141_592_653_589_793, f64); - assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64); - assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64); -} - -#[test] -fn i8_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : I8 - x = 0x7f + 0x7f - - x - "# - ), - -2, - i8 - ); -} - -#[test] -fn i16_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : I16 - x = 0x7fff + 0x7fff - - x - "# - ), - -2, - i16 - ); -} - -#[test] -fn i32_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : I32 - x = 0x7fffffff + 0x7fffffff - - x - "# - ), - -2, - i32 - ); -} - -#[test] -fn u8_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : U8 - x = 0xff + 0xff - - x - "# - ), - 0xfe, - u8 - ); -} - -#[test] -fn u16_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : U16 - x = 0xffff + 0xffff - - x - "# - ), - 0xfffe, - u16 - ); -} -#[test] -fn u32_add_wrap() { - assert_evals_to!( - indoc!( - r#" - x : U32 - x = 0xffffffff + 0xffffffff - - x - "# - ), - 0xfffffffe, - u32 - ); -} - -#[test] -fn gen_add_i64() { - assert_evals_to!( - indoc!( - r#" - 1 + 2 + 3 - "# - ), - 6, - i64 - ); -} - -#[test] -fn if_then_else() { - assert_evals_to!( - indoc!( - r#" - cond : Bool - cond = True - - if cond then - 0 - else - 1 - "# - ), - 0, - i64 - ); -} - -#[test] -fn rgb_red() { - assert_evals_to!( - indoc!( - r#" - when Red is - Red -> 111 - Green -> 222 - Blue -> 333 - "# - ), - 111, - i64 - ); -} - -#[test] -fn rgb_green() { - assert_evals_to!( - indoc!( - r#" - when Green is - Red -> 111 - Green -> 222 - Blue -> 333 - "# - ), - 222, - i64 - ); -} - -#[test] -fn rgb_blue() { - assert_evals_to!( - indoc!( - r#" - when Blue is - Red -> 111 - Green -> 222 - Blue -> 333 - "# - ), - 333, - i64 - ); -} - -#[test] -fn join_point() { - assert_evals_to!( - indoc!( - r#" - x = if True then 111 else 222 - - x + 123 - "# - ), - 234, - i64 - ); -} - -#[test] -fn factorial() { - assert_evals_to!( - indoc!( - r#" - app "test" provides [ main ] to "./platform" - - fac : I32, I32 -> I32 - fac = \n, accum -> - if n > 1 then - fac (n - 1) (n * accum) - else - accum - - main : I32 - main = fac 8 1 - "# - ), - 40_320, - i32 - ); -} - -#[test] -fn gen_add_f64() { - assert_evals_to!( - indoc!( - r#" - 1.1 + 2.4 + 3 - "# - ), - 6.5, - f64 - ); -} - -#[test] -fn gen_sub_i64() { - assert_evals_to!( - indoc!( - r#" - 1 - 2 - 3 - "# - ), - -4, - i64 - ); -} - -#[test] -fn gen_mul_i64() { - assert_evals_to!( - indoc!( - r#" - 2 * 4 * 6 - "# - ), - 48, - i64 - ); -} - -#[test] -fn i64_force_stack() { - // This claims 33 registers. One more than Arm and RISC-V, and many more than x86-64. - assert_evals_to!( - indoc!( - r#" - a = 0 - b = 1 - c = 2 - d = 3 - e = 4 - f = 5 - g = 6 - h = 7 - i = 8 - j = 9 - k = 10 - l = 11 - m = 12 - n = 13 - o = 14 - p = 15 - q = 16 - r = 17 - s = 18 - t = 19 - u = 20 - v = 21 - w = 22 - x = 23 - y = 24 - z = 25 - aa = 26 - ab = 27 - ac = 28 - ad = 29 - ae = 30 - af = 31 - ag = 32 - - a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z + aa + ab + ac + ad + ae + af + ag - "# - ), - 528, - i64 - ); -} - -// #[test] -// fn i64_abs() { -// assert_evals_to!("Num.abs -6", 6, i64); -// assert_evals_to!("Num.abs 7", 7, i64); -// assert_evals_to!("Num.abs 0", 0, i64); -// assert_evals_to!("Num.abs -0", 0, i64); -// assert_evals_to!("Num.abs -1", 1, i64); -// assert_evals_to!("Num.abs 1", 1, i64); -// assert_evals_to!("Num.abs 9_000_000_000_000", 9_000_000_000_000, i64); -// assert_evals_to!("Num.abs -9_000_000_000_000", 9_000_000_000_000, i64); -// } - -// #[test] -// fn gen_int_eq() { -// assert_evals_to!( -// indoc!( -// r#" -// 4 == 4 -// "# -// ), -// true, -// bool -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// 3 == 4 -// "# -// ), -// false, -// bool -// ); -// } - -#[test] -fn gen_basic_fn() { - assert_evals_to!( - indoc!( - r#" - always42 : Num.Num (Num.Integer Num.Signed64) -> Num.Num (Num.Integer Num.Signed64) - always42 = \_ -> 42 - - always42 5 - "# - ), - 42, - i64 - ); -} - -#[test] -fn gen_wrap_add_nums() { - assert_evals_to!( - indoc!( - r#" - add2 = \num1, num2 -> num1 + num2 - - add2 4 5 - "# - ), - 9, - i64 - ); -} - -#[test] -fn gen_wrap_add_nums_force_stack() { - assert_evals_to!( - indoc!( - r#" - add9 = \num1, num2, num3, num4, num5, num6, num7, num8, num9 -> num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 - - add9 1 2 3 4 5 6 7 8 9 - "# - ), - 45, - i64 - ); -} - -// #[test] -// fn pow_int() { -// assert_evals_to!("Num.powInt 2 3", 8, i64); -// } - -// #[test] -// fn acos() { -// assert_evals_to!("Num.acos 0.5", 1.0471975511965979, f64); -// } - -// #[test] -// fn asin() { -// assert_evals_to!("Num.asin 0.5", 0.5235987755982989, f64); -// } - -// #[test] -// fn atan() { -// assert_evals_to!("Num.atan 10", 1.4711276743037347, f64); -// } - -// #[test] -// fn gen_if_fn() { -// assert_evals_to!( -// indoc!( -// r#" -// limitedNegate = \num -> -// x = -// if num == 1 then -// -1 -// else if num == -1 then -// 1 -// else -// num -// x - -// limitedNegate 1 -// "# -// ), -// -1, -// i64 -// ); -// } - -// #[test] -// fn gen_fib_fn() { -// assert_evals_to!( -// indoc!( -// r#" -// fib = \n -> -// if n == 0 then -// 0 -// else if n == 1 then -// 1 -// else -// (fib (n - 1)) + (fib (n - 2)) - -// fib 10 -// "# -// ), -// 55, -// i64 -// ); -// } - -// #[test] -// fn f64_abs() { -// assert_evals_to!("Num.abs -4.7", 4.7, f64); -// assert_evals_to!("Num.abs 5.8", 5.8, f64); -// } - -// #[test] -// fn f64_round() { -// assert_evals_to!("Num.round 3.6", 4, i64); -// assert_evals_to!("Num.round 3.4", 3, i64); -// assert_evals_to!("Num.round 2.5", 3, i64); -// assert_evals_to!("Num.round -2.3", -2, i64); -// assert_evals_to!("Num.round -2.5", -3, i64); -// } - -// #[test] -// fn f64_sqrt() { -// // FIXME this works with normal types, but fails when checking uniqueness types -// assert_evals_to!( -// indoc!( -// r#" -// when Num.sqrt 100 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 10.0, -// f64 -// ); -// } - -// #[test] -// fn gen_float_eq() { -// assert_evals_to!( -// indoc!( -// r#" -// 1.0 == 1.0 -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn gen_div_f64() { -// // FIXME this works with normal types, but fails when checking uniqueness types -// assert_evals_to!( -// indoc!( -// r#" -// when 48 / 2 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 24.0, -// f64 -// ); -// } - -// #[test] -// fn gen_int_neq() { -// assert_evals_to!( -// indoc!( -// r#" -// 4 != 5 -// "# -// ), -// true, -// bool -// ); -// } - -// #[test] -// fn gen_wrap_int_neq() { -// assert_evals_to!( -// indoc!( -// r#" -// wrappedNotEq : a, a -> Bool -// wrappedNotEq = \num1, num2 -> -// num1 != num2 - -// wrappedNotEq 2 3 -// "# -// ), -// true, -// bool -// ); -// } - -#[test] -fn gen_sub_f64() { - assert_evals_to!( - indoc!( - r#" - 1.5 - 2.4 - 3 - "# - ), - -3.9, - f64 - ); -} - -// #[test] -// fn gen_div_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when 1000 // 10 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 100, -// i64 -// ); -// } - -// #[test] -// fn gen_div_by_zero_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when 1000 // 0 is -// Err DivByZero -> 99 -// _ -> -24 -// "# -// ), -// 99, -// i64 -// ); -// } - -// #[test] -// fn gen_rem_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.rem 8 3 is -// Ok val -> val -// Err _ -> -1 -// "# -// ), -// 2, -// i64 -// ); -// } - -// #[test] -// fn gen_rem_div_by_zero_i64() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.rem 8 0 is -// Err DivByZero -> 4 -// Ok _ -> -23 -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn gen_is_zero_i64() { -// assert_evals_to!("Num.isZero 0", true, bool); -// assert_evals_to!("Num.isZero 1", false, bool); -// } - -// #[test] -// fn gen_is_positive_i64() { -// assert_evals_to!("Num.isPositive 0", false, bool); -// assert_evals_to!("Num.isPositive 1", true, bool); -// assert_evals_to!("Num.isPositive -5", false, bool); -// } - -// #[test] -// fn gen_is_negative_i64() { -// assert_evals_to!("Num.isNegative 0", false, bool); -// assert_evals_to!("Num.isNegative 3", false, bool); -// assert_evals_to!("Num.isNegative -2", true, bool); -// } - -// #[test] -// fn gen_is_positive_f64() { -// assert_evals_to!("Num.isPositive 0.0", false, bool); -// assert_evals_to!("Num.isPositive 4.7", true, bool); -// assert_evals_to!("Num.isPositive -8.5", false, bool); -// } - -// #[test] -// fn gen_is_negative_f64() { -// assert_evals_to!("Num.isNegative 0.0", false, bool); -// assert_evals_to!("Num.isNegative 9.9", false, bool); -// assert_evals_to!("Num.isNegative -4.4", true, bool); -// } - -// #[test] -// fn gen_is_zero_f64() { -// assert_evals_to!("Num.isZero 0", true, bool); -// assert_evals_to!("Num.isZero 0_0", true, bool); -// assert_evals_to!("Num.isZero 0.0", true, bool); -// assert_evals_to!("Num.isZero 1", false, bool); -// } - -// #[test] -// fn gen_is_odd() { -// assert_evals_to!("Num.isOdd 4", false, bool); -// assert_evals_to!("Num.isOdd 5", true, bool); -// } - -// #[test] -// fn gen_is_even() { -// assert_evals_to!("Num.isEven 6", true, bool); -// assert_evals_to!("Num.isEven 7", false, bool); -// } - -// #[test] -// fn sin() { -// assert_evals_to!("Num.sin 0", 0.0, f64); -// assert_evals_to!("Num.sin 1.41421356237", 0.9877659459922529, f64); -// } - -// #[test] -// fn cos() { -// assert_evals_to!("Num.cos 0", 1.0, f64); -// assert_evals_to!("Num.cos 3.14159265359", -1.0, f64); -// } - -// #[test] -// fn tan() { -// assert_evals_to!("Num.tan 0", 0.0, f64); -// assert_evals_to!("Num.tan 1", 1.557407724654902, f64); -// } - -// #[test] -// fn lt_i64() { -// assert_evals_to!("1 < 2", true, bool); -// assert_evals_to!("1 < 1", false, bool); -// assert_evals_to!("2 < 1", false, bool); -// assert_evals_to!("0 < 0", false, bool); -// } - -// #[test] -// fn lte_i64() { -// assert_evals_to!("1 <= 1", true, bool); -// assert_evals_to!("2 <= 1", false, bool); -// assert_evals_to!("1 <= 2", true, bool); -// assert_evals_to!("0 <= 0", true, bool); -// } - -// #[test] -// fn gt_i64() { -// assert_evals_to!("2 > 1", true, bool); -// assert_evals_to!("2 > 2", false, bool); -// assert_evals_to!("1 > 1", false, bool); -// assert_evals_to!("0 > 0", false, bool); -// } - -// #[test] -// fn gte_i64() { -// assert_evals_to!("1 >= 1", true, bool); -// assert_evals_to!("1 >= 2", false, bool); -// assert_evals_to!("2 >= 1", true, bool); -// assert_evals_to!("0 >= 0", true, bool); -// } - -// #[test] -// fn lt_f64() { -// assert_evals_to!("1.1 < 1.2", true, bool); -// assert_evals_to!("1.1 < 1.1", false, bool); -// assert_evals_to!("1.2 < 1.1", false, bool); -// assert_evals_to!("0.0 < 0.0", false, bool); -// } - -// #[test] -// fn lte_f64() { -// assert_evals_to!("1.1 <= 1.1", true, bool); -// assert_evals_to!("1.2 <= 1.1", false, bool); -// assert_evals_to!("1.1 <= 1.2", true, bool); -// assert_evals_to!("0.0 <= 0.0", true, bool); -// } - -// #[test] -// fn gt_f64() { -// assert_evals_to!("2.2 > 1.1", true, bool); -// assert_evals_to!("2.2 > 2.2", false, bool); -// assert_evals_to!("1.1 > 2.2", false, bool); -// assert_evals_to!("0.0 > 0.0", false, bool); -// } - -// #[test] -// fn gte_f64() { -// assert_evals_to!("1.1 >= 1.1", true, bool); -// assert_evals_to!("1.1 >= 1.2", false, bool); -// assert_evals_to!("1.2 >= 1.1", true, bool); -// assert_evals_to!("0.0 >= 0.0", true, bool); -// } - -#[test] -fn gen_order_of_arithmetic_ops() { - assert_evals_to!( - indoc!( - r#" - 1 + 3 * 7 - 2 - "# - ), - 20, - i64 - ); -} - -#[test] -fn gen_order_of_arithmetic_ops_complex_float() { - assert_evals_to!( - indoc!( - r#" - 3 - 48 * 2.0 - "# - ), - -93.0, - f64 - ); -} - -// #[test] -// fn if_guard_bind_variable_false() { -// assert_evals_to!( -// indoc!( -// r#" -// wrapper = \{} -> -// when 10 is -// x if x == 5 -> 0 -// _ -> 42 - -// wrapper {} -// "# -// ), -// 42, -// i64 -// ); -// } - -// #[test] -// fn if_guard_bind_variable_true() { -// assert_evals_to!( -// indoc!( -// r#" -// wrapper = \{} -> -// when 10 is -// x if x == 10 -> 42 -// _ -> 0 - -// wrapper {} -// "# -// ), -// 42, -// i64 -// ); -// } - -// #[test] -// fn tail_call_elimination() { -// assert_evals_to!( -// indoc!( -// r#" -// sum = \n, accum -> -// when n is -// 0 -> accum -// _ -> sum (n - 1) (n + accum) - -// sum 1_000_000 0 -// "# -// ), -// 500000500000, -// i64 -// ); -// } - -// #[test] -// fn int_negate() { -// assert_evals_to!("Num.neg 123", -123, i64); -// } - -// #[test] -// fn gen_wrap_int_neg() { -// assert_evals_to!( -// indoc!( -// r#" -// wrappedNeg = \num -> -num - -// wrappedNeg 3 -// "# -// ), -// -3, -// i64 -// ); -// } - -// #[test] -// fn int_to_float() { -// assert_evals_to!("Num.toFloat 0x9", 9.0, f64); -// } - -// #[test] -// fn num_to_float() { -// assert_evals_to!("Num.toFloat 9", 9.0, f64); -// } - -// #[test] -// fn float_to_float() { -// assert_evals_to!("Num.toFloat 0.5", 0.5, f64); -// } - -// #[test] -// fn int_compare() { -// assert_evals_to!("Num.compare 0 1", RocOrder::Lt, RocOrder); -// assert_evals_to!("Num.compare 1 1", RocOrder::Eq, RocOrder); -// assert_evals_to!("Num.compare 1 0", RocOrder::Gt, RocOrder); -// } - -// #[test] -// fn float_compare() { -// assert_evals_to!("Num.compare 0.01 3.14", RocOrder::Lt, RocOrder); -// assert_evals_to!("Num.compare 3.14 3.14", RocOrder::Eq, RocOrder); -// assert_evals_to!("Num.compare 3.14 0.01", RocOrder::Gt, RocOrder); -// } - -// #[test] -// fn pow() { -// assert_evals_to!("Num.pow 2.0 2.0", 4.0, f64); -// } - -// #[test] -// fn ceiling() { -// assert_evals_to!("Num.ceiling 1.1", 2, i64); -// } - -// #[test] -// fn floor() { -// assert_evals_to!("Num.floor 1.9", 1, i64); -// } - -// // #[test] -// // #[should_panic(expected = r#"Roc failed with message: "integer addition overflowed!"#)] -// // fn int_overflow() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // 9_223_372_036_854_775_807 + 1 -// // "# -// // ), -// // 0, -// // i64 -// // ); -// // } - -// #[test] -// fn int_add_checked() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1 2 is -// Ok v -> v -// _ -> -1 -// "# -// ), -// 3, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 9_223_372_036_854_775_807 1 is -// Err Overflow -> -1 -// Ok v -> v -// "# -// ), -// -1, -// i64 -// ); -// } - -// #[test] -// fn int_add_wrap() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.addWrap 9_223_372_036_854_775_807 1 -// "# -// ), -// std::i64::MIN, -// i64 -// ); -// } - -// #[test] -// fn float_add_checked_pass() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1.0 0.0 is -// Ok v -> v -// Err Overflow -> -1.0 -// "# -// ), -// 1.0, -// f64 -// ); -// } - -// #[test] -// fn float_add_checked_fail() { -// assert_evals_to!( -// indoc!( -// r#" -// when Num.addChecked 1.7976931348623157e308 1.7976931348623157e308 is -// Err Overflow -> -1 -// Ok v -> v -// "# -// ), -// -1.0, -// f64 -// ); -// } - -// // #[test] -// // #[should_panic(expected = r#"Roc failed with message: "float addition overflowed!"#)] -// // fn float_overflow() { -// // assert_evals_to!( -// // indoc!( -// // r#" -// // 1.7976931348623157e308 + 1.7976931348623157e308 -// // "# -// // ), -// // 0.0, -// // f64 -// // ); -// // } - -// #[test] -// fn max_i128() { -// assert_evals_to!( -// indoc!( -// r#" -// Num.maxI128 -// "# -// ), -// i128::MAX, -// i128 -// ); -// } - -#[test] -fn num_max_int() { - assert_evals_to!( - indoc!( - r#" - Num.maxInt - "# - ), - i64::MAX, - i64 - ); -} - -#[test] -fn num_min_int() { - assert_evals_to!( - indoc!( - r#" - Num.minInt - "# - ), - i64::MIN, - i64 - ); -} diff --git a/compiler/test_wasm/src/wasm_records.rs b/compiler/test_wasm/src/wasm_records.rs deleted file mode 100644 index 8ff5bcbb69..0000000000 --- a/compiler/test_wasm/src/wasm_records.rs +++ /dev/null @@ -1,911 +0,0 @@ -#![cfg(all(test, target_os = "linux", any(target_arch = "x86_64"/*, target_arch = "aarch64"*/)))] -use crate::assert_evals_to; -use indoc::indoc; - -// #[test] -// fn basic_record() { -// assert_evals_to!( -// indoc!( -// r#" -// { y: 17, x: 15, z: 19 }.x -// "# -// ), -// 15, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: 17, z: 19 }.y -// "# -// ), -// 17, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: 17, z: 19 }.z -// "# -// ), -// 19, -// i64 -// ); -// } -// -// #[test] -// fn nested_record() { -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.x -// "# -// ), -// 15, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.a -// "# -// ), -// 12, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.b -// "# -// ), -// 15, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.y.c -// "# -// ), -// 2, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// { x: 15, y: { a: 12, b: 15, c: 2}, z: 19 }.z -// "# -// ), -// 19, -// i64 -// ); -// } -// -// #[test] -// fn f64_record() { -// assert_evals_to!( -// indoc!( -// r#" -// rec = { y: 17.2, x: 15.1, z: 19.3 } -// -// rec.x -// "# -// ), -// 15.1, -// f64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// rec = { y: 17.2, x: 15.1, z: 19.3 } -// -// rec.y -// "# -// ), -// 17.2, -// f64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// rec = { y: 17.2, x: 15.1, z: 19.3 } -// -// rec.z -// "# -// ), -// 19.3, -// f64 -// ); -// } - -// #[test] -// fn fn_record() { -// assert_evals_to!( -// indoc!( -// r#" -// getRec = \x -> { y: 17, x, z: 19 } - -// (getRec 15).x -// "# -// ), -// 15, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.y -// "# -// ), -// 17, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.z -// "# -// ), -// 19, -// i64 -// ); - -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } - -// rec.z + rec.x -// "# -// ), -// 34, -// i64 -// ); -// } - -// #[test] -// fn def_record() { -// assert_evals_to!( -// indoc!( -// r#" -// rec = { y: 17, x: 15, z: 19 } -// -// rec.x -// "# -// ), -// 15, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } -// -// rec.y -// "# -// ), -// 17, -// i64 -// ); -// -// assert_evals_to!( -// indoc!( -// r#" -// rec = { x: 15, y: 17, z: 19 } -// -// rec.z -// "# -// ), -// 19, -// i64 -// ); -// } -// -// #[test] -// fn when_on_record() { -// assert_evals_to!( -// indoc!( -// r#" -// when { x: 0x2 } is -// { x } -> x + 3 -// "# -// ), -// 5, -// i64 -// ); -// } -// -// #[test] -// fn when_record_with_guard_pattern() { -// assert_evals_to!( -// indoc!( -// r#" -// when { x: 0x2, y: 3.14 } is -// { x: var } -> var + 3 -// "# -// ), -// 5, -// i64 -// ); -// } -// -// #[test] -// fn let_with_record_pattern() { -// assert_evals_to!( -// indoc!( -// r#" -// { x } = { x: 0x2, y: 3.14 } -// -// x -// "# -// ), -// 2, -// i64 -// ); -// } -// -// #[test] -// fn record_guard_pattern() { -// assert_evals_to!( -// indoc!( -// r#" -// when { x: 0x2, y: 3.14 } is -// { x: 0x4 } -> 5 -// { x } -> x + 3 -// "# -// ), -// 5, -// i64 -// ); -// } -// -// #[test] -// fn twice_record_access() { -// assert_evals_to!( -// indoc!( -// r#" -// x = {a: 0x2, b: 0x3 } -// -// x.a + x.b -// "# -// ), -// 5, -// i64 -// ); -// } -// #[test] -// fn empty_record() { -// assert_evals_to!( -// indoc!( -// r#" -// v = {} -// -// v -// "# -// ), -// (), -// () -// ); -// } - -#[test] -fn i64_record1_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3 } - "# - ), - 3, - i64 - ); -} - -#[test] -fn i64_record2_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3, y: 5 } - "# - ), - (3, 5), - (i64, i64) - ); -} - -#[test] -fn i64_record3_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3, y: 5, z: 17 } - "# - ), - (3, 5, 17), - (i64, i64, i64) - ); -} - -#[test] -fn f64_record2_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3.1, y: 5.1 } - "# - ), - (3.1, 5.1), - (f64, f64) - ); -} - -#[test] -fn f64_record3_literal() { - assert_evals_to!( - indoc!( - r#" - { x: 3.1, y: 5.1, z: 17.1 } - "# - ), - (3.1, 5.1, 17.1), - (f64, f64, f64) - ); -} - -#[test] -fn bool_record4_literal() { - assert_evals_to!( - indoc!( - r#" - record : { a : Bool, b : Bool, c : Bool, d : Bool } - record = { a: True, b: False, c : False, d : True } - - record - "# - ), - [true, false, false, true], - [bool; 4] - ); -} - -#[test] -fn i64_record9_literal() { - assert_evals_to!( - indoc!( - r#" - { a: 3, b: 5, c: 17, d: 1, e: 9, f: 12, g: 13, h: 14, i: 15 } - "# - ), - [3, 5, 17, 1, 9, 12, 13, 14, 15], - [i64; 9] - ); -} - -#[test] -fn bool_literal() { - assert_evals_to!( - indoc!( - r#" - x : Bool - x = True - - x - "# - ), - true, - bool - ); -} - -// #[test] -// fn optional_field_when_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// main = -// a = f { x: Blue, y: 7 } -// b = f { x: Blue } -// c = f { x: Red, y: 11 } -// d = f { x: Red } - -// a * b * c * d -// "# -// ), -// 3 * 5 * 7 * 11, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// a = f { x: Blue, y: 7 } -// b = f { x: Blue } -// c = f { x: Red, y: 11 } -// d = f { x: Red } - -// a * b * c * d -// "# -// ), -// 3 * 5 * 7 * 11, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_no_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_when_no_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// { x ? 10, y } = r -// x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { y: 9 } -// "# -// ), -// 19, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_no_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \r -> -// { x ? 10, y } = r -// x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_let_no_use_default_nested() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// { x ? 10, y } = r -// x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_function_use_default() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \{ x ? 10, y } -> x + y - -// f { y: 9 } -// "# -// ), -// 19, -// i64 -// ); -// } - -// #[test] -// #[ignore] -// fn optional_field_function_no_use_default() { -// // blocked on https://github.com/rtfeldman/roc/issues/786 -// assert_evals_to!( -// indoc!( -// r#" -// app "test" provides [ main ] to "./platform" - -// f = \{ x ? 10, y } -> x + y - -// main = -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// #[ignore] -// fn optional_field_function_no_use_default_nested() { -// // blocked on https://github.com/rtfeldman/roc/issues/786 -// assert_evals_to!( -// indoc!( -// r#" -// f = \{ x ? 10, y } -> x + y - -// f { x: 4, y: 9 } -// "# -// ), -// 13, -// i64 -// ); -// } - -// #[test] -// fn optional_field_singleton_record() { -// assert_evals_to!( -// indoc!( -// r#" -// when { x : 4 } is -// { x ? 3 } -> x -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn optional_field_empty_record() { -// assert_evals_to!( -// indoc!( -// r#" -// when { } is -// { x ? 3 } -> x -// "# -// ), -// 3, -// i64 -// ); -// } - -#[test] -fn return_record_3() { - assert_evals_to!( - indoc!( - r#" - { x: 3, y: 5, z: 4 } - "# - ), - (3, 5, 4), - (i64, i64, i64) - ); -} - -#[test] -fn return_record_4() { - assert_evals_to!( - indoc!( - r#" - { a: 3, b: 5, c: 4, d: 2 } - "# - ), - [3, 5, 4, 2], - [i64; 4] - ); -} - -#[test] -fn return_record_5() { - assert_evals_to!( - indoc!( - r#" - { a: 3, b: 5, c: 4, d: 2, e: 1 } - "# - ), - [3, 5, 4, 2, 1], - [i64; 5] - ); -} - -#[test] -fn return_record_6() { - assert_evals_to!( - indoc!( - r#" - { a: 3, b: 5, c: 4, d: 2, e: 1, f: 7 } - "# - ), - [3, 5, 4, 2, 1, 7], - [i64; 6] - ); -} - -#[test] -fn return_record_7() { - assert_evals_to!( - indoc!( - r#" - { a: 3, b: 5, c: 4, d: 2, e: 1, f: 7, g: 8 } - "# - ), - [3, 5, 4, 2, 1, 7, 8], - [i64; 7] - ); -} - -#[test] -fn return_record_float_int() { - assert_evals_to!( - indoc!( - r#" - { a: 3.14, b: 0x1 } - "# - ), - (3.14, 0x1), - (f64, i64) - ); -} - -#[test] -fn return_record_int_float() { - assert_evals_to!( - indoc!( - r#" - { a: 0x1, b: 3.14 } - "# - ), - (0x1, 3.14), - (i64, f64) - ); -} - -#[test] -fn return_record_float_float() { - assert_evals_to!( - indoc!( - r#" - { a: 6.28, b: 3.14 } - "# - ), - (6.28, 3.14), - (f64, f64) - ); -} - -#[test] -fn return_record_float_float_float() { - assert_evals_to!( - indoc!( - r#" - { a: 6.28, b: 3.14, c: 0.1 } - "# - ), - (6.28, 3.14, 0.1), - (f64, f64, f64) - ); -} - -// #[test] -// fn return_nested_record() { -// assert_evals_to!( -// indoc!( -// r#" -// { flag: 0x0, payload: { a: 6.28, b: 3.14, c: 0.1 } } -// "# -// ), -// (0x0, (6.28, 3.14, 0.1)), -// (i64, (f64, f64, f64)) -// ); -// } - -// #[test] -// fn accessor() { -// assert_evals_to!( -// indoc!( -// r#" -// .foo { foo: 4 } + .foo { bar: 6.28, foo: 3 } -// "# -// ), -// 7, -// i64 -// ); -// } - -// #[test] -// fn accessor_single_element_record() { -// assert_evals_to!( -// indoc!( -// r#" -// .foo { foo: 4 } -// "# -// ), -// 4, -// i64 -// ); -// } - -// #[test] -// fn update_record() { -// assert_evals_to!( -// indoc!( -// r#" -// rec = { foo: 42, bar: 6 } - -// { rec & foo: rec.foo + 1 } -// "# -// ), -// (6, 43), -// (i64, i64) -// ); -// } - -// #[test] -// fn update_single_element_record() { -// assert_evals_to!( -// indoc!( -// r#" -// rec = { foo: 42} - -// { rec & foo: rec.foo + 1 } -// "# -// ), -// 43, -// i64 -// ); -// } - -// #[test] -// fn booleans_in_record() { -// assert_evals_to!( -// indoc!("{ x: 1 == 1, y: 1 == 1 }"), -// (true, true), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 != 1, y: 1 == 1 }"), -// (false, true), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 == 1, y: 1 != 1 }"), -// (true, false), -// (bool, bool) -// ); -// assert_evals_to!( -// indoc!("{ x: 1 != 1, y: 1 != 1 }"), -// (false, false), -// (bool, bool) -// ); -// } - -// #[test] -// fn alignment_in_record() { -// assert_evals_to!( -// indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"), -// (32i64, true, 2u8), -// (i64, bool, u8) -// ); -// } - -#[test] -fn stack_memory_return_from_branch() { - // stack memory pointer should end up in the right place after returning from a branch - assert_evals_to!( - indoc!( - r#" - stackMemoryJunk = { x: 999, y: 111 } - if True then - { x: 123, y: 321 } - else - stackMemoryJunk - "# - ), - (123, 321), - (i64, i64) - ); -} - -// #[test] -// fn blue_and_present() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// f { x: Blue, y: 7 } -// "# -// ), -// 7, -// i64 -// ); -// } - -// #[test] -// fn blue_and_absent() { -// assert_evals_to!( -// indoc!( -// r#" -// f = \r -> -// when r is -// { x: Blue, y ? 3 } -> y -// { x: Red, y ? 5 } -> y - -// f { x: Blue } -// "# -// ), -// 3, -// i64 -// ); -// } diff --git a/compiler/test_wasm_util/Cargo.lock b/compiler/test_wasm_util/Cargo.lock deleted file mode 100644 index b8488b9cb6..0000000000 --- a/compiler/test_wasm_util/Cargo.lock +++ /dev/null @@ -1,1055 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli 0.26.1", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object 0.27.1", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "cc" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cranelift-bforest" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ca3560686e7c9c7ed7e0fe77469f2410ba5d7781b1acaa9adc8d8deea28e3e" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf9bf1ffffb6ce3d2e5ebc83549bd2436426c99b31cc550d521364cbe35d276" -dependencies = [ - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.24.0", - "log", - "regalloc", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc21936a5a6d07e23849ffe83e5c1f6f50305c074f4b2970ca50c13bf55b821" -dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5b6ffaa87560bebe69a5446449da18090b126037920b0c1c6d5945f72faf6b" - -[[package]] -name = "cranelift-entity" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6b4a8bef04f82e4296782646f733c641d09497df2fabf791323fefaa44c64c" - -[[package]] -name = "cranelift-frontend" -version = "0.74.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b783b351f966fce33e3c03498cb116d16d97a8f9978164a60920bd0d3a99c" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "crc32fast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[package]] -name = "darling" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "enumset" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6216d2c19a6fb5f29d1ada1dc7bc4367a8cbf0fa4af5cf12e07b5bbdde6b5b2c" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6451128aa6655d880755345d085494cf7561a6bee7c8dc821e5d77e6d267ecd4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "getrandom" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" -dependencies = [ - "autocfg", - "hashbrown", - "serde", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - -[[package]] -name = "libc" -version = "0.2.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" - -[[package]] -name = "libloading" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "log" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" - -[[package]] -name = "memmap2" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "more-asserts" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38f2be3697a57b4060074ff41b44c16870d916ad7877c17696e063257482bc7" -dependencies = [ - "crc32fast", - "indexmap", - "memchr", -] - -[[package]] -name = "object" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" -dependencies = [ - "memchr", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" - -[[package]] -name = "ppv-lite86" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "quote" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rayon" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regalloc" -version = "0.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" -dependencies = [ - "log", - "rustc-hash", - "smallvec", -] - -[[package]] -name = "region" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "rkyv" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb135b3e5e3311f0a254bfb00333f4bac9ef1d89888b84242a89eb8722b09a07" -dependencies = [ - "memoffset", - "ptr_meta", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba8f489f6b6d8551bb15904293c1ad58a6abafa7d8390d15f7ed05a2afcd87d5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "roc_std" -version = "0.1.0" - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustversion" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "serde" -version = "1.0.130" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_bytes" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.130" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "smallvec" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "target-lexicon" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" - -[[package]] -name = "tempfile" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "test_wasm_util" -version = "0.1.0" -dependencies = [ - "roc_std", - "wasmer", -] - -[[package]] -name = "thiserror" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - -[[package]] -name = "version_check" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "wasmer" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f52e455a01d0fac439cd7a96ba9b519bdc84e923a5b96034054697ebb17cd75" -dependencies = [ - "cfg-if", - "indexmap", - "loupe", - "more-asserts", - "target-lexicon", - "thiserror", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-compiler" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc86dda6f715f03104800be575a38382b35c3962953af9e9d8722dcf0bd2458f" -dependencies = [ - "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", - "smallvec", - "target-lexicon", - "thiserror", - "wasmer-types", - "wasmer-vm", - "wasmparser", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a570746cbec434179e2d53357973a34dfdb208043104e8fac3b7b0023015cf6" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.24.0", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "tracing", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-derive" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee7b351bcc1e782997c72dc0b5b328f3ddcad4813b8ce3cac3f25ae5a4ab56b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "wasmer-engine" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8454ead320a4017ba36ddd9ab4fbf7776fceea6ab0b79b5e53664a1682569fc3" -dependencies = [ - "backtrace", - "lazy_static", - "loupe", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa390d123ebe23d5315c39f6063fcc18319661d03c8000f23d0fe1c011e8135" -dependencies = [ - "cfg-if", - "leb128", - "libloading", - "loupe", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dffe8015f08915eb4939ebc8e521cde8246f272f5197ea60d46214ac5aef285" -dependencies = [ - "cfg-if", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-object" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c541c985799fc1444702501c15d41becfb066c92d9673defc1c7417fd8739e15" -dependencies = [ - "object 0.25.3", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-types" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91f75d3c31f8b1f8d818ff49624fc974220243cbc07a2252f408192e97c6b51" -dependencies = [ - "indexmap", - "loupe", - "rkyv", - "serde", - "thiserror", -] - -[[package]] -name = "wasmer-vm" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469a12346a4831e7dac639b9646d8c9b24c7d2cf0cf458b77f489edb35060c1f" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "indexmap", - "libc", - "loupe", - "memoffset", - "more-asserts", - "region", - "rkyv", - "serde", - "thiserror", - "wasmer-types", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.78.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" - -[[package]] -name = "which" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" -dependencies = [ - "either", - "lazy_static", - "libc", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/compiler/test_wasm_util/Cargo.toml b/compiler/test_wasm_util/Cargo.toml deleted file mode 100644 index bdb3ebf83b..0000000000 --- a/compiler/test_wasm_util/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "test_wasm_util" -version = "0.1.0" -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] -# roc_module = { path = "../module" } -# roc_mono = { path = "../mono" } - -wasmer = { version = "2.0.0", default-features = false, features = ["default-cranelift", "default-universal"] } - -roc_std = { path = "../../roc_std" } diff --git a/compiler/test_wasm_util/src/lib.rs b/compiler/test_wasm_util/src/lib.rs deleted file mode 100644 index b620f374d7..0000000000 --- a/compiler/test_wasm_util/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod from_wasm32_memory;