Merge remote-tracking branch 'origin/trunk' into expect-dont-panic

This commit is contained in:
Richard Feldman 2022-01-30 20:22:26 -05:00
commit a55ff62e6c
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
501 changed files with 26570 additions and 12276 deletions

View file

@ -1978,7 +1978,7 @@ fn hof_conditional() {
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[should_panic(
expected = "Roc failed with message: \"Shadowing { original_region: |L 3-3, C 4-5|, shadow: |L 6-6, C 8-9| Ident"
expected = "Roc failed with message: \"Shadowing { original_region: @57-58, shadow: @90-91 Ident"
)]
fn pattern_shadowing() {
assert_evals_to!(
@ -1995,26 +1995,6 @@ fn pattern_shadowing() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[should_panic(expected = "TODO non-exhaustive pattern")]
fn non_exhaustive_pattern_let() {
assert_evals_to!(
indoc!(
r#"
x : Result (Int a) (Float b)
x = Ok 4
(Ok y) = x
y
"#
),
0,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
#[ignore]
@ -2474,9 +2454,7 @@ fn backpassing_result() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[should_panic(
expected = "Shadowing { original_region: |L 3-3, C 4-5|, shadow: |L 5-5, C 6-7| Ident"
)]
#[should_panic(expected = "Shadowing { original_region: @57-58, shadow: @74-75 Ident")]
fn function_malformed_pattern() {
assert_evals_to!(
indoc!(
@ -3143,3 +3121,112 @@ fn call_that_needs_closure_parameter() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn alias_defined_out_of_order() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ main ] to "./platform"
main : Foo
main = "foo"
Foo : Bar
Bar : Str
"#
),
RocStr::from_slice(b"foo"),
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn recursively_build_effect() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ main ] to "./platform"
greeting =
hi = "Hello"
name = "World"
"\(hi), \(name)!"
main =
when nestHelp 4 is
_ -> greeting
nestHelp : I64 -> XEffect {}
nestHelp = \m ->
when m is
0 ->
always {}
_ ->
always {} |> after \_ -> nestHelp (m - 1)
XEffect a : [ @XEffect ({} -> a) ]
always : a -> XEffect a
always = \x -> @XEffect (\{} -> x)
after : XEffect a, (a -> XEffect b) -> XEffect b
after = \(@XEffect e), toB ->
@XEffect \{} ->
when toB (e {}) is
@XEffect e2 ->
e2 {}
"#
),
RocStr::from_slice(b"Hello, World!"),
RocStr
);
}
#[test]
#[ignore = "TODO; currently generates bad code because `a` isn't specialized inside the closure."]
#[cfg(any(feature = "gen-llvm"))]
fn polymophic_expression_captured_inside_closure() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ main ] to "./platform"
asU8 : U8 -> U8
asU8 = \_ -> 30
main =
a = 15
f = \{} ->
asU8 a
f {}
"#
),
30,
u8
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn issue_2322() {
assert_evals_to!(
indoc!(
r#"
double = \x -> x * 2
doubleBind = \x -> (\_ -> double x)
doubleThree = doubleBind 3
doubleThree {}
"#
),
6,
i64
)
}