From 870294b5649b8bc6812e77ebfa96abe1b47fbb5f Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Mon, 18 Jul 2022 13:35:50 -0400 Subject: [PATCH] Update reporting tests --- crates/reporting/tests/test_reporting.rs | 112 ++++++++++++++++------- 1 file changed, 77 insertions(+), 35 deletions(-) diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index ebb76971fe..64e13a18b3 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -8046,35 +8046,6 @@ All branches in an `if` must have the same type! "### ); - test_report!( - ability_member_not_defined, - indoc!( - r#" - app "test" provides [] to "./platform" - - Eq has - eq : a, a -> U64 | a has Eq - - Hash has - hash : a, a -> U64 | a has Hash - - A := U8 has [Eq {eq}, Hash {hash}] - "# - ), - @r###" - ── NAMING ERROR ── tmp/ability_first_demand_not_indented_enough/Test.roc ─ - - I was partway through parsing an ability definition, but I got stuck - here: - - 4│ Eq has - 5│ eq : a, a -> U64 | a has Eq - ^ - - I suspect this line is not indented enough (by 1 spaces) - "### - ); - test_report!( wildcard_in_alias, indoc!( @@ -9162,6 +9133,22 @@ All branches in an `if` must have the same type! "# ); + test_report!( + #[ignore="TODO"] + opaque_ability_impl_not_found_shorthand_syntax, + indoc!( + r#" + app "test" provides [] to "./platform" + + Eq has eq : a, a -> U64 | a has Eq + + A := U8 has [Eq {eq}] + "# + ), + @r###" + "### + ); + test_report!( opaque_ability_impl_not_found, indoc!( @@ -9176,14 +9163,27 @@ All branches in an `if` must have the same type! "# ), @r###" - "### + ── UNRECOGNIZED NAME ───────────────────────────────────── /code/proj/Main.roc ─ + + Nothing is named `aEq` in this scope. + + 5│ A := U8 has [ Eq {eq: aEq} ] + ^^^ + + Did you mean one of these? + + Eq + myEq + eq + U8 + "### ); test_report!( opaque_ability_impl_optional, indoc!( r#" - app "test" provides [myEq] to "./platform" + app "test" provides [A, myEq] to "./platform" Eq has eq : a, a -> Bool | a has Eq @@ -9193,7 +9193,17 @@ All branches in an `if` must have the same type! "# ), @r###" - "### + ── OPTIONAL ABILITY IMPLEMENTATION ─────────────────────── /code/proj/Main.roc ─ + + Ability implementations cannot be optional: + + 5│ A := U8 has [ Eq {eq ? aEq} ] + ^^^^^^^^ + + Custom implementations must be supplied fully. + + + "### ); test_report!( @@ -9210,7 +9220,19 @@ All branches in an `if` must have the same type! "# ), @r###" - "### + ── OPTIONAL ABILITY IMPLEMENTATION ─────────────────────── /code/proj/Main.roc ─ + + Ability implementations cannot be optional: + + 5│ A := U8 has [ Encoding {toEncoder ? myEncoder} ] + ^^^^^^^^^^^^^^^^^^^^^ + + Custom implementations must be supplied fully. + + Hint: if you want this implementation to be derived, don't include a + record of implementations. For example, has [Encoding] will attempt + to derive `Encoding` + "### ); test_report!( @@ -9225,7 +9247,16 @@ All branches in an `if` must have the same type! "# ), @r###" - "### + ── QUALIFIED ABILITY IMPLEMENTATION ────────────────────── /code/proj/Main.roc ─ + + This ability implementation is qualified: + + 5│ A := U8 has [ Eq {eq : Bool.eq} ] + ^^^^^^^ + + Custom implementations must be defined in the local scope, and + unqualified. + "### ); test_report!( @@ -9240,7 +9271,18 @@ All branches in an `if` must have the same type! "# ), @r###" - "### + ── ABILITY IMPLEMENTATION NOT IDENTIFIER ───────────────── /code/proj/Main.roc ─ + + This ability implementation is not an identifier: + + 5│ A := U8 has [ Eq {eq : \m, n -> m == n} ] + ^^^^^^^^^^^^^^^ + + Custom ability implementations defined in this position can only be + unqualified identifiers, not arbitrary expressions. + + Tip: consider defining this expression as a variable. + "### ); test_report!(