merge main

This commit is contained in:
Bryce Miller 2023-06-10 15:04:25 -04:00
commit 0132df9b5a
No known key found for this signature in database
GPG key ID: F1E97BF8DF152350
38 changed files with 6287 additions and 5728 deletions

View file

@ -355,7 +355,7 @@ fn encode_use_stdlib() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
HelloWorld := {} implements [Encoding {toEncoder}]
@ -365,7 +365,7 @@ fn encode_use_stdlib() {
|> Encode.appendWith (Encode.string "Hello, World!\n") fmt
main =
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) Json.json)
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -383,14 +383,14 @@ fn encode_use_stdlib_without_wrapping_custom() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
HelloWorld := {} implements [Encoding {toEncoder}]
toEncoder = \@HelloWorld {} -> Encode.string "Hello, World!\n"
main =
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) Json.json)
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld {}) TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -409,13 +409,13 @@ fn encode_derive_to_encoder_for_opaque() {
indoc!(
r#"
app "test"
imports [Json]
imports [TotallyNotJson]
provides [main] to "./platform"
HelloWorld := { a: Str } implements [Encoding]
main =
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld { a: "Hello, World!" }) Json.json)
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld { a: "Hello, World!" }) TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -433,7 +433,7 @@ fn to_encoder_encode_custom_has_capture() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
HelloWorld := Str implements [Encoding {toEncoder}]
@ -443,7 +443,7 @@ fn to_encoder_encode_custom_has_capture() {
|> Encode.appendWith (Encode.string s1) fmt
main =
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld "Hello, World!\n") Json.json)
result = Str.fromUtf8 (Encode.toBytes (@HelloWorld "Hello, World!\n") TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -473,10 +473,10 @@ mod encode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
app "test" imports [Encode, TotallyNotJson] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes "foo" Json.json) is
when Str.fromUtf8 (Encode.toBytes "foo" TotallyNotJson.json) is
Ok s -> s
_ -> "<bad>"
"#
@ -492,10 +492,10 @@ mod encode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
app "test" imports [Encode, TotallyNotJson] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes [1, 2, 3] Json.json) is
when Str.fromUtf8 (Encode.toBytes [1, 2, 3] TotallyNotJson.json) is
Ok s -> s
_ -> "<bad>"
"#
@ -511,10 +511,10 @@ mod encode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
app "test" imports [Encode, TotallyNotJson] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes Bool.false Json.json) is
when Str.fromUtf8 (Encode.toBytes Bool.false TotallyNotJson.json) is
Ok s -> s
_ -> "<bad>"
"#
@ -532,10 +532,10 @@ mod encode_immediate {
assert_evals_to!(
&format!(indoc!(
r#"
app "test" imports [Encode, Json] provides [main] to "./platform"
app "test" imports [Encode, TotallyNotJson] provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes {}{} Json.json) is
when Str.fromUtf8 (Encode.toBytes {}{} TotallyNotJson.json) is
Ok s -> s
_ -> "<bad>"
"#
@ -572,11 +572,11 @@ fn encode_derived_record_one_field_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
result = Str.fromUtf8 (Encode.toBytes {a: "foo"} Json.json)
result = Str.fromUtf8 (Encode.toBytes {a: "foo"} TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -595,12 +595,12 @@ fn encode_derived_record_two_fields_strings() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
rcd = {a: "foo", b: "bar"}
result = Str.fromUtf8 (Encode.toBytes rcd Json.json)
result = Str.fromUtf8 (Encode.toBytes rcd TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -619,12 +619,12 @@ fn encode_derived_nested_record_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
rcd = {a: {b: "bar"}}
encoded = Encode.toBytes rcd Json.json
encoded = Encode.toBytes rcd TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -643,12 +643,12 @@ fn encode_derived_tag_one_payload_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
x = A "foo"
result = Str.fromUtf8 (Encode.toBytes x Json.json)
result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -666,12 +666,12 @@ fn encode_derived_tag_two_payloads_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
x = A "foo" "bar"
result = Str.fromUtf8 (Encode.toBytes x Json.json)
result = Str.fromUtf8 (Encode.toBytes x TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -689,12 +689,12 @@ fn encode_derived_nested_tag_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
x = A (B "foo" "bar")
encoded = Encode.toBytes x Json.json
encoded = Encode.toBytes x TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -714,12 +714,12 @@ fn encode_derived_nested_record_tag_record() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
x = {a: (B ({c: "foo"}))}
encoded = Encode.toBytes x Json.json
encoded = Encode.toBytes x TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -738,12 +738,12 @@ fn encode_derived_list_string() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
lst = ["foo", "bar", "baz"]
encoded = Encode.toBytes lst Json.json
encoded = Encode.toBytes lst TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -763,12 +763,12 @@ fn encode_derived_list_of_records() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
lst = [{a: "foo"}, {a: "bar"}, {a: "baz"}]
encoded = Encode.toBytes lst Json.json
encoded = Encode.toBytes lst TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -787,12 +787,12 @@ fn encode_derived_list_of_lists_of_strings() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
lst = [["a", "b"], ["c", "d", "e"], ["f"]]
encoded = Encode.toBytes lst Json.json
encoded = Encode.toBytes lst TotallyNotJson.json
result = Str.fromUtf8 encoded
when result is
Ok s -> s
@ -812,14 +812,14 @@ fn encode_derived_record_with_many_types() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
fresh : [Fresh Str, Rotten Str]
fresh = Fresh "tomatoes"
rcd = {actors: ["Idris Elba", "Mila Kunis"], year: 2004u16, rating: {average: 7u8, min: 1u8, max: 10u8, sentiment: fresh}}
result = Str.fromUtf8 (Encode.toBytes rcd Json.json)
result = Str.fromUtf8 (Encode.toBytes rcd TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -839,12 +839,12 @@ fn encode_derived_tuple_two_fields() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
tup = ("foo", 10u8)
result = Str.fromUtf8 (Encode.toBytes tup Json.json)
result = Str.fromUtf8 (Encode.toBytes tup TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -862,12 +862,12 @@ fn encode_derived_tuple_of_tuples() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
tup = ( ("foo", 10u8), (23u8, "bar", 15u8) )
result = Str.fromUtf8 (Encode.toBytes tup Json.json)
result = Str.fromUtf8 (Encode.toBytes tup TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -886,7 +886,7 @@ fn encode_derived_generic_record_with_different_field_types() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
Q a b := {a: a, b: b} implements [Encoding]
@ -894,7 +894,7 @@ fn encode_derived_generic_record_with_different_field_types() {
q = @Q {a: 10u32, b: "fieldb"}
main =
result = Str.fromUtf8 (Encode.toBytes q Json.json)
result = Str.fromUtf8 (Encode.toBytes q TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -912,7 +912,7 @@ fn encode_derived_generic_tag_with_different_field_types() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
Q a b := [A a, B b] implements [Encoding]
@ -921,7 +921,7 @@ fn encode_derived_generic_tag_with_different_field_types() {
q = @Q (B 67)
main =
result = Str.fromUtf8 (Encode.toBytes q Json.json)
result = Str.fromUtf8 (Encode.toBytes q TotallyNotJson.json)
when result is
Ok s -> s
_ -> "<bad>"
@ -939,12 +939,12 @@ fn specialize_unique_newtype_records() {
indoc!(
r#"
app "test"
imports [Encode, Json]
imports [Encode, TotallyNotJson]
provides [main] to "./platform"
main =
when Str.fromUtf8 (Encode.toBytes {a: Bool.true} Json.json) is
Ok s -> when Str.fromUtf8 (Encode.toBytes {b: Bool.true} Json.json) is
when Str.fromUtf8 (Encode.toBytes {a: Bool.true} TotallyNotJson.json) is
Ok s -> when Str.fromUtf8 (Encode.toBytes {b: Bool.true} TotallyNotJson.json) is
Ok t -> "\(s)\(t)"
_ -> "<bad>"
_ -> "<bad>"
@ -962,7 +962,7 @@ fn decode_use_stdlib() {
indoc!(
r#"
app "test"
imports [Json]
imports [TotallyNotJson]
provides [main] to "./platform"
MyNum := U8 implements [Decoding {decoder: myDecoder}]
@ -976,7 +976,7 @@ fn decode_use_stdlib() {
Err e -> {result: Err e, rest}
main =
when Decode.fromBytes [49, 53] Json.json is
when Decode.fromBytes [49, 53] TotallyNotJson.json is
Ok (@MyNum n) -> n
_ -> 101
"#
@ -996,13 +996,13 @@ fn decode_derive_decoder_for_opaque() {
indoc!(
r#"
app "test"
imports [Json]
imports [TotallyNotJson]
provides [main] to "./platform"
HelloWorld := { a: Str } implements [Decoding]
main =
when Str.toUtf8 """{"a":"Hello, World!"}""" |> Decode.fromBytes Json.json is
when Str.toUtf8 """{"a":"Hello, World!"}""" |> Decode.fromBytes TotallyNotJson.json is
Ok (@HelloWorld {a}) -> a
_ -> "FAIL"
"#
@ -1019,7 +1019,7 @@ fn decode_use_stdlib_json_list() {
indoc!(
r#"
app "test"
imports [Json]
imports [TotallyNotJson]
provides [main] to "./platform"
MyNumList := List U8 implements [Decoding {decoder: myDecoder}]
@ -1033,7 +1033,7 @@ fn decode_use_stdlib_json_list() {
Err e -> {result: Err e, rest}
main =
when Str.toUtf8 "[1,2,3]" |> Decode.fromBytes Json.json is
when Str.toUtf8 "[1,2,3]" |> Decode.fromBytes TotallyNotJson.json is
Ok (@MyNumList lst) -> lst
_ -> []
"#
@ -1062,10 +1062,10 @@ mod decode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "\"foo\"" |> Decode.fromBytes Json.json is
when Str.toUtf8 "\"foo\"" |> Decode.fromBytes TotallyNotJson.json is
Ok s -> s
_ -> "<bad>"
"#
@ -1081,13 +1081,13 @@ mod decode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
input = Str.toUtf8 "[1,2,3]"
expected = [1,2,3]
actual = Decode.fromBytes input Json.json |> Result.withDefault []
actual = Decode.fromBytes input TotallyNotJson.json |> Result.withDefault []
actual == expected
"#
@ -1103,10 +1103,10 @@ mod decode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "false" |> Decode.fromBytes Json.json is
when Str.toUtf8 "false" |> Decode.fromBytes TotallyNotJson.json is
Ok s -> s
_ -> Bool.true
"#
@ -1124,10 +1124,10 @@ mod decode_immediate {
assert_evals_to!(
&format!(indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Num.toStr {}{} |> Str.toUtf8 |> Decode.fromBytes Json.json is
when Num.toStr {}{} |> Str.toUtf8 |> Decode.fromBytes TotallyNotJson.json is
Ok n -> n
_ -> 101{}
"#
@ -1162,10 +1162,10 @@ mod decode_immediate {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Num.toStr 17.23dec |> Str.toUtf8 |> Decode.fromBytes Json.json is
when Num.toStr 17.23dec |> Str.toUtf8 |> Decode.fromBytes TotallyNotJson.json is
Ok n -> n
_ -> 101dec
"#
@ -1182,10 +1182,10 @@ fn decode_list_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "[\"a\",\"b\",\"c\"]" |> Decode.fromBytes Json.json is
when Str.toUtf8 "[\"a\",\"b\",\"c\"]" |> Decode.fromBytes TotallyNotJson.json is
Ok l -> Str.joinWith l ","
_ -> "<bad>"
"#
@ -1201,10 +1201,10 @@ fn encode_then_decode_list_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Encode.toBytes ["a", "b", "c"] Json.json |> Decode.fromBytes Json.json is
when Encode.toBytes ["a", "b", "c"] TotallyNotJson.json |> Decode.fromBytes TotallyNotJson.json is
Ok l -> Str.joinWith l ","
_ -> "something went wrong"
"#
@ -1221,10 +1221,10 @@ fn encode_then_decode_list_of_lists_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] Json.json |> Decode.fromBytes Json.json is
when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] TotallyNotJson.json |> Decode.fromBytes TotallyNotJson.json is
Ok list -> (List.map list \inner -> Str.joinWith inner ",") |> Str.joinWith l ";"
_ -> "something went wrong"
"#
@ -1243,10 +1243,10 @@ fn decode_record_two_fields() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.json is
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json is
Ok {first: "ab", second: "cd"} -> "abcd"
_ -> "something went wrong"
"#
@ -1265,10 +1265,10 @@ fn decode_record_two_fields_string_and_int() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":10}" |> Decode.fromBytes Json.json is
when Str.toUtf8 "{\"first\":\"ab\",\"second\":10}" |> Decode.fromBytes TotallyNotJson.json is
Ok {first: "ab", second: 10u8} -> "ab10"
_ -> "something went wrong"
"#
@ -1287,10 +1287,10 @@ fn decode_record_two_fields_string_and_string_infer() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.json is
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json is
Ok {first, second} -> Str.concat first second
_ -> "something went wrong"
"#
@ -1309,10 +1309,10 @@ fn decode_record_two_fields_string_and_string_infer_local_var() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.json
decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json
when decoded is
Ok rcd -> Str.concat rcd.first rcd.second
_ -> "something went wrong"
@ -1332,10 +1332,10 @@ fn decode_record_two_fields_string_and_string_infer_local_var_destructured() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.json
decoded = Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes TotallyNotJson.json
when decoded is
Ok {first, second} -> Str.concat first second
_ -> "something went wrong"
@ -1353,10 +1353,10 @@ fn decode_empty_record() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "{}" |> Decode.fromBytes Json.json is
when Str.toUtf8 "{}" |> Decode.fromBytes TotallyNotJson.json is
Ok {} -> "empty"
_ -> "something went wrong"
"#
@ -1376,10 +1376,10 @@ fn decode_record_of_record() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"outer\":{\"inner\":\"a\"},\"other\":{\"one\":\"b\",\"two\":10}}" |> Decode.fromBytes Json.json is
when Str.toUtf8 "{\"outer\":{\"inner\":\"a\"},\"other\":{\"one\":\"b\",\"two\":10}}" |> Decode.fromBytes TotallyNotJson.json is
Ok {outer: {inner: "a"}, other: {one: "b", two: 10u8}} -> "ab10"
_ -> "something went wrong"
"#
@ -1398,10 +1398,10 @@ fn decode_tuple_two_elements() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "[\"ab\",10]" |> Decode.fromBytes Json.json is
when Str.toUtf8 "[\"ab\",10]" |> Decode.fromBytes TotallyNotJson.json is
Ok ("ab", 10u8) -> "abcd"
_ -> "something went wrong"
"#
@ -1420,10 +1420,10 @@ fn decode_tuple_of_tuples() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Json] provides [main] to "./platform"
app "test" imports [TotallyNotJson] provides [main] to "./platform"
main =
when Str.toUtf8 "[[\"ab\",10],[\"cd\",25]]" |> Decode.fromBytes Json.json is
when Str.toUtf8 "[[\"ab\",10],[\"cd\",25]]" |> Decode.fromBytes TotallyNotJson.json is
Ok ( ("ab", 10u8), ("cd", 25u8) ) -> "abcd"
_ -> "something went wrong"
"#
@ -2139,11 +2139,11 @@ fn issue_4772_weakened_monomorphic_destructure() {
indoc!(
r###"
app "test"
imports [Json]
imports [TotallyNotJson]
provides [main] to "./platform"
getNumber =
{ result, rest } = Decode.fromBytesPartial (Str.toUtf8 "\"1234\"") Json.json
{ result, rest } = Decode.fromBytesPartial (Str.toUtf8 "\"1234\"") TotallyNotJson.json
when result is
Ok val ->

View file

@ -3924,3 +3924,45 @@ fn bool_in_switch() {
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn add_checked_dec() {
assert_evals_to!(
indoc!(
r#"
Num.addChecked 2.0dec 4.0dec == Ok 6.0dec
"#
),
true,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn sub_checked_dec() {
assert_evals_to!(
indoc!(
r#"
Num.subChecked 5.0dec 2.0dec == Ok 3.0dec
"#
),
true,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn mul_checked_dec() {
assert_evals_to!(
indoc!(
r#"
Num.mulChecked 5.0dec 2.0dec == Ok 10.0dec
"#
),
true,
bool
);
}

View file

@ -12,19 +12,19 @@ use indoc::indoc;
use roc_std::{RocBox, RocList, RocStr};
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn basic_int() {
assert_evals_to!("123", 123, i64);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn basic_float() {
assert_evals_to!("1234.0", 1234.0, f64);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_first_float() {
assert_evals_to!(
indoc!(
@ -40,7 +40,7 @@ fn branch_first_float() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_second_float() {
assert_evals_to!(
indoc!(
@ -56,7 +56,7 @@ fn branch_second_float() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_third_float() {
assert_evals_to!(
indoc!(
@ -73,7 +73,7 @@ fn branch_third_float() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_first_int() {
assert_evals_to!(
indoc!(
@ -89,7 +89,7 @@ fn branch_first_int() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_second_int() {
assert_evals_to!(
indoc!(
@ -122,7 +122,7 @@ fn branch_third_int() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn branch_store_variable() {
assert_evals_to!(
indoc!(
@ -138,7 +138,7 @@ fn branch_store_variable() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn when_one_element_tag() {
assert_evals_to!(
indoc!(
@ -156,7 +156,7 @@ fn when_one_element_tag() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn when_two_element_tag_first() {
assert_evals_to!(
indoc!(
@ -175,7 +175,7 @@ fn when_two_element_tag_first() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn when_two_element_tag_second() {
assert_evals_to!(
indoc!(
@ -194,7 +194,7 @@ fn when_two_element_tag_second() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn gen_when_one_branch() {
assert_evals_to!(
indoc!(
@ -209,7 +209,7 @@ fn gen_when_one_branch() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn gen_large_when_int() {
assert_evals_to!(
indoc!(
@ -232,7 +232,7 @@ fn gen_large_when_int() {
}
#[test]
#[cfg(any(feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn gen_large_when_float() {
assert_evals_to!(
indoc!(
@ -255,7 +255,7 @@ fn gen_large_when_float() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn or_pattern() {
assert_evals_to!(
indoc!(
@ -271,7 +271,7 @@ fn or_pattern() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn apply_identity() {
assert_evals_to!(
indoc!(
@ -287,7 +287,7 @@ fn apply_identity() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn apply_unnamed_identity() {
assert_evals_to!(
indoc!(
@ -2144,7 +2144,7 @@ fn rosetree_basic() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn case_jump() {
// the decision tree will generate a jump to the `1` branch here
assert_evals_to!(
@ -2171,7 +2171,7 @@ fn case_jump() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn nullable_eval_cfold() {
// the decision tree will generate a jump to the `1` branch here
assert_evals_to!(
@ -2208,7 +2208,7 @@ fn nullable_eval_cfold() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn nested_switch() {
// exposed bug with passing the right symbol/layout down into switch branch generation
// This is also the only test_gen test that exercises Reset/Reuse (as of Aug 2022)
@ -2252,7 +2252,7 @@ fn nested_switch() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn count_deriv_x() {
// exposed bug with basing the block_of_memory on a specific (smaller) tag layout
assert_evals_to!(
@ -2279,7 +2279,7 @@ fn count_deriv_x() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn deriv_pow() {
// exposed bug with ordering of variable declarations before switch
assert_evals_to!(
@ -2316,7 +2316,7 @@ fn deriv_pow() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn multiple_increment() {
// the `leaf` value will be incremented multiple times at once
assert_evals_to!(
@ -2350,7 +2350,7 @@ fn multiple_increment() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn switch_fuse_rc_non_exhaustive() {
assert_evals_to!(
indoc!(
@ -2380,7 +2380,7 @@ fn switch_fuse_rc_non_exhaustive() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn switch_fuse_rc_exhaustive() {
assert_evals_to!(
indoc!(
@ -2409,7 +2409,7 @@ fn switch_fuse_rc_exhaustive() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn build_then_apply_closure() {
assert_evals_to!(
indoc!(
@ -2429,7 +2429,7 @@ fn build_then_apply_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn expanded_result() {
assert_evals_to!(
indoc!(
@ -2460,7 +2460,7 @@ fn expanded_result() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn backpassing_result() {
assert_evals_to!(
indoc!(
@ -2530,7 +2530,7 @@ fn call_invalid_layout() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn increment_or_double_closure() {
assert_evals_to!(
indoc!(
@ -2568,7 +2568,7 @@ fn increment_or_double_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn module_thunk_is_function() {
assert_evals_to!(
indoc!(
@ -2585,7 +2585,7 @@ fn module_thunk_is_function() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pass_through_unresolved_type_variable() {
assert_evals_to!(
indoc!(
@ -2608,7 +2608,7 @@ fn pass_through_unresolved_type_variable() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_match_empty_record() {
assert_evals_to!(
indoc!(
@ -2628,7 +2628,7 @@ fn pattern_match_empty_record() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_match_unit_tag() {
assert_evals_to!(
indoc!(
@ -2653,7 +2653,7 @@ fn pattern_match_unit_tag() {
// see for why this is disabled on wasm32 https://github.com/roc-lang/roc/issues/1687
#[cfg(not(feature = "gen-llvm-wasm"))]
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn mirror_llvm_alignment_padding() {
// see https://github.com/roc-lang/roc/issues/1569
assert_evals_to!(
@ -2676,7 +2676,7 @@ fn mirror_llvm_alignment_padding() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn lambda_set_bool() {
assert_evals_to!(
indoc!(
@ -2701,7 +2701,7 @@ fn lambda_set_bool() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn lambda_set_byte() {
assert_evals_to!(
indoc!(
@ -2727,7 +2727,7 @@ fn lambda_set_byte() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn lambda_set_struct_byte() {
assert_evals_to!(
indoc!(
@ -2755,7 +2755,7 @@ fn lambda_set_struct_byte() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn lambda_set_enum_byte_byte() {
assert_evals_to!(
indoc!(
@ -2786,7 +2786,7 @@ fn lambda_set_enum_byte_byte() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_walk_until() {
// see https://github.com/roc-lang/roc/issues/1576
assert_evals_to!(
@ -2812,7 +2812,7 @@ fn list_walk_until() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn int_literal_not_specialized_with_annotation() {
// see https://github.com/roc-lang/roc/issues/1600
assert_evals_to!(
@ -2840,7 +2840,7 @@ fn int_literal_not_specialized_with_annotation() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn int_literal_not_specialized_no_annotation() {
// see https://github.com/roc-lang/roc/issues/1600
assert_evals_to!(
@ -2867,7 +2867,7 @@ fn int_literal_not_specialized_no_annotation() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn unresolved_tvar_when_capture_is_unused() {
// see https://github.com/roc-lang/roc/issues/1585
assert_evals_to!(
@ -2913,7 +2913,7 @@ fn value_not_exposed_hits_panic() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn mix_function_and_closure() {
// see https://github.com/roc-lang/roc/pull/1706
assert_evals_to!(
@ -2939,7 +2939,7 @@ fn mix_function_and_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn mix_function_and_closure_level_of_indirection() {
// see https://github.com/roc-lang/roc/pull/1706
assert_evals_to!(
@ -2964,7 +2964,7 @@ fn mix_function_and_closure_level_of_indirection() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
#[cfg_attr(debug_assertions, ignore)] // this test stack-overflows the compiler in debug mode
fn do_pass_bool_byte_closure_layout() {
// see https://github.com/roc-lang/roc/pull/1706
@ -3041,7 +3041,7 @@ fn do_pass_bool_byte_closure_layout() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn nested_rigid_list() {
assert_evals_to!(
indoc!(
@ -3118,7 +3118,7 @@ fn nested_rigid_tag_union() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
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`.
@ -3146,7 +3146,7 @@ fn call_that_needs_closure_parameter() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn alias_defined_out_of_order() {
assert_evals_to!(
indoc!(
@ -3167,7 +3167,7 @@ fn alias_defined_out_of_order() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursively_build_effect() {
assert_evals_to!(
indoc!(
@ -3214,7 +3214,7 @@ fn recursively_build_effect() {
#[test]
#[ignore = "TODO; currently generates bad code because `a` isn't specialized inside the closure."]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn polymophic_expression_captured_inside_closure() {
assert_evals_to!(
indoc!(
@ -3238,7 +3238,7 @@ fn polymophic_expression_captured_inside_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_2322() {
assert_evals_to!(
indoc!(
@ -3271,7 +3271,7 @@ fn box_and_unbox_small_string() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_and_unbox_big_string() {
assert_evals_to!(
indoc!(
@ -3366,7 +3366,7 @@ fn box_and_unbox_f32() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_and_unbox_record() {
assert_evals_to!(
indoc!(
@ -3380,7 +3380,7 @@ fn box_and_unbox_record() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn box_and_unbox_tag_union() {
assert_evals_to!(
indoc!(
@ -3397,7 +3397,7 @@ fn box_and_unbox_tag_union() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn closure_called_in_its_defining_scope() {
assert_evals_to!(
indoc!(
@ -3422,7 +3422,7 @@ fn closure_called_in_its_defining_scope() {
#[test]
#[ignore]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_2894() {
assert_evals_to!(
indoc!(
@ -3449,7 +3449,7 @@ fn issue_2894() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn polymorphic_def_used_in_closure() {
assert_evals_to!(
indoc!(
@ -3470,7 +3470,7 @@ fn polymorphic_def_used_in_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn polymorphic_lambda_set_usage() {
assert_evals_to!(
indoc!(
@ -3488,7 +3488,7 @@ fn polymorphic_lambda_set_usage() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn polymorphic_lambda_set_multiple_specializations() {
assert_evals_to!(
indoc!(
@ -3529,7 +3529,7 @@ fn list_map2_conslist() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn mutual_recursion_top_level_defs() {
assert_evals_to!(
indoc!(
@ -3557,7 +3557,7 @@ fn mutual_recursion_top_level_defs() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn polymorphic_lambda_captures_polymorphic_value() {
assert_evals_to!(
indoc!(
@ -3704,7 +3704,7 @@ fn lambda_capture_niches_have_captured_function_in_closure() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_call_capturing_function() {
assert_evals_to!(
indoc!(
@ -3723,7 +3723,7 @@ fn recursive_call_capturing_function() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn shared_pattern_variable_in_when_branches() {
assert_evals_to!(
indoc!(
@ -3797,7 +3797,7 @@ fn runtime_error_when_degenerate_pattern_reached() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_lambda_set_issue_3444() {
assert_evals_to!(
indoc!(
@ -3818,7 +3818,7 @@ fn recursive_lambda_set_issue_3444() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_lambda_set_toplevel_issue_3444() {
assert_evals_to!(
indoc!(
@ -3842,7 +3842,7 @@ fn recursive_lambda_set_toplevel_issue_3444() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_lambda_set_issue_3444_inferred() {
assert_evals_to!(
indoc!(
@ -3887,7 +3887,7 @@ fn compose_recursive_lambda_set_productive_toplevel() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn compose_recursive_lambda_set_productive_nested() {
assert_evals_to!(
indoc!(
@ -3909,7 +3909,7 @@ fn compose_recursive_lambda_set_productive_nested() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn compose_recursive_lambda_set_productive_inferred() {
assert_evals_to!(
indoc!(
@ -3958,7 +3958,7 @@ fn compose_recursive_lambda_set_productive_nullable_wrapped() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn local_binding_aliases_function() {
assert_evals_to!(
indoc!(
@ -3981,7 +3981,7 @@ fn local_binding_aliases_function() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn local_binding_aliases_function_inferred() {
assert_evals_to!(
indoc!(
@ -4002,7 +4002,7 @@ fn local_binding_aliases_function_inferred() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn transient_captures() {
assert_evals_to!(
indoc!(
@ -4022,7 +4022,7 @@ fn transient_captures() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn transient_captures_after_def_ordering() {
assert_evals_to!(
indoc!(
@ -4042,7 +4042,7 @@ fn transient_captures_after_def_ordering() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn deep_transient_capture_chain() {
assert_evals_to!(
indoc!(
@ -4064,7 +4064,7 @@ fn deep_transient_capture_chain() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn deep_transient_capture_chain_with_multiple_captures() {
assert_evals_to!(
indoc!(
@ -4089,7 +4089,7 @@ fn deep_transient_capture_chain_with_multiple_captures() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn transient_captures_from_outer_scope() {
assert_evals_to!(
indoc!(
@ -4111,7 +4111,7 @@ fn transient_captures_from_outer_scope() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn mutually_recursive_captures() {
assert_evals_to!(
indoc!(
@ -4137,7 +4137,7 @@ fn mutually_recursive_captures() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn int_let_generalization() {
assert_evals_to!(
indoc!(
@ -4158,7 +4158,7 @@ fn int_let_generalization() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_match_char() {
assert_evals_to!(
indoc!(
@ -4176,7 +4176,7 @@ fn pattern_match_char() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_4348() {
assert_evals_to!(
indoc!(
@ -4194,7 +4194,7 @@ fn issue_4348() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_4349() {
assert_evals_to!(
indoc!(
@ -4254,7 +4254,7 @@ fn issue_4712() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_as_toplevel() {
assert_evals_to!(
indoc!(
@ -4275,7 +4275,7 @@ fn pattern_as_toplevel() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_as_nested() {
assert_evals_to!(
indoc!(
@ -4296,7 +4296,7 @@ fn pattern_as_nested() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn pattern_as_of_symbol() {
assert_evals_to!(
indoc!(
@ -4314,7 +4314,7 @@ fn pattern_as_of_symbol() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn function_specialization_information_in_lambda_set_thunk() {
assert_evals_to!(
indoc!(
@ -4336,7 +4336,7 @@ fn function_specialization_information_in_lambda_set_thunk() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn function_specialization_information_in_lambda_set_thunk_independent_defs() {
assert_evals_to!(
indoc!(
@ -4360,7 +4360,7 @@ fn function_specialization_information_in_lambda_set_thunk_independent_defs() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176() {
assert_evals_to!(
indoc!(
@ -4383,7 +4383,7 @@ fn when_guard_appears_multiple_times_in_compiled_decision_tree_issue_5176() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_lambda_set_resolved_only_upon_specialization() {
assert_evals_to!(
indoc!(
@ -4406,7 +4406,7 @@ fn recursive_lambda_set_resolved_only_upon_specialization() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn layout_cache_structure_with_multiple_recursive_structures() {
assert_evals_to!(
indoc!(

View file

@ -1007,7 +1007,7 @@ fn result_never() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn nested_recursive_literal() {
assert_evals_to!(
indoc!(
@ -1027,7 +1027,7 @@ fn nested_recursive_literal() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn newtype_wrapper() {
assert_evals_to!(
indoc!(
@ -1045,13 +1045,17 @@ fn newtype_wrapper() {
"#
),
42,
&i64,
|x: &i64| *x
roc_std::RocBox<i64>,
|x: roc_std::RocBox<i64>| {
let value = *x;
std::mem::forget(x);
value
}
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn applied_tag_function() {
assert_evals_to!(
indoc!(
@ -1068,7 +1072,7 @@ fn applied_tag_function() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn applied_tag_function_result() {
assert_evals_to!(
indoc!(
@ -1085,7 +1089,7 @@ fn applied_tag_function_result() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
#[ignore = "This test has incorrect refcounts: https://github.com/roc-lang/roc/issues/2968"]
fn applied_tag_function_linked_list() {
assert_evals_to!(
@ -1146,7 +1150,7 @@ fn tag_must_be_its_own_type() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_tag_union_into_flat_tag_union() {
// Comprehensive test for correctness in cli/tests/repl_eval
assert_evals_to!(
@ -1402,7 +1406,7 @@ fn issue_2458() {
#[test]
#[ignore = "See https://github.com/roc-lang/roc/issues/2466"]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_2458_deep_recursion_var() {
assert_evals_to!(
indoc!(
@ -1423,7 +1427,7 @@ fn issue_2458_deep_recursion_var() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_1162() {
assert_evals_to!(
indoc!(
@ -1598,7 +1602,7 @@ fn issue_2900_unreachable_pattern() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_3261_non_nullable_unwrapped_recursive_union_at_index() {
assert_evals_to!(
indoc!(
@ -1619,7 +1623,7 @@ fn issue_3261_non_nullable_unwrapped_recursive_union_at_index() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn instantiate_annotated_as_recursive_alias_toplevel() {
assert_evals_to!(
indoc!(
@ -1646,7 +1650,7 @@ fn instantiate_annotated_as_recursive_alias_toplevel() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn instantiate_annotated_as_recursive_alias_polymorphic_expr() {
assert_evals_to!(
indoc!(
@ -1673,7 +1677,7 @@ fn instantiate_annotated_as_recursive_alias_polymorphic_expr() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn instantiate_annotated_as_recursive_alias_multiple_polymorphic_expr() {
assert_evals_to!(
indoc!(
@ -1802,7 +1806,7 @@ fn error_type_in_tag_union_payload() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_3653_recursion_pointer_in_naked_opaque() {
assert_evals_to!(
indoc!(
@ -1827,7 +1831,7 @@ fn issue_3653_recursion_pointer_in_naked_opaque() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_3653_recursion_pointer_in_naked_opaque_localized() {
assert_evals_to!(
indoc!(
@ -1852,7 +1856,7 @@ fn issue_3653_recursion_pointer_in_naked_opaque_localized() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_2165_recursive_tag_destructure() {
assert_evals_to!(
indoc!(
@ -1894,7 +1898,7 @@ fn tag_union_let_generalization() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn fit_recursive_union_in_struct_into_recursive_pointer() {
assert_evals_to!(
indoc!(
@ -1957,7 +1961,7 @@ fn dispatch_tag_union_function_inferred() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn issue_4077_fixed_fixpoint() {
assert_evals_to!(
indoc!(
@ -1982,7 +1986,7 @@ fn issue_4077_fixed_fixpoint() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
assert_evals_to!(
indoc!(
@ -2041,7 +2045,7 @@ fn lambda_set_with_imported_toplevels_issue_4733() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn non_unary_union_with_lambda_set_with_imported_toplevels_issue_4733() {
assert_evals_to!(
indoc!(
@ -2131,7 +2135,7 @@ fn nullable_wrapped_with_nullable_not_last_index() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn refcount_nullable_unwrapped_needing_no_refcount_issue_5027() {
assert_evals_to!(
indoc!(
@ -2170,7 +2174,7 @@ fn refcount_nullable_unwrapped_needing_no_refcount_issue_5027() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn issue_5162_recast_nested_nullable_unwrapped_layout() {
with_larger_debug_stack(|| {
assert_evals_to!(
@ -2198,7 +2202,7 @@ fn issue_5162_recast_nested_nullable_unwrapped_layout() {
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn nullable_wrapped_eq_issue_5434() {
assert_evals_to!(
indoc!(
@ -2218,12 +2222,87 @@ fn nullable_wrapped_eq_issue_5434() {
y : Value
y = B 0
if x == y then
"OK"
Bool.true
else
"FAIL"
Bool.false
"###
),
RocStr::from("FAIL"),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_tag_id_in_allocation_basic() {
assert_evals_to!(
indoc!(
r###"
app "test" provides [main] to "./platform"
Value : [
A Value,
B I64,
C I64,
D I64,
E I64,
F I64,
G I64,
H I64,
I I64,
]
x : Value
x = H 42
main =
when x is
A _ -> "A"
B _ -> "B"
C _ -> "C"
D _ -> "D"
E _ -> "E"
F _ -> "F"
G _ -> "G"
H _ -> "H"
I _ -> "I"
"###
),
RocStr::from("H"),
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn recursive_tag_id_in_allocation_eq() {
assert_evals_to!(
indoc!(
r###"
app "test" provides [main] to "./platform"
Value : [
A Value,
B I64,
C I64,
D I64,
E I64,
F I64,
G I64,
H I64,
I I64,
]
x : Value
x = G 42
y : Value
y = H 42
main = (x == x) && (x != y) && (y == y)
"###
),
true,
bool
);
}