fix clippy unnecessary hashes

This commit is contained in:
Anton-4 2024-01-01 16:38:36 +01:00
parent 5d98783cf2
commit 1126f85b5a
No known key found for this signature in database
GPG Key ID: 0971D718C0A9B937
21 changed files with 4158 additions and 4158 deletions

View File

@ -280,12 +280,12 @@ mod test_can {
#[test]
fn correct_annotated_body() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int *
f = \ a -> a
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -296,12 +296,12 @@ mod test_can {
#[test]
fn correct_annotated_body_with_comments() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int * # comment
f = \ a -> a
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -312,12 +312,12 @@ mod test_can {
#[test]
fn name_mismatch_annotated_body() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int *
g = \ a -> a
g
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -340,12 +340,12 @@ mod test_can {
#[test]
fn name_mismatch_annotated_body_with_comment() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int * # comment
g = \ a -> a
g
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -368,13 +368,13 @@ mod test_can {
#[test]
fn separated_annotated_body() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int *
f = \ a -> a
f 42
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -389,13 +389,13 @@ mod test_can {
#[test]
fn separated_annotated_body_with_comment() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int *
# comment
f = \ a -> a
f 42
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -410,13 +410,13 @@ mod test_can {
#[test]
fn shadowed_annotation() {
let src = indoc!(
r#"
r"
f : Num.Int * -> Num.Int *
f : Num.Int * -> Num.Int *
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -432,7 +432,7 @@ mod test_can {
#[test]
fn correct_nested_unannotated_body() {
let src = indoc!(
r#"
r"
f : Num.Int *
f =
g = 42
@ -440,7 +440,7 @@ mod test_can {
g + 1
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -451,7 +451,7 @@ mod test_can {
#[test]
fn correct_nested_annotated_body() {
let src = indoc!(
r#"
r"
f : Num.Int *
f =
g : Num.Int *
@ -460,7 +460,7 @@ mod test_can {
g + 1
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -471,7 +471,7 @@ mod test_can {
#[test]
fn correct_nested_body_annotated_multiple_lines() {
let src = indoc!(
r#"
r"
f : Num.Int *
f =
g : Num.Int *
@ -482,7 +482,7 @@ mod test_can {
g + h + z
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -493,7 +493,7 @@ mod test_can {
#[test]
fn correct_nested_body_unannotated_multiple_lines() {
let src = indoc!(
r#"
r"
f : Num.Int *
f =
g = 42
@ -503,7 +503,7 @@ mod test_can {
g + h + z
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -513,7 +513,7 @@ mod test_can {
#[test]
fn correct_double_nested_body() {
let src = indoc!(
r#"
r"
f : Num.Int *
f =
g =
@ -523,7 +523,7 @@ mod test_can {
f
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -534,13 +534,13 @@ mod test_can {
#[test]
fn annotation_followed_with_unrelated_affectation() {
let src = indoc!(
r#"
r"
F : Str
x = 1
x
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -554,7 +554,7 @@ mod test_can {
#[test]
fn two_annotations_followed_with_unrelated_affectation() {
let src = indoc!(
r#"
r"
G : Str
F : {}
@ -562,7 +562,7 @@ mod test_can {
x = 1
x
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -581,11 +581,11 @@ mod test_can {
// // it only exists in the closure's arguments.
// let arena = Bump::new();
// let src = indoc!(
// r#"
// r"
// func = \arg -> arg
// func 2
// "#
// "
// );
// let (_actual, output, problems, _var_store, _vars, _constraint) =
// can_expr_with(&arena, test_home(), src);
@ -608,13 +608,13 @@ mod test_can {
// fn call_by_pointer_for_fn_args() {
// // This function will get passed in as a pointer.
// let src = indoc!(
// r#"
// r"
// apply = \f, x -> f x
// identity = \a -> a
// apply identity 5
// "#
// "
// );
// let arena = Bump::new();
// let (_actual, output, problems, _var_store, _vars, _constraint) =
@ -637,9 +637,9 @@ mod test_can {
#[test]
fn incorrect_optional_value() {
let src = indoc!(
r#"
r"
{ x ? 42 }
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -911,7 +911,7 @@ mod test_can {
#[test]
fn recognize_tail_calls() {
let src = indoc!(
r#"
r"
g = \x ->
when x is
0 -> 0
@ -936,7 +936,7 @@ mod test_can {
{ x: p, y: h }
)
)
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -963,7 +963,7 @@ mod test_can {
// #[test]
// fn reproduce_incorrect_unused_defs() {
// let src = indoc!(
// r#"
// r"
// g = \x ->
// when x is
// 0 -> 0
@ -983,7 +983,7 @@ mod test_can {
// # variables must be (indirectly) referenced in the body for analysis to work
// # { x: p, y: h }
// g
// "#
// "
// );
// let arena = Bump::new();
// let CanExprOut {
@ -1012,14 +1012,14 @@ mod test_can {
#[test]
fn when_tail_call() {
let src = indoc!(
r#"
r"
g = \x ->
when x is
0 -> 0
_ -> g (x + 1)
g 0
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -1034,11 +1034,11 @@ mod test_can {
#[test]
fn immediate_tail_call() {
let src = indoc!(
r#"
r"
f = \x -> f x
f 0
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -1055,13 +1055,13 @@ mod test_can {
#[test]
fn when_condition_is_no_tail_call() {
let src = indoc!(
r#"
r"
q = \x ->
when q x is
_ -> 0
q 0
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -1076,7 +1076,7 @@ mod test_can {
#[test]
fn good_mutual_recursion() {
let src = indoc!(
r#"
r"
q = \x ->
when x is
0 -> 0
@ -1088,7 +1088,7 @@ mod test_can {
_ -> q (x - 1)
q p
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -1107,11 +1107,11 @@ mod test_can {
#[test]
fn valid_self_recursion() {
let src = indoc!(
r#"
r"
boom = \_ -> boom {}
boom
"#
"
);
let arena = Bump::new();
let CanExprOut {
@ -1128,13 +1128,13 @@ mod test_can {
#[test]
fn invalid_mutual_recursion() {
let src = indoc!(
r#"
r"
x = y
y = z
z = x
x
"#
"
);
let home = test_home();
let arena = Bump::new();
@ -1176,11 +1176,11 @@ mod test_can {
#[test]
fn dict() {
let src = indoc!(
r#"
r"
x = Dict.empty {}
Dict.len x
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -1191,7 +1191,7 @@ mod test_can {
#[test]
fn unused_def_regression() {
let src = indoc!(
r#"
r"
Booly : [Yes, No, Maybe]
y : Booly
@ -1205,7 +1205,7 @@ mod test_can {
x = [y]
x
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -1216,14 +1216,14 @@ mod test_can {
#[test]
fn optional_field_not_unused() {
let src = indoc!(
r#"
r"
fallbackZ = 3
fn = \{ x, y, z ? fallbackZ } ->
{ x, y, z }
fn { x: 0, y: 1 }
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -1234,12 +1234,12 @@ mod test_can {
#[test]
fn issue_2534() {
let src = indoc!(
r#"
r"
x = { a: 1 }
{
x & a: 2
}
"#
"
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
@ -1252,13 +1252,13 @@ mod test_can {
// // "local" should be used, because the closure used it.
// // However, "unused" should be unused.
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// local = 5
// unused = 6
// func = \arg -> arg + local
// 3 + func 2
// "#
// "
// ));
// assert_eq!(
@ -1283,13 +1283,13 @@ mod test_can {
//fn unused_closure() {
// // "unused" should be unused because it's in func, which is unused.
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// local = 5
// unused = 6
// func = \arg -> arg + unused
// local
// "#
// "
// ));
// assert_eq!(
@ -1316,9 +1316,9 @@ mod test_can {
// #[test]
// fn basic_unrecognized_constant() {
// let (expr, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// x
// "#
// "
// ));
// assert_eq!(
@ -1342,12 +1342,12 @@ mod test_can {
//#[test]
//fn complex_unrecognized_constant() {
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// a = 5
// b = 6
// a + b * z
// "#
// "
// ));
// assert_eq!(
@ -1375,13 +1375,13 @@ mod test_can {
// // This should report that both a and b are unused, since the return expr never references them.
// // It should not report them as circular, since we haven't solved the halting problem here.
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// a = \arg -> if arg > 0 then b 7 else 0
// b = \arg -> if arg > 0 then a (arg - 1) else 0
// c = 5
// c
// "#
// "
// ));
// assert_eq!(problems, vec![unused("a"), unused("b")]);
@ -1400,7 +1400,7 @@ mod test_can {
//#[test]
//fn can_fibonacci() {
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// fibonacci = \num ->
// if num < 2 then
// num
@ -1408,7 +1408,7 @@ mod test_can {
// fibonacci (num - 1) + fibonacci (num - 2)
// fibonacci 9
// "#
// "
// ));
// assert_eq!(problems, vec![]);
@ -1430,7 +1430,7 @@ mod test_can {
// // is considered a tail call, even though it only
// // calls itself from one branch!
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// factorial = \num ->
// factorialHelp num 0
@ -1441,7 +1441,7 @@ mod test_can {
// factorialHelp (num - 1) (total * num)
// factorial 9
// "#
// "
// ));
// assert_eq!(problems, vec![]);
@ -1462,12 +1462,12 @@ mod test_can {
// // This should report that neither a nor b are unused,
// // since if you never call a function but do return it, that's okay!
// let (_, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// a = \_ -> 42
// b = a
// b
// "#
// "
// ));
// assert_eq!(problems, Vec::new());
@ -1488,14 +1488,14 @@ mod test_can {
//#[test]
//fn reorder_assignments() {
// let (expr, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// increment = \arg -> arg + 1
// z = (increment 2) + y
// y = x + 1
// x = 9
// z * 3
// "#
// "
// ));
// assert_eq!(problems, vec![]);
@ -1526,7 +1526,7 @@ mod test_can {
//#[test]
//fn reorder_closed_over_assignments() {
// let (expr, output, problems, _) = can_expr(indoc!(
// r#"
// r"
// z = func1 x
// x = 9
// y = func2 3
@ -1534,7 +1534,7 @@ mod test_can {
// func2 = \arg -> arg + x
// z
// "#
// "
// ));
// assert_eq!(problems, vec![]);
@ -1628,14 +1628,14 @@ mod test_can {
//#[test]
//fn circular_assignment() {
// let (_, _, problems, _) = can_expr(indoc!(
// r#"
// r"
// c = d + 3
// b = 2 + c
// d = a + 7
// a = b + 1
// 2 + d
// "#
// "
// ));
// assert_eq!(
@ -1655,9 +1655,9 @@ mod test_can {
// // There was a bug where this reported UnusedArgument("val")
// // since it was used only in the returned function only.
// let (_, _, problems, _) = can_expr(indoc!(
// r#"
// r"
// \val -> \_ -> val
// "#
// "
// ));
// assert_eq!(problems, vec![]);
@ -1831,7 +1831,7 @@ mod test_can {
// "abcd\\(efg)hij"
// "#
// ),
// Str(r#"abcd\(efg)hij"#.into()),
// Str(r"abcd\(efg)hij".into()),
// );
// }
@ -1848,7 +1848,7 @@ mod test_can {
// #[test]
// fn string_with_special_escapes() {
// expect_parsed_str(r#"x\x"#, r#""x\\x""#);
// expect_parsed_str(r"x\x", r#""x\\x""#);
// expect_parsed_str(r#"x"x"#, r#""x\"x""#);
// expect_parsed_str("x\tx", r#""x\tx""#);
// expect_parsed_str("x\rx", r#""x\rx""#);

File diff suppressed because it is too large Load Diff

View File

@ -325,7 +325,7 @@ fn import_transitive_alias() {
(
"RBTree",
indoc!(
r#"
r"
interface RBTree exposes [RedBlackTree, empty] imports []
# The color of a node. Leaves are considered Black.
@ -337,18 +337,18 @@ fn import_transitive_alias() {
empty : RedBlackTree k v
empty =
Empty
"#
"
),
),
(
"Other",
indoc!(
r#"
r"
interface Other exposes [empty] imports [RBTree]
empty : RBTree.RedBlackTree I64 I64
empty = RBTree.empty
"#
"
),
),
];
@ -628,11 +628,11 @@ fn parse_problem() {
let modules = vec![(
"Main",
indoc!(
r#"
r"
interface Main exposes [main] imports []
main = [
"#
"
),
)];
@ -820,23 +820,23 @@ fn opaque_wrapped_unwrapped_outside_defining_module() {
(
"Age",
indoc!(
r#"
r"
interface Age exposes [Age] imports []
Age := U32
"#
"
),
),
(
"Main",
indoc!(
r#"
r"
interface Main exposes [twenty, readAge] imports [Age.{ Age }]
twenty = @Age 20
readAge = \@Age n -> n
"#
"
),
),
];
@ -846,7 +846,7 @@ fn opaque_wrapped_unwrapped_outside_defining_module() {
assert_eq!(
err,
indoc!(
r#"
r"
OPAQUE TYPE DECLARED OUTSIDE SCOPE ...rapped_outside_defining_module/Main
The unwrapped opaque type Age referenced here:
@ -883,7 +883,7 @@ fn opaque_wrapped_unwrapped_outside_defining_module() {
^^^^^^^^^^^
Since Age isn't used, you don't need to import it.
"#
"
),
"\n{}",
err
@ -993,11 +993,11 @@ fn module_doesnt_match_file_path() {
let modules = vec![(
"Age",
indoc!(
r#"
r"
interface NotAge exposes [Age] imports []
Age := U32
"#
"
),
)];
@ -1005,7 +1005,7 @@ fn module_doesnt_match_file_path() {
assert_eq!(
err,
indoc!(
r#"
r"
WEIRD MODULE NAME tmp/module_doesnt_match_file_path/Age
This module name does not correspond with the file path it is defined
@ -1016,7 +1016,7 @@ fn module_doesnt_match_file_path() {
Module names must correspond with the file paths they are defined in.
For example, I expect to see BigNum defined in BigNum.roc, or Math.Sin
defined in Math/Sin.roc."#
defined in Math/Sin.roc."
),
"\n{}",
err
@ -1028,9 +1028,9 @@ fn module_cyclic_import_itself() {
let modules = vec![(
"Age",
indoc!(
r#"
r"
interface Age exposes [] imports [Age]
"#
"
),
)];
@ -1038,7 +1038,7 @@ fn module_cyclic_import_itself() {
assert_eq!(
err,
indoc!(
r#"
r"
IMPORT CYCLE tmp/module_cyclic_import_itself/Age
I can't compile Age because it depends on itself through the following
@ -1052,7 +1052,7 @@ fn module_cyclic_import_itself() {
Cyclic dependencies are not allowed in Roc! Can you restructure a
module in this import chain so that it doesn't have to depend on
itself?"#
itself?"
),
"\n{}",
err
@ -1065,17 +1065,17 @@ fn module_cyclic_import_transitive() {
(
"Age",
indoc!(
r#"
r"
interface Age exposes [] imports [Person]
"#
"
),
),
(
"Person",
indoc!(
r#"
r"
interface Person exposes [] imports [Age]
"#
"
),
),
];
@ -1084,7 +1084,7 @@ fn module_cyclic_import_transitive() {
assert_eq!(
err,
indoc!(
r#"
r"
IMPORT CYCLE tmp/module_cyclic_import_transitive/Age.roc
I can't compile Age because it depends on itself through the following
@ -1100,7 +1100,7 @@ fn module_cyclic_import_transitive() {
Cyclic dependencies are not allowed in Roc! Can you restructure a
module in this import chain so that it doesn't have to depend on
itself?"#
itself?"
),
"\n{}",
err
@ -1113,17 +1113,17 @@ fn nested_module_has_incorrect_name() {
(
"Dep/Foo.roc",
indoc!(
r#"
r"
interface Foo exposes [] imports []
"#
"
),
),
(
"I.roc",
indoc!(
r#"
r"
interface I exposes [] imports [Dep.Foo]
"#
"
),
),
];
@ -1132,7 +1132,7 @@ fn nested_module_has_incorrect_name() {
assert_eq!(
err,
indoc!(
r#"
r"
INCORRECT MODULE NAME tmp/nested_module_has_incorrect_name/Dep/Foo.roc
This module has a different name than I expected:
@ -1142,7 +1142,7 @@ fn nested_module_has_incorrect_name() {
Based on the nesting and use of this module, I expect it to have name
Dep.Foo"#
Dep.Foo"
),
"\n{}",
err

View File

@ -272,11 +272,11 @@ mod test_parse {
let arena = Bump::new();
let src = indoc!(
r#"
r"
foo = \list ->
isTest = \_ -> 5
List.map list isTest
"#
"
);
let actual = module_defs()
.parse(&arena, State::new(src.as_bytes()), 0)
@ -295,12 +295,12 @@ mod test_parse {
// highlights a problem with the else branch demanding a newline after its expression
let src = indoc!(
r#"
r"
main =
v = \y -> if x then y else z
1
"#
"
);
let state = State::new(src.as_bytes());

File diff suppressed because it is too large Load Diff

View File

@ -542,7 +542,7 @@ mod encode_immediate {
_ -> "<bad>"
"#
), $num, stringify!($typ)),
RocStr::from(format!(r#"{}"#, $num).as_str()),
RocStr::from(format!(r"{}", $num).as_str()),
RocStr
)
}
@ -1011,7 +1011,7 @@ fn decode_derive_decoder_for_opaque() {
_ -> "FAIL"
"#
),
RocStr::from(r#"Hello, World!"#),
RocStr::from(r"Hello, World!"),
RocStr
)
}
@ -1458,7 +1458,7 @@ mod hash {
use indoc::indoc;
const TEST_HASHER: &str = indoc!(
r#"
r"
THasher := List U8 implements [Hasher {
addBytes: tAddBytes,
addU8: tAddU8,
@ -1507,7 +1507,7 @@ mod hash {
tComplete = \@THasher _ -> Num.maxU64
tRead = \@THasher bytes -> bytes
"#
"
);
fn build_test(input: &str) -> String {
@ -1668,7 +1668,7 @@ mod hash {
#[test]
fn list_u8() {
assert_evals_to!(
&build_test(r#"[15u8, 23u8, 37u8]"#),
&build_test(r"[15u8, 23u8, 37u8]"),
RocList::from_slice(&[15, 23, 37]),
RocList<u8>
)
@ -1700,7 +1700,7 @@ mod hash {
#[test]
fn empty_record() {
assert_evals_to!(
&build_test(r#"{}"#),
&build_test(r"{}"),
RocList::from_slice(&[] as &[u8]),
RocList<u8>
)
@ -1728,7 +1728,7 @@ mod hash {
fn record_of_list_of_records() {
assert_evals_to!(
&build_test(
r#"{ a: [ { b: 15u8 }, { b: 23u8 } ], b: [ { c: 45u8 }, { c: 73u8 } ] }"#
r"{ a: [ { b: 15u8 }, { b: 23u8 } ], b: [ { c: 45u8 }, { c: 73u8 } ] }"
),
RocList::from_slice(&[15, 23, 45, 73]),
RocList<u8>
@ -1757,7 +1757,7 @@ mod hash {
fn tuple_of_list_of_tuples() {
assert_evals_to!(
&build_test(
r#"( [ ( 15u8, 32u8 ), ( 23u8, 41u8 ) ], [ (45u8, 63u8), (58u8, 73u8) ] )"#
r"( [ ( 15u8, 32u8 ), ( 23u8, 41u8 ) ], [ (45u8, 63u8), (58u8, 73u8) ] )"
),
RocList::from_slice(&[15, 32, 23, 41, 45, 63, 58, 73]),
RocList<u8>
@ -2152,7 +2152,7 @@ fn issue_4772_weakened_monomorphic_destructure() {
with_larger_debug_stack(|| {
assert_evals_to!(
indoc!(
r###"
r#"
app "test"
imports [TotallyNotJson]
provides [main] to "./platform"
@ -2173,7 +2173,7 @@ fn issue_4772_weakened_monomorphic_destructure() {
main =
getNumber |> Result.map .val |> Result.withDefault 0
"###
"#
),
1234i64,
i64
@ -2302,7 +2302,7 @@ mod inspect {
main = Inspect.toStr (@Op {})
"#
),
RocStr::from(r#"<opaque>"#),
RocStr::from(r"<opaque>"),
RocStr
);
}
@ -2322,7 +2322,7 @@ mod inspect {
main = late (@Op {})
"#
),
RocStr::from(r#"<opaque>"#),
RocStr::from(r"<opaque>"),
RocStr
);
}

View File

@ -19,11 +19,11 @@ use roc_std::{RocList, RocResult, RocStr};
fn def_closure_in_parens() {
assert_evals_to!(
indoc!(
r#"
r"
id = (\x -> x)
id 42u32
"#
"
),
42,
u32
@ -35,11 +35,11 @@ fn def_closure_in_parens() {
fn def_closure_in_multiple_parens() {
assert_evals_to!(
indoc!(
r#"
r"
id = (((\x -> x)))
id 42u32
"#
"
),
42,
u32

View File

@ -20,9 +20,9 @@ use roc_std::{RocList, RocStr};
fn dict_empty_len() {
assert_evals_to!(
indoc!(
r#"
r"
Dict.len (Dict.empty {})
"#
"
),
0,
usize
@ -34,11 +34,11 @@ fn dict_empty_len() {
fn dict_insert_empty() {
assert_evals_to!(
indoc!(
r#"
r"
Dict.empty {}
|> Dict.insert 42 32
|> Dict.len
"#
"
),
1,
usize
@ -50,12 +50,12 @@ fn dict_insert_empty() {
fn dict_empty_contains() {
assert_evals_to!(
indoc!(
r#"
r"
empty : Dict.Dict I64 F64
empty = Dict.empty {}
Dict.contains empty 42
"#
"
),
false,
bool
@ -67,12 +67,12 @@ fn dict_empty_contains() {
fn dict_nonempty_contains() {
assert_evals_to!(
indoc!(
r#"
r"
empty : Dict.Dict I64 F64
empty = Dict.insert (Dict.empty {}) 42 1.23
Dict.contains empty 42
"#
"
),
true,
bool
@ -85,14 +85,14 @@ fn dict_nonempty_contains() {
fn dict_empty_remove() {
assert_evals_to!(
indoc!(
r#"
r"
empty : Dict.Dict I64 F64
empty = Dict.empty {}
empty
|> Dict.remove 42
|> Dict.len
"#
"
),
0,
i64
@ -104,7 +104,7 @@ fn dict_empty_remove() {
fn dict_nonempty_remove() {
assert_evals_to!(
indoc!(
r#"
r"
empty : Dict.Dict I64 F64
empty = Dict.insert (Dict.empty {}) 42 1.23
@ -112,7 +112,7 @@ fn dict_nonempty_remove() {
|> Dict.remove 42
|> Dict.len
|> Num.toI64
"#
"
),
0,
i64
@ -124,7 +124,7 @@ fn dict_nonempty_remove() {
fn dict_nonempty_get() {
assert_evals_to!(
indoc!(
r#"
r"
empty : Dict.Dict I64 F64
empty = Dict.insert (Dict.empty {}) 42 1.23
@ -137,7 +137,7 @@ fn dict_nonempty_get() {
|> Dict.insert 42 1.23f64
|> Dict.get 42
|> withDefault 0
"#
"
),
1.23,
f64
@ -145,7 +145,7 @@ fn dict_nonempty_get() {
assert_evals_to!(
indoc!(
r#"
r"
withDefault = \x, def ->
when x is
Ok v -> v
@ -155,7 +155,7 @@ fn dict_nonempty_get() {
|> Dict.insert 42 1.23f64
|> Dict.get 43
|> withDefault 0
"#
"
),
0.0,
f64
@ -167,7 +167,7 @@ fn dict_nonempty_get() {
fn keys() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 I64
myDict =
Dict.empty {}
@ -177,7 +177,7 @@ fn keys() {
Dict.keys myDict
"#
"
),
RocList::from_slice(&[0, 1, 2]),
RocList<i64>
@ -189,7 +189,7 @@ fn keys() {
fn values() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 I64
myDict =
Dict.empty {}
@ -199,7 +199,7 @@ fn values() {
Dict.values myDict
"#
"
),
RocList::from_slice(&[100, 200, 300]),
RocList<i64>
@ -211,14 +211,14 @@ fn values() {
fn from_list_with_fold_simple() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 I64
myDict =
[1,2,3]
|> List.walk (Dict.empty {}) (\accum, value -> Dict.insert accum value value)
Dict.values myDict
"#
"
),
RocList::from_slice(&[1, 2, 3]),
RocList<i64>
@ -230,7 +230,7 @@ fn from_list_with_fold_simple() {
fn from_list_with_fold_reallocates() {
assert_evals_to!(
indoc!(
r#"
r"
range : I64, I64, List I64-> List I64
range = \low, high, accum ->
if low < high then
@ -245,7 +245,7 @@ fn from_list_with_fold_reallocates() {
|> List.walk (Dict.empty {}) (\accum, value -> Dict.insert accum value value)
Dict.values myDict
"#
"
),
RocList::from_slice(&[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
@ -329,7 +329,7 @@ fn big_str_values() {
fn unit_values() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 {}
myDict =
Dict.empty {}
@ -339,7 +339,7 @@ fn unit_values() {
|> Dict.insert 3 {}
Num.toI64 (Dict.len myDict)
"#
"
),
4,
i64
@ -351,13 +351,13 @@ fn unit_values() {
fn single() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 {}
myDict =
Dict.single 12345 {}
Num.toI64 (Dict.len myDict)
"#
"
),
1,
i64
@ -369,14 +369,14 @@ fn single() {
fn insert_all() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict I64 {}
myDict =
Dict.insertAll (Dict.single 0 {}) (Dict.single 1 {})
Dict.len myDict
|> Num.toI64
"#
"
),
2,
i64
@ -388,14 +388,14 @@ fn insert_all() {
fn insert_all_prefer_second() {
assert_evals_to!(
indoc!(
r#"
r"
myDict : Dict.Dict I64 I64
myDict =
(Dict.single 0 100)
|> Dict.insertAll (Dict.single 0 200)
Dict.values myDict
"#
"
),
RocList::from_slice(&[200]),
RocList<i64>
@ -407,7 +407,7 @@ fn insert_all_prefer_second() {
fn keep_shared() {
assert_evals_to!(
indoc!(
r#"
r"
dict1 : Dict.Dict I64 {}
dict1 =
Dict.empty {}
@ -427,7 +427,7 @@ fn keep_shared() {
Dict.keepShared dict1 dict2
|> Dict.len
|> Num.toI64
"#
"
),
2,
i64
@ -439,7 +439,7 @@ fn keep_shared() {
fn keep_shared_value_must_match() {
assert_evals_to!(
indoc!(
r#"
r"
dict1 : Dict.Dict I64 I64
dict1 =
Dict.empty {}
@ -458,7 +458,7 @@ fn keep_shared_value_must_match() {
Dict.keepShared dict1 dict2
|> Dict.values
"#
"
),
RocList::from_slice(&[2]),
RocList<i64>
@ -470,7 +470,7 @@ fn keep_shared_value_must_match() {
fn remove_all() {
assert_evals_to!(
indoc!(
r#"
r"
dict1 : Dict.Dict I64 {}
dict1 =
Dict.empty {}
@ -490,7 +490,7 @@ fn remove_all() {
Dict.removeAll dict1 dict2
|> Dict.len
|> Num.toI64
"#
"
),
3,
i64
@ -502,7 +502,7 @@ fn remove_all() {
fn remove_all_prefer_first() {
assert_evals_to!(
indoc!(
r#"
r"
dict1 : Dict.Dict I64 I64
dict1 =
Dict.empty {}
@ -521,7 +521,7 @@ fn remove_all_prefer_first() {
Dict.removeAll dict1 dict2
|> Dict.values
"#
"
),
RocList::from_slice(&[1, 5, 3]),
RocList<i64>
@ -533,7 +533,7 @@ fn remove_all_prefer_first() {
fn walk_sum_keys() {
assert_evals_to!(
indoc!(
r#"
r"
dict1 : Dict.Dict I64 I64
dict1 =
Dict.empty {}
@ -544,7 +544,7 @@ fn walk_sum_keys() {
|> Dict.insert 5 5
Dict.walk dict1 0 \k, _, a -> k + a
"#
"
),
15,
i64

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -28,11 +28,11 @@ fn basic_float() {
fn branch_first_float() {
assert_evals_to!(
indoc!(
r#"
r"
when 1.23f64 is
1.23 -> 12
_ -> 34
"#
"
),
12,
i64
@ -44,11 +44,11 @@ fn branch_first_float() {
fn branch_second_float() {
assert_evals_to!(
indoc!(
r#"
r"
when 2.34 is
1.23 -> 63
_ -> 48
"#
"
),
48,
i64
@ -60,12 +60,12 @@ fn branch_second_float() {
fn branch_third_float() {
assert_evals_to!(
indoc!(
r#"
r"
when 10.0 is
1.0 -> 63
2.0 -> 48
_ -> 112
"#
"
),
112,
i64
@ -77,11 +77,11 @@ fn branch_third_float() {
fn branch_first_int() {
assert_evals_to!(
indoc!(
r#"
r"
when 1 is
1 -> 12
_ -> 34
"#
"
),
12,
i64
@ -93,11 +93,11 @@ fn branch_first_int() {
fn branch_second_int() {
assert_evals_to!(
indoc!(
r#"
r"
when 2 is
1 -> 63
_ -> 48
"#
"
),
48,
i64
@ -109,12 +109,12 @@ fn branch_second_int() {
fn branch_third_int() {
assert_evals_to!(
indoc!(
r#"
r"
when 10 is
1 -> 63
2 -> 48
_ -> 112
"#
"
),
112,
i64
@ -126,11 +126,11 @@ fn branch_third_int() {
fn branch_store_variable() {
assert_evals_to!(
indoc!(
r#"
r"
when 0 is
1 -> 12
a -> a
"#
"
),
0,
i64
@ -142,13 +142,13 @@ fn branch_store_variable() {
fn when_one_element_tag() {
assert_evals_to!(
indoc!(
r#"
r"
x : [Pair (Int a) (Int a)]
x = Pair 0x2 0x3
when x is
Pair l r -> l + r
"#
"
),
5,
i64
@ -160,14 +160,14 @@ fn when_one_element_tag() {
fn when_two_element_tag_first() {
assert_evals_to!(
indoc!(
r#"
r"
x : [A (Int a), B (Int a)]
x = A 0x2
when x is
A v -> v
B v -> v
"#
"
),
2,
i64
@ -179,14 +179,14 @@ fn when_two_element_tag_first() {
fn when_two_element_tag_second() {
assert_evals_to!(
indoc!(
r#"
r"
x : [A (Int a), B (Int a)]
x = B 0x3
when x is
A v -> v
B v -> v
"#
"
),
3,
i64
@ -198,10 +198,10 @@ fn when_two_element_tag_second() {
fn gen_when_one_branch() {
assert_evals_to!(
indoc!(
r#"
r"
when 1.23 is
_ -> 23
"#
"
),
23,
i64
@ -213,7 +213,7 @@ fn gen_when_one_branch() {
fn gen_large_when_int() {
assert_evals_to!(
indoc!(
r#"
r"
foo = \num ->
when num is
0 -> 200
@ -224,7 +224,7 @@ fn gen_large_when_int() {
_ -> 1000
foo -3
"#
"
),
111,
i64
@ -236,7 +236,7 @@ fn gen_large_when_int() {
fn gen_large_when_float() {
assert_evals_to!(
indoc!(
r#"
r"
foo = \num ->
when num is
0.5f64 -> 200.1
@ -247,7 +247,7 @@ fn gen_large_when_float() {
_ -> 1000.6f64
foo -3.6
"#
"
),
111.2,
f64
@ -259,11 +259,11 @@ fn gen_large_when_float() {
fn or_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when 2 is
1 | 2 -> 42
_ -> 1
"#
"
),
42,
i64
@ -275,11 +275,11 @@ fn or_pattern() {
fn apply_identity() {
assert_evals_to!(
indoc!(
r#"
r"
identity = \a -> a
identity 5
"#
"
),
5,
i64
@ -291,12 +291,12 @@ fn apply_identity() {
fn apply_unnamed_identity() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
(\a -> a) 5
wrapper {}
"#
"
),
5,
i64
@ -308,7 +308,7 @@ fn apply_unnamed_identity() {
fn return_unnamed_fn() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
alwaysFloatIdentity : Int * -> (Frac a -> Frac a)
alwaysFloatIdentity = \_ ->
@ -317,7 +317,7 @@ fn return_unnamed_fn() {
(alwaysFloatIdentity 2) 1.23f64
wrapper {}
"#
"
),
1.23,
f64
@ -329,7 +329,7 @@ fn return_unnamed_fn() {
fn gen_when_fn() {
assert_evals_to!(
indoc!(
r#"
r"
limitedNegate = \num ->
when num is
1 -> -1
@ -337,7 +337,7 @@ fn gen_when_fn() {
_ -> num
limitedNegate 1
"#
"
),
-1,
i64
@ -349,11 +349,11 @@ fn gen_when_fn() {
fn gen_basic_def() {
assert_evals_to!(
indoc!(
r#"
r"
answer = 42
answer
"#
"
),
42,
i64
@ -361,11 +361,11 @@ fn gen_basic_def() {
assert_evals_to!(
indoc!(
r#"
r"
float = 1.23f64
float
"#
"
),
1.23,
f64
@ -377,13 +377,13 @@ fn gen_basic_def() {
fn gen_multiple_defs() {
assert_evals_to!(
indoc!(
r#"
r"
answer = 42
float = 1.23f64
if float > 3 then answer else answer
"#
"
),
42,
i64
@ -391,13 +391,13 @@ fn gen_multiple_defs() {
assert_evals_to!(
indoc!(
r#"
r"
answer = 42
float = 1.23f64
if answer > 3 then float else float
"#
"
),
1.23,
f64
@ -411,7 +411,7 @@ fn gen_multiple_defs() {
// fn gen_chained_defs() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// x = i1
// i3 = i2
// i1 = 1337
@ -419,7 +419,7 @@ fn gen_multiple_defs() {
// y = 12.4
//
// i3
// "#
// "
// ),
// 1337,
// i64
@ -431,7 +431,7 @@ fn gen_multiple_defs() {
// fn gen_nested_defs_old() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// x = 5
//
// answer =
@ -461,7 +461,7 @@ fn gen_multiple_defs() {
// y = 12.4
//
// answer
// "#
// "
// ),
// 1337,
// i64
@ -473,7 +473,7 @@ fn gen_multiple_defs() {
// fn let_x_in_x() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// x = 5
//
// answer =
@ -484,7 +484,7 @@ fn gen_multiple_defs() {
// nested
//
// answer
// "#
// "
// ),
// 1337,
// i64
@ -496,7 +496,7 @@ fn gen_multiple_defs() {
fn factorial() {
assert_evals_to!(
indoc!(
r#"
r"
factorial = \n, accum ->
when n is
0 ->
@ -506,7 +506,7 @@ fn factorial() {
factorial (n - 1) (n * accum)
factorial 10 1
"#
"
),
3628800,
i64
@ -518,7 +518,7 @@ fn factorial() {
fn peano1() {
assert_evals_to!(
indoc!(
r#"
r"
Peano : [S Peano, Z]
three : Peano
@ -527,7 +527,7 @@ fn peano1() {
when three is
Z -> 2
S _ -> 1
"#
"
),
1,
i64
@ -539,7 +539,7 @@ fn peano1() {
fn peano2() {
assert_evals_to!(
indoc!(
r#"
r"
Peano : [S Peano, Z]
three : Peano
@ -549,7 +549,7 @@ fn peano2() {
S (S _) -> 1
S (_) -> 0
Z -> 0
"#
"
),
1,
i64
@ -833,7 +833,7 @@ fn linked_list_map() {
fn when_nested_maybe() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int a))
@ -842,7 +842,7 @@ fn when_nested_maybe() {
when x is
Just (Just v) -> v + 0x1
_ -> 0x1
"#
"
),
42,
i64
@ -850,7 +850,7 @@ fn when_nested_maybe() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int *))
@ -860,7 +860,7 @@ fn when_nested_maybe() {
Just (Just v) -> v + 0x1
Just Nothing -> 0x2
Nothing -> 0x1
"#
"
),
2,
i64
@ -868,7 +868,7 @@ fn when_nested_maybe() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe (Int *))
@ -878,7 +878,7 @@ fn when_nested_maybe() {
Just (Just v) -> v + 0x1
Just Nothing -> 0x2
Nothing -> 0x1
"#
"
),
1,
i64
@ -890,7 +890,7 @@ fn when_nested_maybe() {
fn when_peano() {
assert_evals_to!(
indoc!(
r#"
r"
Peano : [S Peano, Z]
three : Peano
@ -900,7 +900,7 @@ fn when_peano() {
S (S _) -> 1
S (_) -> 2
Z -> 3
"#
"
),
1,
i64
@ -908,7 +908,7 @@ fn when_peano() {
assert_evals_to!(
indoc!(
r#"
r"
Peano : [S Peano, Z]
three : Peano
@ -918,7 +918,7 @@ fn when_peano() {
S (S _) -> 1
S (_) -> 2
Z -> 3
"#
"
),
2,
i64
@ -926,7 +926,7 @@ fn when_peano() {
assert_evals_to!(
indoc!(
r#"
r"
Peano : [S Peano, Z]
three : Peano
@ -936,7 +936,7 @@ fn when_peano() {
S (S _) -> 1
S (_) -> 2
Z -> 3
"#
"
),
3,
i64
@ -955,7 +955,7 @@ fn when_peano() {
fn overflow_frees_list() {
assert_evals_to!(
indoc!(
r#"
r"
myList = [1,2,3]
# integer overflow; must use the list so it is defined before the overflow
@ -967,7 +967,7 @@ fn overflow_frees_list() {
index = Num.intCast n
List.get myList index
"#
"
),
(3, 0),
(i64, i8)
@ -980,12 +980,12 @@ fn overflow_frees_list() {
fn undefined_variable() {
assert_evals_to!(
indoc!(
r#"
r"
if Bool.true then
x + z
else
y + z
"#
"
),
3,
i64
@ -1016,12 +1016,12 @@ fn a_crash() {
fn annotation_without_body() {
assert_evals_to!(
indoc!(
r#"
r"
foo : Int *
foo
"#
"
),
3,
i64
@ -2022,11 +2022,11 @@ fn hof_conditional() {
// exposed issue with the if condition being just a symbol
assert_evals_to!(
indoc!(
r#"
r"
passTrue = \f -> f Bool.true
passTrue (\trueVal -> if trueVal then Bool.false else Bool.true)
"#
"
),
0,
u8
@ -2041,12 +2041,12 @@ fn hof_conditional() {
fn pattern_shadowing() {
assert_evals_to!(
indoc!(
r#"
r"
x = 4
when 4 is
x -> x
"#
"
),
0,
i64
@ -2060,11 +2060,11 @@ fn pattern_shadowing() {
fn unsupported_pattern_str_interp() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 4 } = { x : 4 }
x
"#
"
),
0,
i64
@ -2120,14 +2120,14 @@ fn case_or_pattern() {
// it is currently duplicated
assert_evals_to!(
indoc!(
r#"
r"
x : [Red, Green, Blue]
x = Red
when x is
Red | Green -> 0
Blue -> 1
"#
"
),
0,
i64
@ -2517,11 +2517,11 @@ fn backpassing_result() {
fn function_malformed_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
x = 3
(\x -> x) 42
"#
"
),
3,
i64
@ -2534,12 +2534,12 @@ fn function_malformed_pattern() {
fn call_invalid_layout() {
assert_evals_to!(
indoc!(
r#"
r"
f : I64 -> I64
f = \x -> x
f {}
"#
"
),
3,
i64,
@ -3261,12 +3261,12 @@ fn polymophic_expression_captured_inside_closure() {
fn issue_2322() {
assert_evals_to!(
indoc!(
r#"
r"
double = \x -> x * 2
doubleBind = \x -> (\_ -> double x)
doubleThree = doubleBind 3
doubleThree {}
"#
"
),
6,
i64
@ -3312,14 +3312,14 @@ fn box_and_unbox_big_string() {
fn box_and_unbox_nonrecursive_tag() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result U64 U64
result = Ok 42
result
|> Box.box
|> Box.unbox
"#
"
),
roc_std::RocResult::ok(42),
roc_std::RocResult<u64, u64>
@ -3409,9 +3409,9 @@ fn box_and_unbox_f32() {
fn box_and_unbox_record_2_u64() {
assert_evals_to!(
indoc!(
r#"
r"
Box.unbox (Box.box { a: 15u64, b: 27u64 })
"#
"
),
(15, 27),
(u64, u64)
@ -3423,9 +3423,9 @@ fn box_and_unbox_record_2_u64() {
fn box_and_unbox_record_3_u64() {
assert_evals_to!(
indoc!(
r#"
r"
Box.unbox (Box.box { a: 15u64, b: 27u64, c: 34u64 })
"#
"
),
(15, 27, 34),
(u64, u64, u64)
@ -3437,9 +3437,9 @@ fn box_and_unbox_record_3_u64() {
fn box_and_unbox_record_2_u8() {
assert_evals_to!(
indoc!(
r#"
r"
Box.unbox (Box.box { a: 15u8, b: 27u8 })
"#
"
),
(15, 27),
(u8, u8)
@ -3451,9 +3451,9 @@ fn box_and_unbox_record_2_u8() {
fn box_and_unbox_record_3_u8() {
assert_evals_to!(
indoc!(
r#"
r"
Box.unbox (Box.box { a: 15u8, b: 27u8, c: 34u8 })
"#
"
),
(15, 27, 34),
(u8, u8, u8)
@ -3465,12 +3465,12 @@ fn box_and_unbox_record_3_u8() {
fn box_and_unbox_tag_union() {
assert_evals_to!(
indoc!(
r#"
r"
v : [A U8, B U8] # usually stack allocated
v = B 27u8
Box.unbox (Box.box v)
"#
"
),
(27, 1),
(u8, u8)
@ -3534,7 +3534,7 @@ fn issue_2894() {
fn polymorphic_def_used_in_closure() {
assert_evals_to!(
indoc!(
r#"
r"
a : I64 -> _
a = \g ->
f = { r: g, h: 32 }
@ -3543,7 +3543,7 @@ fn polymorphic_def_used_in_closure() {
h1 = (\{} -> f.h) {}
h1
a 1
"#
"
),
32,
u64
@ -3555,13 +3555,13 @@ fn polymorphic_def_used_in_closure() {
fn polymorphic_lambda_set_usage() {
assert_evals_to!(
indoc!(
r#"
r"
id1 = \x -> x
id2 = \y -> y
id = if Bool.true then id1 else id2
id 9u8
"#
"
),
9,
u8
@ -3573,7 +3573,7 @@ fn polymorphic_lambda_set_usage() {
fn polymorphic_lambda_set_multiple_specializations() {
assert_evals_to!(
indoc!(
r#"
r"
id1 = \x -> x
id2 = \y -> y
id = \z ->
@ -3581,7 +3581,7 @@ fn polymorphic_lambda_set_multiple_specializations() {
f z
(id 9u8) + Num.toU8 (id 16u16)
"#
"
),
25,
u8
@ -3642,14 +3642,14 @@ fn mutual_recursion_top_level_defs() {
fn polymorphic_lambda_captures_polymorphic_value() {
assert_evals_to!(
indoc!(
r#"
r"
x = 2
f1 = \_ -> x
f = if Bool.true then f1 else f1
f {}
"#
"
),
2,
u64
@ -3661,7 +3661,7 @@ fn polymorphic_lambda_captures_polymorphic_value() {
fn lambda_capture_niche_u64_vs_u8_capture() {
assert_evals_to!(
indoc!(
r#"
r"
capture : _ -> ({} -> Str)
capture = \val ->
\{} ->
@ -3677,7 +3677,7 @@ fn lambda_capture_niche_u64_vs_u8_capture() {
capture 18u8
fun {}
"#
"
),
RocStr::from("123"),
RocStr
@ -3789,14 +3789,14 @@ fn lambda_capture_niches_have_captured_function_in_closure() {
fn recursive_call_capturing_function() {
assert_evals_to!(
indoc!(
r#"
r"
a = \b ->
c = \d ->
if d == 7 then d else c (d + b)
c 1
a 6
"#
"
),
7,
i64
@ -3808,13 +3808,13 @@ fn recursive_call_capturing_function() {
fn shared_pattern_variable_in_when_branches() {
assert_evals_to!(
indoc!(
r#"
r"
f = \t ->
when t is
A x | B x -> x
{a: f (A 15u8), b: (B 31u8)}
"#
"
),
(15u8, 31u8),
(u8, u8)
@ -3826,12 +3826,12 @@ fn shared_pattern_variable_in_when_branches() {
fn symbol_not_bound_in_all_patterns_runs_when_no_bound_symbol_used() {
assert_evals_to!(
indoc!(
r#"
r"
f = \t -> when t is
A x | B y -> 31u8
{a: f (A 15u8), b: f (B 15u8)}
"#
"
),
(31u8, 31u8),
(u8, u8),
@ -3845,10 +3845,10 @@ fn symbol_not_bound_in_all_patterns_runs_when_no_bound_symbol_used() {
fn symbol_not_bound_in_all_patterns_runs_when_bound_pattern_reached() {
assert_evals_to!(
indoc!(
r#"
r"
when A 15u8 is
A x | B y -> x
"#
"
),
15u8,
u8,
@ -3865,10 +3865,10 @@ fn symbol_not_bound_in_all_patterns_runs_when_bound_pattern_reached() {
fn runtime_error_when_degenerate_pattern_reached() {
assert_evals_to!(
indoc!(
r#"
r"
when B 15u8 is
A x | B y -> x + 5u8
"#
"
),
15u8,
u8,
@ -4399,7 +4399,7 @@ fn pattern_as_of_symbol() {
fn function_specialization_information_in_lambda_set_thunk() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
andThen = \{} ->
@ -4409,7 +4409,7 @@ fn function_specialization_information_in_lambda_set_thunk() {
between = andThen {}
main = between \{} -> between \{} -> 10u8
"###
"#
),
30,
u8
@ -4421,7 +4421,7 @@ fn function_specialization_information_in_lambda_set_thunk() {
fn function_specialization_information_in_lambda_set_thunk_independent_defs() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
andThen = \{} ->
@ -4433,7 +4433,7 @@ fn function_specialization_information_in_lambda_set_thunk_independent_defs() {
between2 = andThen {}
main = between1 \{} -> between2 \{} -> 10u8
"###
"#
),
30,
u8
@ -4526,7 +4526,7 @@ fn layout_cache_structure_with_multiple_recursive_structures() {
fn reset_recursive_type_wraps_in_named_type() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
main : Str
@ -4553,7 +4553,7 @@ fn reset_recursive_type_wraps_in_named_type() {
strX = f x
strXs = printLinkedList xs f
"Cons \(strX) (\(strXs))"
"###
"#
),
RocStr::from("Cons 2 (Cons 3 (Cons 4 (Nil)))"),
RocStr
@ -4619,12 +4619,12 @@ fn many_arguments() {
// exhausts all argument registers on x86 and aarch
assert_evals_to!(
indoc!(
r#"
r"
fun = \a,b,c,d, e,f,g,h, i ->
(a + b + c + d) + (e + f + g + h) + i
fun 0i64 1 2 3 4 5 6 7 8
"#
"
),
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8,
i64
@ -4636,9 +4636,9 @@ fn many_arguments() {
fn multiple_uses_of_bool_true_record() {
assert_evals_to!(
indoc!(
r#"
r"
(Bool.true, Bool.true).0
"#
"
),
true,
bool
@ -4650,14 +4650,14 @@ fn multiple_uses_of_bool_true_record() {
fn multiple_uses_of_bool_true_tag_union() {
assert_evals_to!(
indoc!(
r#"
r"
x : [ One Bool Bool, Empty ]
x = One Bool.true Bool.true
when x is
One a _ -> a
Empty -> Bool.false
"#
"
),
true,
bool

View File

@ -18,9 +18,9 @@ use roc_std::{RocList, RocStr};
fn basic_record() {
assert_evals_to!(
indoc!(
r#"
r"
{ y: 17, x: 15, z: 19 }.x
"#
"
),
15,
i64
@ -28,9 +28,9 @@ fn basic_record() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 15, y: 17, z: 19 }.y
"#
"
),
17,
i64
@ -38,9 +38,9 @@ fn basic_record() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 15, y: 17, z: 19 }.z
"#
"
),
19,
i64
@ -52,11 +52,11 @@ fn basic_record() {
fn f64_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { y: 17.2f64, x: 15.1f64, z: 19.3f64 }
rec.x
"#
"
),
15.1,
f64
@ -64,11 +64,11 @@ fn f64_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { y: 17.2f64, x: 15.1f64, z: 19.3f64 }
rec.y
"#
"
),
17.2,
f64
@ -76,11 +76,11 @@ fn f64_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { y: 17.2f64, x: 15.1f64, z: 19.3f64 }
rec.z
"#
"
),
19.3,
f64
@ -93,14 +93,14 @@ fn pass_bool_record() {
// found a bug there the register to use was not incremented correctly
assert_evals_to!(
indoc!(
r#"
r"
true : Bool
true = Bool.true
f = \_, x -> x
f { x: true, y: true } 23
"#
"
),
23,
i64
@ -124,11 +124,11 @@ fn fn_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { x: 15, y: 17, z: 19 }
rec.z + rec.x
"#
"
),
34,
i64
@ -140,11 +140,11 @@ fn fn_record() {
fn def_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { y: 17, x: 15, z: 19 }
rec.x
"#
"
),
15,
i64
@ -152,11 +152,11 @@ fn def_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { x: 15, y: 17, z: 19 }
rec.y
"#
"
),
17,
i64
@ -164,11 +164,11 @@ fn def_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { x: 15, y: 17, z: 19 }
rec.z
"#
"
),
19,
i64
@ -180,10 +180,10 @@ fn def_record() {
fn when_on_record() {
assert_evals_to!(
indoc!(
r#"
r"
when { x: 0x2 } is
{ x } -> x + 3
"#
"
),
5,
i64
@ -195,10 +195,10 @@ fn when_on_record() {
fn when_record_with_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when { x: 0x2, y: 1.23 } is
{ x: var } -> var + 3
"#
"
),
5,
i64
@ -210,11 +210,11 @@ fn when_record_with_guard_pattern() {
fn let_with_record_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
{ x } = { x: 0x2, y: 1.23 }
x
"#
"
),
2,
i64
@ -226,11 +226,11 @@ fn let_with_record_pattern() {
fn record_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when { x: 0x2, y: 1.23 } is
{ x: 0x4 } -> 5
{ x } -> x + 3
"#
"
),
5,
i64
@ -242,11 +242,11 @@ fn record_guard_pattern() {
fn twice_record_access() {
assert_evals_to!(
indoc!(
r#"
r"
x = {a: 0x2, b: 0x3 }
x.a + x.b
"#
"
),
5,
i64
@ -257,11 +257,11 @@ fn twice_record_access() {
fn empty_record() {
assert_evals_to!(
indoc!(
r#"
r"
v = {}
v
"#
"
),
(),
()
@ -272,9 +272,9 @@ fn empty_record() {
fn i64_record2_literal() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 3, y: 5 }
"#
"
),
(3, 5),
(i64, i64)
@ -286,9 +286,9 @@ fn i64_record2_literal() {
// fn i64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// { x: 3, y: 5, z: 17 }
// "#
// "
// ),
// (3, 5, 17),
// (i64, i64, i64)
@ -299,9 +299,9 @@ fn i64_record2_literal() {
fn f64_record2_literal() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 3.1f64, y: 5.1f64 }
"#
"
),
(3.1, 5.1),
(f64, f64)
@ -313,9 +313,9 @@ fn f64_record2_literal() {
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// "
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
@ -327,12 +327,12 @@ fn f64_record2_literal() {
// fn bool_record4_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// record : { a : Bool, b : Bool, c : Bool, d : Bool }
// record = { a: Bool.true, b: Bool.true, c : Bool.true, d : Bool }
// record
// "#
// "
// ),
// (true, false, false, true),
// (bool, bool, bool, bool)
@ -343,9 +343,9 @@ fn f64_record2_literal() {
fn i64_record1_literal() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 3 }
"#
"
),
3,
i64
@ -357,9 +357,9 @@ fn i64_record1_literal() {
// fn i64_record9_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// 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)
@ -371,9 +371,9 @@ fn i64_record1_literal() {
// fn f64_record3_literal() {
// assert_evals_to!(
// indoc!(
// r#"
// r"
// { x: 3.1, y: 5.1, z: 17.1 }
// "#
// "
// ),
// (3.1, 5.1, 17.1),
// (f64, f64, f64)
@ -384,12 +384,12 @@ fn i64_record1_literal() {
fn bool_literal() {
assert_evals_to!(
indoc!(
r#"
r"
x : Bool
x = Bool.true
x
"#
"
),
true,
bool
@ -401,12 +401,12 @@ fn bool_literal() {
fn return_record() {
assert_evals_to!(
indoc!(
r#"
r"
x = 4
y = 3
{ x, y }
"#
"
),
(4, 3),
(i64, i64)
@ -446,7 +446,7 @@ fn optional_field_when_use_default() {
fn optional_field_when_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
r"
f = \r ->
when r is
{ x: Blue, y ? 3 } -> y
@ -458,7 +458,7 @@ fn optional_field_when_use_default_nested() {
d = f { x: Red }
a * b * c * d
"#
"
),
3 * 5 * 7 * 11,
i64
@ -491,13 +491,13 @@ fn optional_field_destructure_module() {
fn optional_field_destructure_expr() {
assert_evals_to!(
indoc!(
r#"
r"
fn = \r ->
{ x ? 10, y } = r
x + y
fn { x: 4, y: 9 }
"#
"
),
13,
i64
@ -551,13 +551,13 @@ fn optional_field_let_no_use_default() {
fn optional_field_let_no_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
r"
f = \r ->
{ x ? 10, y } = r
x + y
f { y: 9, x: 4 }
"#
"
),
13,
i64
@ -569,12 +569,12 @@ fn optional_field_let_no_use_default_nested() {
fn optional_field_function_use_default() {
assert_evals_to!(
indoc!(
r#"
r"
f = \{ x ? 10, y } -> x + y
f { y: 9 }
"#
"
),
19,
i64
@ -605,12 +605,12 @@ fn optional_field_function_no_use_default() {
fn optional_field_function_no_use_default_nested() {
assert_evals_to!(
indoc!(
r#"
r"
f = \{ x ? 10, y } -> x + y
f { x: 4, y: 9 }
"#
"
),
13,
i64
@ -622,10 +622,10 @@ fn optional_field_function_no_use_default_nested() {
fn optional_field_singleton_record() {
assert_evals_to!(
indoc!(
r#"
r"
when { x : 4 } is
{ x ? 3 } -> x
"#
"
),
4,
i64
@ -637,10 +637,10 @@ fn optional_field_singleton_record() {
fn optional_field_empty_record() {
assert_evals_to!(
indoc!(
r#"
r"
when { } is
{ x ? 3 } -> x
"#
"
),
3,
i64
@ -652,9 +652,9 @@ fn optional_field_empty_record() {
fn return_record_2() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 3, y: 5 }
"#
"
),
[3, 5],
[i64; 2]
@ -666,9 +666,9 @@ fn return_record_2() {
fn return_record_3() {
assert_evals_to!(
indoc!(
r#"
r"
{ x: 3, y: 5, z: 4 }
"#
"
),
(3, 5, 4),
(i64, i64, i64)
@ -680,9 +680,9 @@ fn return_record_3() {
fn return_record_4() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 3, b: 5, c: 4, d: 2 }
"#
"
),
[3, 5, 4, 2],
[i64; 4]
@ -694,9 +694,9 @@ fn return_record_4() {
fn return_record_5() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 3, b: 5, c: 4, d: 2, e: 1 }
"#
"
),
[3, 5, 4, 2, 1],
[i64; 5]
@ -708,9 +708,9 @@ fn return_record_5() {
fn return_record_6() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 3, b: 5, c: 4, d: 2, e: 1, f: 7 }
"#
"
),
[3, 5, 4, 2, 1, 7],
[i64; 6]
@ -722,9 +722,9 @@ fn return_record_6() {
fn return_record_7() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 3, b: 5, c: 4, d: 2, e: 1, f: 7, g: 8 }
"#
"
),
[3, 5, 4, 2, 1, 7, 8],
[i64; 7]
@ -736,9 +736,9 @@ fn return_record_7() {
fn return_record_float_int() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 1.23f64, b: 0x1 }
"#
"
),
(1.23, 0x1),
(f64, i64)
@ -750,9 +750,9 @@ fn return_record_float_int() {
fn return_record_int_float() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 0x1, b: 1.23f64 }
"#
"
),
(0x1, 1.23),
(i64, f64)
@ -764,9 +764,9 @@ fn return_record_int_float() {
fn return_record_float_float() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 2.46f64, b: 1.23f64 }
"#
"
),
(2.46, 1.23),
(f64, f64)
@ -778,9 +778,9 @@ fn return_record_float_float() {
fn return_record_float_float_float() {
assert_evals_to!(
indoc!(
r#"
r"
{ a: 2.46f64, b: 1.23f64, c: 0.1f64 }
"#
"
),
(2.46, 1.23, 0.1),
(f64, f64, f64)
@ -792,9 +792,9 @@ fn return_record_float_float_float() {
fn return_nested_record() {
assert_evals_to!(
indoc!(
r#"
r"
{ flag: 0x0, payload: { a: 2.46f64, b: 1.23f64, c: 0.1f64 } }
"#
"
),
(0x0, (2.46, 1.23, 0.1)),
(i64, (f64, f64, f64))
@ -806,13 +806,13 @@ fn return_nested_record() {
fn nested_record_load() {
assert_evals_to!(
indoc!(
r#"
r"
x = { a : { b : 0x5 } }
y = x.a
y.b
"#
"
),
5,
i64
@ -844,9 +844,9 @@ fn accessor_multi_element_record() {
fn accessor_single_element_record() {
assert_evals_to!(
indoc!(
r#"
r"
.foo { foo: 4 }
"#
"
),
4,
i64
@ -858,11 +858,11 @@ fn accessor_single_element_record() {
fn update_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { foo: 42, bar: 2.46f64 }
{ rec & foo: rec.foo + 1 }
"#
"
),
(2.46, 43),
(f64, i64)
@ -874,11 +874,11 @@ fn update_record() {
fn update_single_element_record() {
assert_evals_to!(
indoc!(
r#"
r"
rec = { foo: 42}
{ rec & foo: rec.foo + 1 }
"#
"
),
43,
i64
@ -927,14 +927,14 @@ fn alignment_in_record() {
fn blue_and_present() {
assert_evals_to!(
indoc!(
r#"
r"
f = \r ->
when r is
{ x: Blue, y ? 3 } -> y
{ x: Red, y ? 5 } -> y
f { x: Blue, y: 7 }
"#
"
),
7,
i64
@ -946,14 +946,14 @@ fn blue_and_present() {
fn blue_and_absent() {
assert_evals_to!(
indoc!(
r#"
r"
f = \r ->
when r is
{ x: Blue, y ? 3 } -> y
{ x: Red, y ? 5 } -> y
f { x: Blue }
"#
"
),
3,
i64
@ -965,7 +965,7 @@ fn blue_and_absent() {
fn update_the_only_field() {
assert_evals_to!(
indoc!(
r#"
r"
Model : { foo : I64 }
model : Model
@ -977,7 +977,7 @@ fn update_the_only_field() {
newModel = { model & foo }
newModel.foo
"#
"
),
4,
i64
@ -990,7 +990,7 @@ fn update_the_only_field() {
fn both_have_unique_fields() {
assert_evals_to!(
indoc!(
r#"
r"
a = { x: 42, y: 43 }
b = { x: 42, z: 44 }
@ -998,7 +998,7 @@ fn both_have_unique_fields() {
f = \{ x: x1}, { x: x2 } -> x1 + x2
f a b
"#
"
),
84,
i64

View File

@ -17,12 +17,12 @@ use roc_std::{RocResult, RocStr};
fn with_default_ok() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Ok 12345
Result.withDefault result 0
"#
"
),
12345,
i64
@ -34,12 +34,12 @@ fn with_default_ok() {
fn with_default_err() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Err {}
Result.withDefault result 0
"#
"
),
0,
i64
@ -51,14 +51,14 @@ fn with_default_err() {
fn result_map() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Ok 2
result
|> Result.map (\x -> x + 1)
|> Result.withDefault 0
"#
"
),
3,
i64
@ -66,14 +66,14 @@ fn result_map() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Err {}
result
|> Result.map (\x -> x + 1)
|> Result.withDefault 0
"#
"
),
0,
i64
@ -85,14 +85,14 @@ fn result_map() {
fn result_map_err() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result {} I64
result = Err 2
when Result.mapErr result (\x -> x + 1) is
Err n -> n
Ok _ -> 0
"#
"
),
3,
i64
@ -100,14 +100,14 @@ fn result_map_err() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result {} I64
result = Ok {}
when Result.mapErr result (\x -> x + 1) is
Err n -> n
Ok _ -> 0
"#
"
),
0,
i64
@ -119,10 +119,10 @@ fn result_map_err() {
fn err_type_var() {
assert_evals_to!(
indoc!(
r#"
r"
Result.map (Ok 3) (\x -> x + 1)
|> Result.withDefault -1
"#
"
),
4,
i64
@ -134,13 +134,13 @@ fn err_type_var() {
fn err_type_var_annotation() {
assert_evals_to!(
indoc!(
r#"
r"
ok : Result I64 *
ok = Ok 3
Result.map ok (\x -> x + 1)
|> Result.withDefault -1
"#
"
),
4,
i64
@ -152,13 +152,13 @@ fn err_type_var_annotation() {
fn err_empty_tag_union() {
assert_evals_to!(
indoc!(
r#"
r"
ok : Result I64 []
ok = Ok 3
Result.map ok (\x -> x + 1)
|> Result.withDefault -1
"#
"
),
4,
i64
@ -170,12 +170,12 @@ fn err_empty_tag_union() {
fn is_ok() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Ok 2
Result.isOk result
"#
"
),
true,
bool
@ -183,12 +183,12 @@ fn is_ok() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Err {}
Result.isOk result
"#
"
),
false,
bool
@ -200,12 +200,12 @@ fn is_ok() {
fn is_err() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Ok 2
Result.isErr result
"#
"
),
false,
bool
@ -213,12 +213,12 @@ fn is_err() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Err {}
Result.isErr result
"#
"
),
true,
bool
@ -230,12 +230,12 @@ fn is_err() {
fn roc_result_ok_i64() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result I64 {}
result = Ok 42
result
"#
"
),
RocResult::ok(42),
RocResult<i64, ()>
@ -250,12 +250,12 @@ fn roc_result_ok_f64() {
assert_evals_to!(
indoc!(
r#"
r"
result : Result F64 {}
result = Ok 42.0
result
"#
"
),
RocResult::ok(42.0),
RocResult<f64, ()>

View File

@ -20,9 +20,9 @@ use roc_std::RocList;
fn empty_len() {
assert_evals_to!(
indoc!(
r#"
r"
Set.len (Set.empty {})
"#
"
),
0,
usize
@ -34,9 +34,9 @@ fn empty_len() {
fn single_len() {
assert_evals_to!(
indoc!(
r#"
r"
Set.len (Set.single 42)
"#
"
),
1,
usize
@ -48,9 +48,9 @@ fn single_len() {
fn single_to_list() {
assert_evals_to!(
indoc!(
r#"
r"
Set.toList (Set.single 42)
"#
"
),
RocList::from_slice(&[42]),
RocList<i64>
@ -58,9 +58,9 @@ fn single_to_list() {
assert_evals_to!(
indoc!(
r#"
r"
Set.toList (Set.single 1)
"#
"
),
RocList::from_slice(&[1]),
RocList<i64>
@ -72,13 +72,13 @@ fn single_to_list() {
fn insert() {
assert_evals_to!(
indoc!(
r#"
r"
Set.empty {}
|> Set.insert 0
|> Set.insert 1
|> Set.insert 2
|> Set.toList
"#
"
),
RocList::from_slice(&[0, 1, 2]),
RocList<i64>
@ -90,14 +90,14 @@ fn insert() {
fn remove() {
assert_evals_to!(
indoc!(
r#"
r"
Set.empty {}
|> Set.insert 0
|> Set.insert 1
|> Set.remove 1
|> Set.remove 2
|> Set.toList
"#
"
),
RocList::from_slice(&[0]),
RocList<i64>
@ -109,7 +109,7 @@ fn remove() {
fn union() {
assert_evals_to!(
indoc!(
r#"
r"
set1 : Set.Set I64
set1 = Set.fromList [1,2]
@ -118,7 +118,7 @@ fn union() {
Set.union set1 set2
|> Set.toList
"#
"
),
RocList::from_slice(&[1, 3, 4, 2]),
RocList<i64>
@ -130,7 +130,7 @@ fn union() {
fn difference() {
assert_evals_to!(
indoc!(
r#"
r"
set1 : Set.Set I64
set1 = Set.fromList [1,2]
@ -139,7 +139,7 @@ fn difference() {
Set.difference set1 set2
|> Set.toList
"#
"
),
RocList::from_slice(&[2]),
RocList<i64>
@ -151,7 +151,7 @@ fn difference() {
fn intersection() {
assert_evals_to!(
indoc!(
r#"
r"
set1 : Set.Set I64
set1 = Set.fromList [1,2]
@ -160,7 +160,7 @@ fn intersection() {
Set.intersection set1 set2
|> Set.toList
"#
"
),
RocList::from_slice(&[1]),
RocList<i64>
@ -172,9 +172,9 @@ fn intersection() {
fn walk_sum() {
assert_evals_to!(
indoc!(
r#"
r"
Set.walk (Set.fromList [1,2,3]) 0 (\x, y -> x + y)
"#
"
),
6,
i64
@ -186,9 +186,9 @@ fn walk_sum() {
fn contains() {
assert_evals_to!(
indoc!(
r#"
r"
Set.contains (Set.fromList [1,3,4]) 4
"#
"
),
true,
bool
@ -196,9 +196,9 @@ fn contains() {
assert_evals_to!(
indoc!(
r#"
r"
Set.contains (Set.fromList [1,3,4]) 2
"#
"
),
false,
bool
@ -210,11 +210,11 @@ fn contains() {
fn from_list() {
assert_evals_to!(
indoc!(
r#"
r"
[1,2,2,3,1,4]
|> Set.fromList
|> Set.toList
"#
"
),
RocList::from_slice(&[1, 2, 3, 4]),
RocList<i64>
@ -222,14 +222,14 @@ fn from_list() {
assert_evals_to!(
indoc!(
r#"
r"
empty : List I64
empty = []
empty
|> Set.fromList
|> Set.toList
"#
"
),
RocList::<i64>::default(),
RocList<i64>
@ -242,11 +242,11 @@ fn from_list() {
fn from_list_void() {
assert_evals_to!(
indoc!(
r#"
r"
[]
|> Set.fromList
|> Set.toList
"#
"
),
RocList::<i64>::default(),
RocList<i64>
@ -258,9 +258,9 @@ fn from_list_void() {
fn to_list_empty() {
assert_evals_to!(
indoc!(
r#"
r"
Set.toList (Set.empty {})
"#
"
),
RocList::<std::convert::Infallible>::default(),
RocList<std::convert::Infallible>

View File

@ -39,14 +39,14 @@ fn width_and_alignment_u8_u8() {
fn applied_tag_nothing() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Just a, Nothing]
x : Maybe I64
x = Nothing
x
"#
"
),
1,
(i64, u8),
@ -59,14 +59,14 @@ fn applied_tag_nothing() {
fn applied_tag_just() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Just a, Nothing]
y : Maybe I64
y = Just 0x4
y
"#
"
),
(0x4, 0),
(i64, u8)
@ -78,7 +78,7 @@ fn applied_tag_just() {
fn applied_tag_just_enum() {
assert_evals_to!(
indoc!(
r#"
r"
Fruit : [Orange, Apple, Banana]
Maybe a : [Just a, Nothing]
@ -89,7 +89,7 @@ fn applied_tag_just_enum() {
y = Just orange
y
"#
"
),
(2, 0),
(u8, u8)
@ -101,12 +101,12 @@ fn applied_tag_just_enum() {
fn true_is_true() {
assert_evals_to!(
indoc!(
r#"
r"
bool : Bool
bool = Bool.true
bool
"#
"
),
true,
bool
@ -118,12 +118,12 @@ fn true_is_true() {
fn false_is_false() {
assert_evals_to!(
indoc!(
r#"
r"
bool : Bool
bool = Bool.false
bool
"#
"
),
false,
bool
@ -135,7 +135,7 @@ fn false_is_false() {
fn basic_enum() {
assert_evals_to!(
indoc!(
r#"
r"
Fruit : [Apple, Orange, Banana]
apple : Fruit
@ -145,7 +145,7 @@ fn basic_enum() {
orange = Orange
apple == orange
"#
"
),
false,
bool
@ -157,7 +157,7 @@ fn basic_enum() {
fn even_odd() {
assert_evals_to!(
indoc!(
r#"
r"
even = \n ->
when n is
0 -> Bool.true
@ -171,7 +171,7 @@ fn even_odd() {
_ -> even (n - 1)
odd 5 && even 42
"#
"
),
true,
bool
@ -183,9 +183,9 @@ fn even_odd() {
fn gen_literal_true() {
assert_evals_to!(
indoc!(
r#"
r"
if Bool.true then -1 else 1
"#
"
),
-1,
i64
@ -197,9 +197,9 @@ fn gen_literal_true() {
fn gen_if_float() {
assert_evals_to!(
indoc!(
r#"
r"
if Bool.true then -1.0 else 1.0f64
"#
"
),
-1.0,
f64
@ -210,14 +210,14 @@ fn gen_if_float() {
fn when_on_nothing() {
assert_evals_to!(
indoc!(
r#"
r"
x : [Nothing, Just I64]
x = Nothing
when x is
Nothing -> 0x2
Just _ -> 0x1
"#
"
),
2,
i64
@ -229,14 +229,14 @@ fn when_on_nothing() {
fn when_on_just() {
assert_evals_to!(
indoc!(
r#"
r"
x : [Nothing, Just I64]
x = Just 41
when x is
Just v -> v + 0x1
Nothing -> 0x1
"#
"
),
42,
i64
@ -248,14 +248,14 @@ fn when_on_just() {
fn when_on_result() {
assert_evals_to!(
indoc!(
r#"
r"
x : Result I64 I64
x = Err 41
when x is
Err v -> v + 1
Ok _ -> 1
"#
"
),
42,
i64
@ -267,7 +267,7 @@ fn when_on_result() {
fn when_on_these() {
assert_evals_to!(
indoc!(
r#"
r"
These a b : [This a, That b, These a b]
x : These I64 I64
@ -277,7 +277,7 @@ fn when_on_these() {
These a b -> a + b
That v -> v
This v -> v
"#
"
),
5,
i64
@ -290,11 +290,11 @@ fn match_on_two_values() {
// this will produce a Chain internally
assert_evals_to!(
indoc!(
r#"
r"
when Pair 2 3 is
Pair 4 3 -> 9
Pair a b -> a + b
"#
"
),
5,
i64
@ -306,12 +306,12 @@ fn match_on_two_values() {
fn pair_with_underscore() {
assert_evals_to!(
indoc!(
r#"
r"
when Pair 2 3 is
Pair 4 _ -> 1
Pair 3 _ -> 2
Pair a b -> a + b
"#
"
),
5,
i64
@ -324,7 +324,7 @@ fn result_with_underscore() {
// This test revealed an issue with hashing Test values
assert_evals_to!(
indoc!(
r#"
r"
x : Result I64 I64
x = Ok 2
@ -332,7 +332,7 @@ fn result_with_underscore() {
Ok 3 -> 1
Ok _ -> 2
Err _ -> 3
"#
"
),
2,
i64
@ -369,7 +369,7 @@ fn maybe_is_just_not_nested() {
fn maybe_is_just_nested() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Just a, Nothing]
isJust : Maybe a -> Bool
@ -379,7 +379,7 @@ fn maybe_is_just_nested() {
Just _ -> Bool.true
isJust (Just 42)
"#
"
),
true,
bool
@ -391,7 +391,7 @@ fn maybe_is_just_nested() {
fn nested_pattern_match() {
assert_evals_to!(
indoc!(
r#"
r"
Maybe a : [Nothing, Just a]
x : Maybe (Maybe I64)
@ -400,7 +400,7 @@ fn nested_pattern_match() {
when x is
Just (Just v) -> v + 0x1
_ -> 0x1
"#
"
),
42,
i64
@ -428,11 +428,11 @@ fn if_guard_vanilla() {
fn when_on_single_value_tag() {
assert_evals_to!(
indoc!(
r#"
r"
when Identity 0 is
Identity 0 -> 6
Identity s -> s
"#
"
),
6,
i64
@ -444,7 +444,7 @@ fn when_on_single_value_tag() {
fn if_guard_multiple() {
assert_evals_to!(
indoc!(
r#"
r"
f = \n ->
when Identity n 0 is
Identity x _ if x == 0 -> x + 0
@ -453,7 +453,7 @@ fn if_guard_multiple() {
Identity x _ -> x - x
{ a: f 0, b: f 1, c: f 2, d: f 4 }
"#
"
),
[0, 1, 2, 0],
[i64; 4]
@ -465,13 +465,13 @@ fn if_guard_multiple() {
fn if_guard_constructor_switch() {
assert_evals_to!(
indoc!(
r#"
r"
when Identity 32 0 is
Identity 41 _ -> 0
Identity s 0 if s == 32 -> 3
# Identity s 0 -> s
Identity z _ -> z
"#
"
),
3,
i64
@ -509,12 +509,12 @@ fn if_guard_constructor_switch() {
fn if_guard_constructor_chain() {
assert_evals_to!(
indoc!(
r#"
r"
when Identity 43 0 is
Identity 42 _ if 3 == 3 -> 43
# Identity 42 _ -> 1
Identity z _ -> z
"#
"
),
43,
i64
@ -526,14 +526,14 @@ fn if_guard_constructor_chain() {
fn if_guard_pattern_false() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
when 2 is
2 if Bool.false -> 0
_ -> 42
wrapper {}
"#
"
),
42,
i64
@ -545,14 +545,14 @@ fn if_guard_pattern_false() {
fn if_guard_switch() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
when 2 is
2 | 3 if Bool.false -> 0
_ -> 42
wrapper {}
"#
"
),
42,
i64
@ -564,14 +564,14 @@ fn if_guard_switch() {
fn if_guard_pattern_true() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
when 2 is
2 if Bool.true -> 42
_ -> 0
wrapper {}
"#
"
),
42,
i64
@ -583,14 +583,14 @@ fn if_guard_pattern_true() {
fn if_guard_exhaustiveness() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
when 2 is
_ if Bool.false -> 0
_ -> 42
wrapper {}
"#
"
),
42,
i64
@ -602,7 +602,7 @@ fn if_guard_exhaustiveness() {
fn when_on_enum() {
assert_evals_to!(
indoc!(
r#"
r"
Fruit : [Apple, Orange, Banana]
apple : Fruit
@ -612,7 +612,7 @@ fn when_on_enum() {
Apple -> 1
Banana -> 2
Orange -> 3
"#
"
),
1,
i64
@ -624,14 +624,14 @@ fn when_on_enum() {
fn pattern_matching_unit() {
assert_evals_to!(
indoc!(
r#"
r"
Unit : [Unit]
f : Unit -> I64
f = \Unit -> 42
f Unit
"#
"
),
42,
i64
@ -639,7 +639,7 @@ fn pattern_matching_unit() {
assert_evals_to!(
indoc!(
r#"
r"
Unit : [Unit]
x : Unit
@ -647,7 +647,7 @@ fn pattern_matching_unit() {
when x is
Unit -> 42
"#
"
),
42,
i64
@ -655,12 +655,12 @@ fn pattern_matching_unit() {
assert_evals_to!(
indoc!(
r#"
r"
f : {} -> I64
f = \{} -> 42
f {}
"#
"
),
42,
i64
@ -668,10 +668,10 @@ fn pattern_matching_unit() {
assert_evals_to!(
indoc!(
r#"
r"
when {} is
{} -> 42
"#
"
),
42,
i64
@ -683,12 +683,12 @@ fn pattern_matching_unit() {
fn one_element_tag() {
assert_evals_to!(
indoc!(
r#"
r"
x : [Pair I64]
x = Pair 2
x
"#
"
),
2,
i64
@ -721,14 +721,14 @@ fn nested_tag_union() {
fn unit_type() {
assert_evals_to!(
indoc!(
r#"
r"
Unit : [Unit]
v : Unit
v = Unit
v
"#
"
),
(),
()
@ -740,12 +740,12 @@ fn unit_type() {
fn join_point_if() {
assert_evals_to!(
indoc!(
r#"
r"
x =
if Bool.true then 1 else 2
x
"#
"
),
1,
i64
@ -757,7 +757,7 @@ fn join_point_if() {
fn join_point_when() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
x : [Red, White, Blue]
x = Blue
@ -771,7 +771,7 @@ fn join_point_when() {
y
wrapper {}
"#
"
),
3.1,
f64
@ -783,7 +783,7 @@ fn join_point_when() {
fn join_point_with_cond_expr() {
assert_evals_to!(
indoc!(
r#"
r"
wrapper = \{} ->
y =
when 1 + 2 is
@ -794,7 +794,7 @@ fn join_point_with_cond_expr() {
y
wrapper {}
"#
"
),
3,
i64
@ -802,7 +802,7 @@ fn join_point_with_cond_expr() {
assert_evals_to!(
indoc!(
r#"
r"
y =
if 1 + 2 > 0 then
3
@ -810,7 +810,7 @@ fn join_point_with_cond_expr() {
0
y
"#
"
),
3,
i64
@ -1135,12 +1135,12 @@ fn applied_tag_function_pair() {
fn tag_must_be_its_own_type() {
assert_evals_to!(
indoc!(
r#"
r"
z : [A, B, C]
z = Z
z
"#
"
),
1,
i64
@ -1171,12 +1171,12 @@ fn recursive_tag_union_into_flat_tag_union() {
fn monomorphized_tag() {
assert_evals_to!(
indoc!(
r#"
r"
b = \{} -> Bar
f : [Foo, Bar], [Bar, Baz] -> U8
f = \_, _ -> 18
f (b {}) (b {})
"#
"
),
18,
u8
@ -1391,7 +1391,7 @@ fn issue_2445() {
fn issue_2458() {
assert_evals_to!(
indoc!(
r#"
r"
Foo a : [Blah (Bar a), Nothing {}]
Bar a : Foo a
@ -1401,7 +1401,7 @@ fn issue_2458() {
when v is
Blah (Blah (Nothing {})) -> 15
_ -> 25
"#
"
),
15,
u8
@ -1471,11 +1471,11 @@ fn issue_1162() {
fn polymorphic_tag() {
assert_evals_to!(
indoc!(
r#"
r"
x : [Y U8]
x = Y 3
x
"#
"
),
3, // Y is a newtype, it gets unwrapped
u8
@ -1487,11 +1487,11 @@ fn polymorphic_tag() {
fn issue_2725_alias_polymorphic_lambda() {
assert_evals_to!(
indoc!(
r#"
r"
wrap = \value -> Tag value
wrapIt = wrap
wrapIt 42
"#
"
),
42, // Tag is a newtype, it gets unwrapped
i64
@ -1717,7 +1717,7 @@ fn instantiate_annotated_as_recursive_alias_multiple_polymorphic_expr() {
fn issue_3560_nested_tag_constructor_is_newtype() {
assert_evals_to!(
indoc!(
r#"
r"
f : _ -> u8
f = \t ->
when t is
@ -1725,7 +1725,7 @@ fn issue_3560_nested_tag_constructor_is_newtype() {
Wrapper (AlternatePayload it) -> it
{a: f (Wrapper (Payload 15u8)), b: f(Wrapper (AlternatePayload 31u8))}
"#
"
),
(15, 31),
(u8, u8)
@ -1737,7 +1737,7 @@ fn issue_3560_nested_tag_constructor_is_newtype() {
fn issue_3560_nested_tag_constructor_is_record_newtype() {
assert_evals_to!(
indoc!(
r#"
r"
f : _ -> u8
f = \t ->
when t is
@ -1745,7 +1745,7 @@ fn issue_3560_nested_tag_constructor_is_record_newtype() {
{wrapper: (AlternatePayload it)} -> it
{a: f {wrapper: (Payload 15u8)}, b: f {wrapper: (AlternatePayload 31u8)}}
"#
"
),
(15, 31),
(u8, u8)
@ -1791,7 +1791,7 @@ fn alignment_i128() {
fn error_type_in_tag_union_payload() {
assert_evals_to!(
indoc!(
r#"
r"
f : ([] -> Bool) -> Bool
f = \fun ->
if Bool.true then
@ -1800,7 +1800,7 @@ fn error_type_in_tag_union_payload() {
Bool.false
f (\x -> x)
"#
"
),
0,
u8,
@ -1864,7 +1864,7 @@ fn issue_3653_recursion_pointer_in_naked_opaque_localized() {
fn issue_2165_recursive_tag_destructure() {
assert_evals_to!(
indoc!(
r#"
r"
SomeTag : [ Ctor { rec : List SomeTag } ]
x : SomeTag
@ -1872,7 +1872,7 @@ fn issue_2165_recursive_tag_destructure() {
when x is
Ctor { rec } -> Num.toStr (List.len rec)
"#
"
),
RocStr::from("0"),
RocStr
@ -2183,7 +2183,7 @@ fn issue_5162_recast_nested_nullable_unwrapped_layout() {
with_larger_debug_stack(|| {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
Concept : [
@ -2197,7 +2197,7 @@ fn issue_5162_recast_nested_nullable_unwrapped_layout() {
main =
when Dict.single bottom 0 is
_ -> Bool.true
"###
"#
),
true,
bool
@ -2210,7 +2210,7 @@ fn issue_5162_recast_nested_nullable_unwrapped_layout() {
fn nullable_wrapped_eq_issue_5434() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
Value : [
@ -2229,7 +2229,7 @@ fn nullable_wrapped_eq_issue_5434() {
Bool.true
else
Bool.false
"###
"#
),
false,
bool
@ -2241,7 +2241,7 @@ fn nullable_wrapped_eq_issue_5434() {
fn recursive_tag_id_in_allocation_basic() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
Value : [
@ -2270,7 +2270,7 @@ fn recursive_tag_id_in_allocation_basic() {
G _ -> "G"
H _ -> "H"
I _ -> "I"
"###
"#
),
RocStr::from("H"),
RocStr
@ -2282,7 +2282,7 @@ fn recursive_tag_id_in_allocation_basic() {
fn recursive_tag_id_in_allocation_eq() {
assert_evals_to!(
indoc!(
r###"
r#"
app "test" provides [main] to "./platform"
Value : [
@ -2304,7 +2304,7 @@ fn recursive_tag_id_in_allocation_eq() {
y = H 42
main = (x == x) && (x != y) && (y == y)
"###
"#
),
true,
bool

View File

@ -18,9 +18,9 @@ use roc_std::RocStr;
fn basic_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
( 15, 17, 19 ).0
"#
"
),
15,
i64
@ -28,9 +28,9 @@ fn basic_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
( 15, 17, 19 ).1
"#
"
),
17,
i64
@ -38,9 +38,9 @@ fn basic_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
( 15, 17, 19 ).2
"#
"
),
19,
i64
@ -52,11 +52,11 @@ fn basic_tuple() {
fn f64_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
tup = (17.2f64, 15.1f64, 19.3f64)
tup.0
"#
"
),
17.2,
f64
@ -64,11 +64,11 @@ fn f64_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
tup = (17.2f64, 15.1f64, 19.3f64)
tup.1
"#
"
),
15.1,
f64
@ -76,11 +76,11 @@ fn f64_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
tup = (17.2f64, 15.1f64, 19.3f64)
tup.2
"#
"
),
19.3,
f64
@ -104,11 +104,11 @@ fn fn_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
rec = (15, 17, 19)
rec.2 + rec.0
"#
"
),
34,
i64
@ -120,11 +120,11 @@ fn fn_tuple() {
fn int_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
rec = (15, 17, 19)
rec.0
"#
"
),
15,
i64
@ -132,11 +132,11 @@ fn int_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
rec = (15, 17, 19)
rec.1
"#
"
),
17,
i64
@ -144,11 +144,11 @@ fn int_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
rec = (15, 17, 19)
rec.2
"#
"
),
19,
i64
@ -160,10 +160,10 @@ fn int_tuple() {
fn when_on_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
when (0x2, 0x3) is
(x, y) -> x + y
"#
"
),
5,
i64
@ -175,10 +175,10 @@ fn when_on_tuple() {
fn when_tuple_with_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when (0x2, 1.23) is
(var, _) -> var + 3
"#
"
),
5,
i64
@ -190,11 +190,11 @@ fn when_tuple_with_guard_pattern() {
fn let_with_tuple_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
(x, _ ) = (0x2, 1.23)
x
"#
"
),
2,
i64
@ -202,11 +202,11 @@ fn let_with_tuple_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
(_, y) = (0x2, 0x3)
y
"#
"
),
3,
i64
@ -218,11 +218,11 @@ fn let_with_tuple_pattern() {
fn tuple_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when (0x2, 1.23) is
(0x4, _) -> 5
(x, _) -> x + 4
"#
"
),
6,
i64
@ -230,11 +230,11 @@ fn tuple_guard_pattern() {
assert_evals_to!(
indoc!(
r#"
r"
when (0x2, 0x3) is
(_, 0x4) -> 5
(_, x) -> x + 4
"#
"
),
7,
i64
@ -246,11 +246,11 @@ fn tuple_guard_pattern() {
fn twice_tuple_access() {
assert_evals_to!(
indoc!(
r#"
r"
x = (0x2, 0x3)
x.0 + x.1
"#
"
),
5,
i64
@ -262,9 +262,9 @@ fn twice_tuple_access() {
fn i64_tuple2_literal() {
assert_evals_to!(
indoc!(
r#"
r"
(3, 5)
"#
"
),
(3, 5),
(i64, i64)
@ -276,9 +276,9 @@ fn i64_tuple2_literal() {
fn i64_tuple3_literal() {
assert_evals_to!(
indoc!(
r#"
r"
(3, 5, 17)
"#
"
),
(3, 5, 17),
(i64, i64, i64)
@ -290,9 +290,9 @@ fn i64_tuple3_literal() {
fn f64_tuple2_literal() {
assert_evals_to!(
indoc!(
r#"
r"
(3.1f64, 5.1f64)
"#
"
),
(3.1, 5.1),
(f64, f64)
@ -304,12 +304,12 @@ fn f64_tuple2_literal() {
fn bool_tuple4_literal() {
assert_evals_to!(
indoc!(
r#"
r"
tuple : (Bool, Bool, Bool, Bool)
tuple = (Bool.true, Bool.false, Bool.false, Bool.true)
tuple
"#
"
),
(true, false, false, true),
(bool, bool, bool, bool)
@ -323,9 +323,9 @@ fn bool_tuple4_literal() {
fn i64_tuple9_literal() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 17, 1, 9, 12, 13, 14, 15 )
"#
"
),
[3, 5, 17, 1, 9, 12, 13, 14, 15],
[i64; 9]
@ -337,12 +337,12 @@ fn i64_tuple9_literal() {
fn return_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
x = 4
y = 3
(x, y)
"#
"
),
(4, 3),
(i64, i64)
@ -354,9 +354,9 @@ fn return_tuple() {
fn return_tuple_2() {
assert_evals_to!(
indoc!(
r#"
r"
(3, 5)
"#
"
),
[3, 5],
[i64; 2]
@ -368,9 +368,9 @@ fn return_tuple_2() {
fn return_tuple_3() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 4 )
"#
"
),
(3, 5, 4),
(i64, i64, i64)
@ -382,9 +382,9 @@ fn return_tuple_3() {
fn return_tuple_4() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 4, 2 )
"#
"
),
[3, 5, 4, 2],
[i64; 4]
@ -398,9 +398,9 @@ fn return_tuple_4() {
fn return_tuple_5() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 4, 2, 1 )
"#
"
),
[3, 5, 4, 2, 1],
[i64; 5]
@ -414,9 +414,9 @@ fn return_tuple_5() {
fn return_tuple_6() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 4, 2, 1, 7 )
"#
"
),
[3, 5, 4, 2, 1, 7],
[i64; 6]
@ -430,9 +430,9 @@ fn return_tuple_6() {
fn return_tuple_7() {
assert_evals_to!(
indoc!(
r#"
r"
( 3, 5, 4, 2, 1, 7, 8 )
"#
"
),
[3, 5, 4, 2, 1, 7, 8],
[i64; 7]
@ -444,9 +444,9 @@ fn return_tuple_7() {
fn return_tuple_float_int() {
assert_evals_to!(
indoc!(
r#"
r"
(1.23f64, 0x1)
"#
"
),
(1.23, 0x1),
(f64, i64)
@ -458,9 +458,9 @@ fn return_tuple_float_int() {
fn return_tuple_int_float() {
assert_evals_to!(
indoc!(
r#"
r"
( 0x1, 1.23f64 )
"#
"
),
(0x1, 1.23),
(i64, f64)
@ -472,9 +472,9 @@ fn return_tuple_int_float() {
fn return_tuple_float_float() {
assert_evals_to!(
indoc!(
r#"
r"
( 2.46f64, 1.23f64 )
"#
"
),
(2.46, 1.23),
(f64, f64)
@ -486,9 +486,9 @@ fn return_tuple_float_float() {
fn return_tuple_float_float_float() {
assert_evals_to!(
indoc!(
r#"
r"
( 2.46f64, 1.23f64, 0.1f64 )
"#
"
),
(2.46, 1.23, 0.1),
(f64, f64, f64)
@ -500,9 +500,9 @@ fn return_tuple_float_float_float() {
fn return_nested_tuple() {
assert_evals_to!(
indoc!(
r#"
r"
(0x0, (2.46f64, 1.23f64, 0.1f64))
"#
"
),
(0x0, (2.46, 1.23, 0.1)),
(i64, (f64, f64, f64))
@ -514,13 +514,13 @@ fn return_nested_tuple() {
fn nested_tuple_load() {
assert_evals_to!(
indoc!(
r#"
r"
x = (0, (0x2, 0x5, 0x6))
y = x.1
y.2
"#
"
),
6,
i64
@ -572,7 +572,7 @@ fn alignment_in_tuple() {
fn tuple_length_polymorphism() {
assert_evals_to!(
indoc!(
r#"
r"
a = (42, 43)
b = (1, 2, 44)
@ -580,7 +580,7 @@ fn tuple_length_polymorphism() {
f = \(x1, x2), (x3, x4) -> x1 + x2 + x3 + x4
f a b
"#
"
),
88,
i64

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -238,12 +238,12 @@ mod test {
"#
),
indoc!(
r#"
r"
This expectation failed:
5 expect 1 == 2
^^^^^^^^^^^^^
"#
"
),
);
}
@ -265,7 +265,7 @@ mod test {
"#
),
indoc!(
r#"
r"
This expectation failed:
5> expect
@ -281,7 +281,7 @@ mod test {
b : Num *
b = 2
"#
"
),
);
}
@ -380,7 +380,7 @@ mod test {
"#
),
indoc!(
r#"
r"
This expectation failed:
5> expect
@ -397,7 +397,7 @@ mod test {
expected : Result I64 [OutOfBounds]
expected = Ok 42
"#
"
),
);
}
@ -463,7 +463,7 @@ mod test {
"#
),
indoc!(
r#"
r"
This expectation failed:
5> expect
@ -485,7 +485,7 @@ mod test {
y : U8,
}
vec2 = { x: 4, y: 8 }
"#
"
),
);
}
@ -965,22 +965,22 @@ mod test {
fn issue_i4389() {
run_expect_test(
indoc!(
r#"
r"
interface Test exposes [] imports []
expect
totalCount = \{} -> 1u8
totalCount {} == 96u8
"#
"
),
indoc!(
r#"
r"
This expectation failed:
3> expect
4> totalCount = \{} -> 1u8
5> totalCount {} == 96u8
"#
"
),
);
}
@ -989,7 +989,7 @@ mod test {
fn adjacent_lists() {
run_expect_test(
indoc!(
r#"
r"
interface Test exposes [] imports []
expect
@ -1007,10 +1007,10 @@ mod test {
x: [115, 116, 117],
}
actual == expected
"#
"
),
indoc!(
r#"
r"
This expectation failed:
3> expect
@ -1044,7 +1044,7 @@ mod test {
x : List (Int Unsigned8),
}
expected = { body: [42, 43, 44], headers: [15, 16, 17], x: [115, 116, 117] }
"#
"
),
);
}
@ -1113,7 +1113,7 @@ mod test {
fn tag_payloads_of_different_size() {
run_expect_test(
indoc!(
r#"
r"
interface Test exposes [] imports []
actual : [Leftover (List U8), TooShort]
@ -1124,10 +1124,10 @@ mod test {
expected = TooShort
actual == expected
"#
"
),
indoc!(
r#"
r"
This expectation failed:
6> expect
@ -1143,7 +1143,7 @@ mod test {
TooShort,
]
expected = TooShort
"#
"
),
);
}
@ -1220,7 +1220,7 @@ mod test {
fn match_on_opaque_number_type() {
run_expect_test(
indoc!(
r#"
r"
interface Test exposes [] imports []
hexToByte : U8, U8 -> U8
@ -1231,10 +1231,10 @@ mod test {
actual = hexToByte 7 4
expected = 't'
actual == expected
"#
"
),
indoc!(
r#"
r"
This expectation failed:
7> expect
@ -1249,7 +1249,7 @@ mod test {
expected : Int Unsigned8
expected = 116
"#
"
),
);
}

View File

@ -124,11 +124,11 @@ fn bool_basic_equality() {
fn bool_true() {
expect_success(
indoc!(
r#"
r"
Bool.true
"#
"
),
r#"Bool.true : Bool"#,
r"Bool.true : Bool",
);
}
@ -136,11 +136,11 @@ fn bool_true() {
fn bool_false() {
expect_success(
indoc!(
r#"
r"
Bool.false
"#
"
),
r#"Bool.false : Bool"#,
r"Bool.false : Bool",
);
}
@ -315,24 +315,24 @@ fn nested_string_list() {
#[test]
fn nested_num_list() {
expect_success(
r#"[[[4, 3, 2], [1, 0]], [[]], []]"#,
r#"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Num *)))"#,
r"[[[4, 3, 2], [1, 0]], [[]], []]",
r"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Num *)))",
);
}
#[test]
fn nested_int_list() {
expect_success(
r#"[[[4, 3, 2], [1, 0x0]], [[]], []]"#,
r#"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Int *)))"#,
r"[[[4, 3, 2], [1, 0x0]], [[]], []]",
r"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Int *)))",
);
}
#[test]
fn nested_float_list() {
expect_success(
r#"[[[4, 3, 2], [1, 0.0]], [[]], []]"#,
r#"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Frac *)))"#,
r"[[[4, 3, 2], [1, 0.0]], [[]], []]",
r"[[[4, 3, 2], [1, 0]], [[]], []] : List (List (List (Frac *)))",
);
}
@ -641,7 +641,7 @@ fn too_few_args() {
expect_failure(
"Num.add 2",
indoc!(
r#"
r"
TOO FEW ARGS
The add function expects 2 arguments, but it got only 1:
@ -651,7 +651,7 @@ fn too_few_args() {
Roc does not allow functions to be partially applied. Use a closure to
make partial application explicit.
"#
"
),
);
}
@ -970,7 +970,7 @@ fn large_nullable_wrapped_tag_union() {
fn issue_2300() {
expect_success(
r#"\Email str -> str == """#,
r#"<function> : [Email Str] -> Bool"#,
r"<function> : [Email Str] -> Bool",
)
}
@ -978,8 +978,8 @@ fn issue_2300() {
#[test]
fn function_in_list() {
expect_success(
r#"[\x -> x + 1, \s -> s * 2]"#,
r#"[<function>, <function>] : List (Num a -> Num a)"#,
r"[\x -> x + 1, \s -> s * 2]",
r"[<function>, <function>] : List (Num a -> Num a)",
)
}
@ -987,8 +987,8 @@ fn function_in_list() {
#[test]
fn function_in_record() {
expect_success(
r#"{ n: 1, adder: \x -> x + 1 }"#,
r#"{ adder: <function>, n: 1 } : { adder : Num a -> Num a, n : Num * }"#,
r"{ n: 1, adder: \x -> x + 1 }",
r"{ adder: <function>, n: 1 } : { adder : Num a -> Num a, n : Num * }",
)
}
@ -996,8 +996,8 @@ fn function_in_record() {
#[test]
fn function_in_unwrapped_record() {
expect_success(
r#"{ adder: \x -> x + 1 }"#,
r#"{ adder: <function> } : { adder : Num a -> Num a }"#,
r"{ adder: \x -> x + 1 }",
r"{ adder: <function> } : { adder : Num a -> Num a }",
)
}
@ -1005,16 +1005,16 @@ fn function_in_unwrapped_record() {
#[test]
fn function_in_tag() {
expect_success(
r#"Adder (\x -> x + 1)"#,
r#"Adder <function> : [Adder (Num a -> Num a)]"#,
r"Adder (\x -> x + 1)",
r"Adder <function> : [Adder (Num a -> Num a)]",
)
}
#[test]
fn newtype_of_record_of_tag_of_record_of_tag() {
expect_success(
r#"A {b: C {d: 1}}"#,
r#"A { b: C { d: 1 } } : [A { b : [C { d : Num * }] }]"#,
r"A {b: C {d: 1}}",
r"A { b: C { d: 1 } } : [A { b : [C { d : Num * }] }]",
)
}
@ -1022,11 +1022,11 @@ fn newtype_of_record_of_tag_of_record_of_tag() {
fn print_u8s() {
expect_success(
indoc!(
r#"
r"
x : U8
x = 129
x
"#
"
),
"129 : U8",
)
@ -1062,17 +1062,17 @@ fn parse_problem() {
fn issue_2343_complete_mono_with_shadowed_vars() {
expect_failure(
indoc!(
r#"
r"
b = False
f = \b ->
when b is
True -> 5
False -> 15
f b
"#
"
),
indoc!(
r#"
r"
DUPLICATE NAME
The b name is first defined here:
@ -1087,7 +1087,7 @@ fn issue_2343_complete_mono_with_shadowed_vars() {
Since these variables have the same name, it's easy to use the wrong
one by accident. Give one of them a new name.
"#
"
),
);
}
@ -1126,12 +1126,12 @@ fn tag_with_type_behind_alias() {
fn issue_2588_record_with_function_and_nonfunction() {
expect_success(
indoc!(
r#"
r"
x = 1
f = \n -> n * 2
{ y: f x, f }"#
{ y: f x, f }"
),
r#"{ f: <function>, y: 2 } : { f : Num a -> Num a, y : Num * }"#,
r"{ f: <function>, y: 2 } : { f : Num a -> Num a, y : Num * }",
)
}
@ -1139,10 +1139,10 @@ fn issue_2588_record_with_function_and_nonfunction() {
fn opaque_apply() {
expect_success(
indoc!(
r#"
r"
Age := U32
@Age 23"#
@Age 23"
),
"@Age 23 : Age",
)
@ -1165,14 +1165,14 @@ fn opaque_apply_polymorphic() {
fn opaque_pattern_and_call() {
expect_success(
indoc!(
r#"
r"
F t u := [Package t u]
f = \@F (Package A {}) -> @F (Package {} A)
f (@F (Package A {}))"#
f (@F (Package A {}))"
),
r#"@F (Package {} A) : F {} [A]"#,
r"@F (Package {} A) : F {} [A]",
)
}
@ -1180,10 +1180,10 @@ fn opaque_pattern_and_call() {
fn dec_in_repl() {
expect_success(
indoc!(
r#"
r"
x: Dec
x=1.23
x"#
x"
),
"1.23 : Dec",
)
@ -1193,12 +1193,12 @@ fn dec_in_repl() {
fn print_i8_issue_2710() {
expect_success(
indoc!(
r#"
r"
a : I8
a = -1
a"#
a"
),
r#"-1 : I8"#,
r"-1 : I8",
)
}
@ -1243,11 +1243,11 @@ fn issue_2582_specialize_result_value() {
fn issue_2818() {
expect_success(
indoc!(
r#"
r"
f : {} -> List Str
f = \_ ->
x = []
x"#
x"
),
r"<function> : {} -> List Str",
)
@ -1257,7 +1257,7 @@ fn issue_2818() {
fn issue_2810_recursive_layout_inside_nonrecursive() {
expect_success(
indoc!(
r#"
r"
Command : [Command Tool]
Job : [Job Command]
@ -1266,7 +1266,7 @@ fn issue_2810_recursive_layout_inside_nonrecursive() {
a : Job
a = Job (Command (FromJob (Job (Command SystemTool))))
a"#
a"
),
"Job (Command (FromJob (Job (Command SystemTool)))) : Job",
)
@ -1276,12 +1276,12 @@ fn issue_2810_recursive_layout_inside_nonrecursive() {
fn render_nullable_unwrapped_passing_through_alias() {
expect_success(
indoc!(
r#"
r"
Deep : [L DeepList]
DeepList : [Nil, Cons Deep]
v : DeepList
v = (Cons (L (Cons (L (Cons (L Nil))))))
v"#
v"
),
"Cons (L (Cons (L (Cons (L Nil))))) : DeepList",
)
@ -1291,9 +1291,9 @@ fn render_nullable_unwrapped_passing_through_alias() {
fn opaque_wrap_function() {
expect_success(
indoc!(
r#"
r"
A a := a
List.map [1u8, 2u8, 3u8] @A"#
List.map [1u8, 2u8, 3u8] @A"
),
"[@A 1, @A 2, @A 3] : List (A U8)",
);
@ -1305,10 +1305,10 @@ fn opaque_wrap_function() {
fn dict_get_single() {
expect_success(
indoc!(
r#"
Dict.single 0 {a: 1, c: 2} |> Dict.get 0"#
r"
Dict.single 0 {a: 1, c: 2} |> Dict.get 0"
),
r#"Ok { a: 1, c: 2 } : Result { a : Num *, c : Num * } [KeyNotFound]"#,
r"Ok { a: 1, c: 2 } : Result { a : Num *, c : Num * } [KeyNotFound]",
)
}
@ -1319,7 +1319,7 @@ fn record_of_poly_function() {
r#"
{ a: \_ -> "a" }"#
),
r#"{ a: <function> } : { a : * -> Str }"#,
r"{ a: <function> } : { a : * -> Str }",
);
}
@ -1338,18 +1338,18 @@ fn record_of_poly_function_and_string() {
fn newtype_by_void_is_wrapped() {
expect_success(
indoc!(
r#"
Result.try (Err 42) (\x -> Err (x+1))"#
r"
Result.try (Err 42) (\x -> Err (x+1))"
),
r#"Err 42 : Result b (Num *)"#,
r"Err 42 : Result b (Num *)",
);
expect_success(
indoc!(
r#"
Result.try (Ok 42) (\x -> Ok (x+1))"#
r"
Result.try (Ok 42) (\x -> Ok (x+1))"
),
r#"Ok 43 : Result (Num *) err"#,
r"Ok 43 : Result (Num *) err",
);
}
@ -1357,11 +1357,11 @@ fn newtype_by_void_is_wrapped() {
fn enum_tag_union_in_list() {
expect_success(
indoc!(
r#"
r"
[E, F, G, H]
"#
"
),
r#"[E, F, G, H] : List [E, F, G, H]"#,
r"[E, F, G, H] : List [E, F, G, H]",
);
}
@ -1373,7 +1373,7 @@ fn str_to_dec() {
Str.toDec "1234.1234"
"#
),
r#"Ok 1234.1234 : Result Dec [InvalidNumStr]"#,
r"Ok 1234.1234 : Result Dec [InvalidNumStr]",
);
}
@ -1405,7 +1405,7 @@ fn nested_tuple() {
fn ordered_tag_union_memory_layout() {
expect_success(
indoc!(
r#"
r"
Loc : { line: U32, column: U32 }
Node : [ A Loc, Height U8 Loc ]
@ -1413,9 +1413,9 @@ fn ordered_tag_union_memory_layout() {
x : Node
x = Height 1 { line: 2, column: 3 }
x
"#
"
),
r#"Height 1 { column: 3, line: 2 } : Node"#,
r"Height 1 { column: 3, line: 2 } : Node",
);
}

View File

@ -149,7 +149,7 @@ fn run_with_valgrind(binary_path: &std::path::Path) {
let memory_errors = extract_valgrind_errors(&raw_xml).unwrap_or_else(|err| {
panic!(
indoc!(
r#"
r"
failed to parse the `valgrind` xml output:
Error was:
@ -167,7 +167,7 @@ fn run_with_valgrind(binary_path: &std::path::Path) {
valgrind stderr was:
{}
"#
"
),
err, raw_xml, valgrind_out.stdout, valgrind_out.stderr
);
@ -214,7 +214,7 @@ fn list_concat_consumes_first_argument() {
#[test]
fn list_concat_consumes_second_argument() {
valgrind_test(indoc!(
r#"
r"
(
a : List U8
a = []
@ -223,7 +223,7 @@ fn list_concat_consumes_second_argument() {
|> List.len
|> Num.toStr
)
"#
"
));
}
@ -273,7 +273,7 @@ fn str_concat_first_argument_not_unique() {
#[test]
fn list_concat_empty_list_zero_sized_type() {
valgrind_test(indoc!(
r#"
r"
(
a = List.reserve [] 11
b = []
@ -281,7 +281,7 @@ fn list_concat_empty_list_zero_sized_type() {
|> List.len
|> Num.toStr
)
"#
"
));
}
@ -316,7 +316,7 @@ fn str_trim_start_capacity() {
#[test]
fn str_concat_later_referencing_empty_list_with_capacity() {
valgrind_test(indoc!(
r#"
r"
(
a : List U8
a = List.withCapacity 1
@ -326,7 +326,7 @@ fn str_concat_later_referencing_empty_list_with_capacity() {
|> Num.addWrap (List.len a)
|> Num.toStr
)
"#
"
));
}
@ -504,7 +504,7 @@ fn tree_rebalance() {
#[test]
fn lowlevel_list_calls() {
valgrind_test(indoc!(
r#"
r"
(
a = List.map [1,1,1,1,1] (\x -> x + 0)
b = List.map2 a [1,1,1,1,1] (\x, y -> x + y)
@ -514,7 +514,7 @@ fn lowlevel_list_calls() {
Num.toStr (List.len e)
)
"#
"
));
}