Skip to content

Commit

Permalink
proposing 'integration' test
Browse files Browse the repository at this point in the history
Current state:
Type Errors:  [4/5, 452ms]
    - everything is ok [1ms]
    - try to apply one argument [253ms]
    - try to apply two arguments [62ms]
    - [FAILED] report unapplied constructor nicely [77ms]
        Reason: The value (Error: Type error: expected `x` to be My_Type, but got Constructor<My_Type.Value>.) did not contain the element (Try to apply foo argument.) (at C:\NBO\enso\test\Tests\src\Semantic\Error_Spec.enso:370:13-73).
    - report partially applied constructor nicely [56ms]
  • Loading branch information
radeusgd committed Aug 23, 2023
1 parent 4105f51 commit 5c2ef16
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/Tests/src/Semantic/Error_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Standard.Test.Extensions

type My_Type
Value foo
Multi_Value foo bar

throw_a_bar = Error.throw "bar"
throw_a_bar_panicking = Panic.throw "bar"
Expand Down Expand Up @@ -348,17 +349,29 @@ spec =

neg n:Number = -n

extract x:My_Type = x.foo

Test.specify "everything is ok" <|
neg (my_func -5 -2) . should_equal 7

Test.specify "try to apply one argument" <|
r = Panic.recover Type_Error <| neg (my_func -5)
r . should_fail_with Type_Error
r.to_display_text.contains "Try to apply y argument" . should_be_true
r.to_display_text.should_contain "Try to apply y argument."

Test.specify "try to apply two arguments" <|
r = Panic.recover Type_Error <| neg my_func
r . should_fail_with Type_Error
r.to_display_text.contains "Try to apply x, y arguments" . should_be_true
r.to_display_text.should_contain "Try to apply x, y arguments."

Test.specify "report unapplied constructor nicely" <|
r = Panic.recover Type_Error <| extract My_Type.Value
r . should_fail_with Type_Error
r.to_display_text.should_contain "Try to apply foo argument."

Test.specify "report partially applied constructor nicely" <|
r = Panic.recover Type_Error <| extract (My_Type.Multi_Value 42)
r . should_fail_with Type_Error
r.to_display_text.should_contain "Try to apply bar argument."

main = Test_Suite.run_main spec

0 comments on commit 5c2ef16

Please sign in to comment.