Merge Test_New into Test (#8991)

Merges the temporary `Test_New` library into `Test`. This is the last PR in the series of PRs that refactor all the stdlib tests to the builder API.
This commit is contained in:
Pavel Marek 2024-02-08 12:25:13 +01:00 committed by GitHub
parent 93f2a44633
commit f3f0697d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
226 changed files with 424 additions and 1943 deletions

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Runtime.Context
from Standard.Test import Test
import project.Test.Test
## PRIVATE
Runs the action twice, once with the Output context enabled and once with it

View File

@ -2,8 +2,8 @@ from Standard.Base import all
import Standard.Base.Errors.Common.No_Such_Method
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import project.Test_Result.Test_Result
from project.Test import Test
import project.Spec_Result.Spec_Result
import project.Test.Test
## Expect a function to fail with the provided dataflow error.
@ -22,7 +22,7 @@ from project.Test import Test
example_should_fail_with =
Examples.throw_error . should_fail_with Examples.My_Error
Any.should_fail_with : Any -> Integer -> Boolean -> Test_Result
Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result
Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
_ = unwrap_errors
loc = Meta.get_source_location 1+frames_to_skip
@ -46,7 +46,7 @@ Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
example_should_fail_with =
Examples.throw_error . should_fail_with Examples.My_Error
Error.should_fail_with : Any -> Integer -> Boolean -> Test_Result
Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result
Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
unwrap_maybe error = if unwrap_errors then Error.unwrap error else error
caught = unwrap_maybe self.catch
@ -69,9 +69,9 @@ Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
from Standard.Test import Test
example_should_equal = Examples.add_1_to 1 . should_equal 2
Any.should_equal : Any -> Integer -> Test_Result
Any.should_equal : Any -> Integer -> Spec_Result
Any.should_equal self that frames_to_skip=0 = case self == that of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
additional_comment = case self of
@ -102,9 +102,9 @@ Any.should_equal self that frames_to_skip=0 = case self == that of
from Standard.Test import Test
example_should_equal = Examples.some_type . should_equal_type Vector
Any.should_equal_type : Any -> Integer -> Test_Result
Any.should_equal_type : Any -> Integer -> Spec_Result
Any.should_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that) of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did not equal type " + that.to_text + " (at " + loc + ")."
@ -129,9 +129,9 @@ Error.should_equal_type self that frames_to_skip=0 =
from Standard.Test import Test
example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2
Any.should_not_equal : Any -> Integer -> Test_Result
Any.should_not_equal : Any -> Integer -> Spec_Result
Any.should_not_equal self that frames_to_skip=0 = case self != that of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did equal " + that.to_text + " (at " + loc + ")."
@ -156,9 +156,9 @@ Error.should_not_equal self that frames_to_skip=0 =
from Standard.Test import Test
example_should_not_equal = Examples.some_type . should_not_equal_type Vector
Any.should_not_equal_type : Any -> Integer -> Test_Result
Any.should_not_equal_type : Any -> Integer -> Spec_Result
Any.should_not_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that . not) of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did equal type " + that.to_text + " (at " + loc + ")."
@ -182,9 +182,9 @@ Error.should_not_equal_type self that frames_to_skip=0 =
from Standard.Test import Test
example_should_start_with = "Hello World!" . should_start_with "Hello"
Any.should_start_with : Text -> Integer -> Test_Result
Any.should_start_with : Text -> Integer -> Spec_Result
Any.should_start_with self that frames_to_skip=0 = case self of
_ : Text -> if self.starts_with that then Test_Result.Success else
_ : Text -> if self.starts_with that then Spec_Result.Success else
loc = Meta.get_source_location 3+frames_to_skip
msg = self.to_text + " does not start with " + that.to_text + " (at " + loc + ")."
Test.fail msg
@ -206,9 +206,9 @@ Any.should_start_with self that frames_to_skip=0 = case self of
from Standard.Test import Test
example_should_end_with = "Hello World!" . should_end_with "ld!"
Any.should_end_with : Text -> Integer -> Test_Result
Any.should_end_with : Text -> Integer -> Spec_Result
Any.should_end_with self that frames_to_skip=0 = case self of
_ : Text -> if self.ends_with that then Test_Result.Success else
_ : Text -> if self.ends_with that then Spec_Result.Success else
loc = Meta.get_source_location 3+frames_to_skip
msg = self.to_text + " does not end with " + that.to_text + " (at " + loc + ")."
Test.fail msg
@ -230,7 +230,7 @@ Any.should_end_with self that frames_to_skip=0 = case self of
from Standard.Test import Test
example_should_start_with = "Hello World!" . should_start_with "Hello"
Error.should_start_with : Any -> Integer -> Test_Result
Error.should_start_with : Any -> Integer -> Spec_Result
Error.should_start_with self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -248,7 +248,7 @@ Error.should_start_with self that frames_to_skip=0 =
from Standard.Test import Test
example_should_end_with = "Hello World!" . should_end_with "ld!"
Error.should_end_with : Any -> Integer -> Test_Result
Error.should_end_with : Any -> Integer -> Spec_Result
Error.should_end_with self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -265,7 +265,7 @@ Error.should_end_with self that frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = Examples.add_1_to 1 . should_equal 2
Error.should_equal : Any -> Integer -> Test_Result
Error.should_equal : Any -> Integer -> Spec_Result
Error.should_equal self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -292,13 +292,13 @@ Error.should_equal self that frames_to_skip=0 =
example_should_equal =
1.00000001 . should_equal 1.00000002 epsilon=0.0001
Number.should_equal : Float -> Float -> Integer -> Test_Result
Number.should_equal : Float -> Float -> Integer -> Spec_Result
Number.should_equal self that epsilon=0 frames_to_skip=0 =
matches = case that of
_ : Number -> self.equals that epsilon
_ -> False
case matches of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did not equal " + that.to_text + " (at " + loc + ")."
@ -352,9 +352,9 @@ Error.should_be_a self typ frames_to_skip=0 =
from Standard.Test import Test
example_should_be_true = Examples.get_boolean . should_be_true
Boolean.should_be_true : Test_Result
Boolean.should_be_true : Spec_Result
Boolean.should_be_true self = case self of
True -> Test_Result.Success
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2
Test.fail "Expected False to be True (at "+loc+")."
@ -368,7 +368,7 @@ Boolean.should_be_true self = case self of
from Standard.Test import Test
example_should_be_true = Examples.get_boolean . should_be_true
Error.should_be_true : Test_Result
Error.should_be_true : Spec_Result
Error.should_be_true self = Test.fail_match_on_unexpected_error self 1
## Asserts that the given `Boolean` is `False`
@ -380,12 +380,12 @@ Error.should_be_true self = Test.fail_match_on_unexpected_error self 1
from Standard.Test import Test
example_should_be_false = Examples.get_boolean . should_be_false
Boolean.should_be_false : Test_Result
Boolean.should_be_false : Spec_Result
Boolean.should_be_false self = case self of
True ->
loc = Meta.get_source_location 2
Test.fail "Expected True to be False (at "+loc+")."
False -> Test_Result.Success
False -> Spec_Result.Success
## Asserts that the given `Boolean` is `False`
@ -396,7 +396,7 @@ Boolean.should_be_false self = case self of
from Standard.Test import Test
example_should_be_false = Examples.get_boolean . should_be_false
Error.should_be_false : Test_Result
Error.should_be_false : Spec_Result
Error.should_be_false self = Test.fail_match_on_unexpected_error self 1
## Asserts that a value is of a given type.
@ -410,7 +410,7 @@ Error.should_be_false self = Test.fail_match_on_unexpected_error self 1
from Standard.Test import Test
example_should_be_a = 1.should_be_a Boolean
Any.should_be_a : Any -> Test_Result
Any.should_be_a : Any -> Spec_Result
Any.should_be_a self typ =
loc = Meta.get_source_location 1
fail_on_wrong_arg_type =
@ -419,7 +419,7 @@ Any.should_be_a self typ =
case Meta.meta typ of
c : Meta.Constructor -> case Meta.meta self of
a : Meta.Atom ->
if a.constructor == c then Test_Result.Success else
if a.constructor == c then Spec_Result.Success else
expected_type = Meta.get_qualified_type_name typ
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+loc+")."
@ -431,7 +431,7 @@ Any.should_be_a self typ =
Test.fail message
_ : Meta.Type ->
ok = self.is_a typ || self==typ
if ok then Test_Result.Success else
if ok then Spec_Result.Success else
expected_type = Meta.get_qualified_type_name typ
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of type "+expected_type+" but got a value of type "+actual_type+" instead (at "+loc+")."
@ -443,13 +443,13 @@ Any.should_be_a self typ =
self.should_be_a (ctor.value ...)
_ : Meta.Polyglot ->
ok = self.is_a typ
if ok then Test_Result.Success else
if ok then Spec_Result.Success else
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of Java class "+typ.to_text+" but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
Meta.Primitive.Value (b : Boolean) ->
ok = self == b
if ok then Test_Result.Success else
if ok then Spec_Result.Success else
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of "+typ.to_text+" but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
@ -476,7 +476,7 @@ Any.should_be_a self typ =
from Standard.Test import Test
example_should_equal = [1, 2] . should_contain_the_same_elements_as [2, 1]
Any.should_contain_the_same_elements_as : Any -> Integer -> Test_Result
Any.should_contain_the_same_elements_as : Any -> Integer -> Spec_Result
Any.should_contain_the_same_elements_as self that frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
that.each element->
@ -487,7 +487,7 @@ Any.should_contain_the_same_elements_as self that frames_to_skip=0 =
if that.contains element . not then
msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + loc + ")."
Test.fail msg
Test_Result.Success
Spec_Result.Success
## Asserts that `self` value contains the same elements as `that`.
@ -510,7 +510,7 @@ Any.should_contain_the_same_elements_as self that frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = [1, 2] . should_contain_the_same_elements_as [2, 1]
Error.should_contain_the_same_elements_as : Any -> Integer -> Test_Result
Error.should_contain_the_same_elements_as : Any -> Integer -> Spec_Result
Error.should_contain_the_same_elements_as self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -537,14 +537,14 @@ Error.should_contain_the_same_elements_as self that frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4]
Any.should_only_contain_elements_in : Any -> Integer -> Test_Result
Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result
Any.should_only_contain_elements_in self that frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
self.each element->
if that.contains element . not then
msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + loc + ")."
Test.fail msg
Test_Result.Success
Spec_Result.Success
## Asserts that `self` value contains only elements in `that`.
@ -568,7 +568,7 @@ Any.should_only_contain_elements_in self that frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4]
Error.should_only_contain_elements_in : Any -> Integer -> Test_Result
Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result
Error.should_only_contain_elements_in self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -590,14 +590,14 @@ Error.should_only_contain_elements_in self that frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = "foobar".should_contain "foo"
Any.should_contain : Any -> Integer -> Test_Result
Any.should_contain : Any -> Integer -> Spec_Result
Any.should_contain self element frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic->
if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else
msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")."
Test.fail msg
if contains_result then Test_Result.Success else
if contains_result then Spec_Result.Success else
msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + loc + ")."
Test.fail msg
@ -618,7 +618,7 @@ Any.should_contain self element frames_to_skip=0 =
from Standard.Test import Test
example_should_equal = "foobar".should_contain "foo"
Error.should_contain : Any -> Integer -> Test_Result
Error.should_contain : Any -> Integer -> Spec_Result
Error.should_contain self element frames_to_skip=0 =
_ = [element]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
@ -633,14 +633,14 @@ Error.should_contain self element frames_to_skip=0 =
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
Any.should_not_contain : Any -> Integer -> Test_Result
Any.should_not_contain : Any -> Integer -> Spec_Result
Any.should_not_contain self element frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic->
if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else
msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")."
Test.fail msg
if contains_result.not then Test_Result.Success else
if contains_result.not then Spec_Result.Success else
msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + loc + ")."
Test.fail msg
@ -654,7 +654,7 @@ Any.should_not_contain self element frames_to_skip=0 =
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
Error.should_not_contain : Any -> Integer -> Test_Result
Error.should_not_contain : Any -> Integer -> Spec_Result
Error.should_not_contain self element frames_to_skip=0 =
_ = [element]
Test.fail_match_on_unexpected_error self 1+frames_to_skip

View File

@ -1,17 +1,15 @@
from Standard.Base import all
import project.Bench.Bench
import project.Bench.Phase_Conf
import project.Faker.Faker
import project.Problems
import project.Suite.Suite
import project.Test.Test
import project.Test_Suite.Test_Suite
import project.Problems
from project.Extensions import all
export project.Bench.Bench
export project.Bench.Phase_Conf
export project.Faker.Faker
export project.Problems
export project.Suite.Suite
export project.Test.Test
export project.Test_Suite.Test_Suite
export project.Problems
from project.Extensions export all

View File

@ -1,3 +1,5 @@
private
from Standard.Base import all
import Standard.Base.Runtime.Source_Location.Source_Location
import Standard.Base.Runtime.Stack_Trace_Element
@ -17,7 +19,7 @@ find_project_root path =
find_caller_script : Vector Stack_Trace_Element -> File
find_caller_script stack =
find_main idx =
if stack.at idx . name == "Test_Suite.type.run_main" then idx else
if stack.at idx . name . split "." . last == "main" then idx else
@Tail_Call find_main (idx + 1)
main_index = find_main 0
@ -29,38 +31,35 @@ find_caller_script stack =
if (idx + 1 == stack.length) then Nothing else
@Tail_Call find_caller (idx + 1)
find_caller (main_index + 1)
find_caller main_index
## Holds configuration for a Test_Suite
type Suite_Config
## PRIVATE
Construct a configuration
Arguments:
- output_path: The path to the JUnit XML file to write to. If Nothing, no JUnit XML file
will be written.
Value (print_only_failures : Boolean) (output_path : (File | Nothing)) (use_ansi_colors : Boolean)
## Creates an Suite_Config based off environment and caller location
from_environment : Suite_Config
from_environment =
only_group_regexp = Environment.get "TEST_ONLY_GROUP"
print_only_failures = Environment.get "REPORT_ONLY_FAILED" != Nothing
junit_folder = Environment.get "ENSO_TEST_JUNIT_DIR"
use_ansi_colors = Environment.get "ENSO_TEST_ANSI_COLORS" . is_nothing . not
results_path = if junit_folder.is_nothing then Nothing else
caller_script = find_caller_script Runtime.get_stack_trace
project_root = find_project_root caller_script
case project_root.is_nothing of
case project_root.is_error || project_root.is_nothing of
True ->
IO.println "Unable to determine root project path. JUnit output disabled."
Nothing
False ->
(File.new junit_folder) / project_root.name / "JUnit.xml"
Suite_Config.Value only_group_regexp print_only_failures results_path
## PRIVATE
Construct a configuration
Value only_group_regexp print_only_failures output_path
## Should a specific group be run.
should_run_group self name =
regexp = self.only_group_regexp
case regexp of
_ : Text -> name.match regexp . catch Any (_->True)
_ -> True
Suite_Config.Value print_only_failures results_path use_ansi_colors
## Should the results be written to JUnit XML file.
should_output_junit self =

View File

@ -1,114 +1,39 @@
from Standard.Base import all
import Standard.Base.Errors.Common.Uninitialized_State
import Standard.Base.Runtime.State
from Standard.Base.Errors.Common import Uninitialized_State
from Standard.Base.Runtime import State
import project.Test_Reporter
import project.Clue.Clue
import project.Group.Group
import project.Spec.Spec
import project.Spec_Result.Spec_Result
import project.Suite.Suite
import project.Suite.Suite_Builder
import project.Test_Result.Test_Result
import project.Test_Suite.Test_Suite
## Set of functions for running Unit Tests.
## Contains only static methods
type Test
## Creates a new test group, describing properties of the object
described by `self`.
Arguments:
- name: The name of the test group.
- behaviors: An action containing a set of specs for the group.
- pending: A reason for why the test is pending, or `Nothing` when it is not
pending.
> Example
Adding a test group.
from Standard.Test import Test, Test_Suite
example_group = Test_Suite.run <|
Test.group "Number" <| Nothing
group : Text -> Any -> (Text | Nothing) -> Nothing
group name ~behaviors pending=Nothing =
suite = State.get Test_Suite
config = suite.config
if config.should_run_group name then
case pending of
Nothing ->
handle_failed_group_builder caught_panic =
stack_trace_text = caught_panic.stack_trace.map .to_display_text . join '\n'
result = Test_Result.Failure "A Panic has been thrown outside of `Test.specify`, failed to run the test group: "+caught_panic.payload.to_display_text details=caught_panic.to_text+'\n'+stack_trace_text
behavior = Behavior.Value "{Building the test group.}" result Duration.zero
Spec.Value name (List.Cons behavior List.Nil)
r = Panic.catch Any handler=handle_failed_group_builder <|
State.run Spec (Spec.Value name List.Nil) <|
behaviors
State.get Spec
case find_parent_spec of
Nothing ->
# This is the root group - print report and save it to the test suite:
Test_Reporter.print_report r config suite.builder
new_suite = Test_Suite.Value suite.config (List.Cons r suite.specs) suite.builder suite.skipped_groups
State.put Test_Suite new_suite
Spec.Value parent_name parent_behaviors ->
# We add our nested group name to each behavior
extended_behaviors = r.behaviors.map b-> b.prepend_name r.name
# And then add the behaviors to our parent spec's list of behaviors
new_spec = Spec.Value parent_name (prepend_list extended_behaviors parent_behaviors)
State.put Spec new_spec
reason ->
Test_Reporter.report_pending_group name reason config suite.builder
new_suite = Test_Suite.Value suite.config suite.specs suite.builder suite.skipped_groups+1
State.put Test_Suite new_suite
## Specifies a single behavior, described by `self`.
Arguments:
- label: A description of the behavior being tested.
- behavior: An action that executes tests.
- pending: A reason for why the test is pending, or `Nothing` when it is not
pending.
> Example
Adding a specification to the test group.
from Standard.Test import Test, Test_Suite
example_group = Test_Suite.run <|
Test.group "Number" <|
Test.specify "should define addition" <|
2+3 . should_equal 5
> Example
Adding a pending specification to the test group.
from Standard.Test import Test, Test_Suite
example_group = Test_Suite.run <|
Test.group "Number" <|
Test.specify "should define addition" pending="Reason" <|
2+3 . should_equal 5
specify : Text -> Any -> (Text | Nothing) -> Nothing
specify label ~behavior pending=Nothing =
pair = case pending of
Nothing -> Duration.time_execution (State.run Clue Nothing (run_spec behavior))
reason -> Pair.new Duration.zero (Test_Result.Pending reason)
result = pair.second
time_taken = pair.first
spec = State.get Spec
new_spec = Spec.Value spec.name (List.Cons (Behavior.Value label result time_taken) spec.behaviors)
State.put Spec new_spec
## Construct a Test Suite object
build : (Suite_Builder -> Any) -> Suite
build fn =
b = Vector.new_builder
fn (Suite_Builder.Impl b)
groups_vec = b.to_vector
Suite.Impl groups_vec
## Expect a function to fail with the provided panic.
Arguments:
- action: The action to evaluate that is expected to fail with a panic.
- matcher: The expected type of the panic thrown by `action`.
Arguments:
- action: The action to evaluate that is expected to fail with a panic.
- matcher: The expected type of the panic thrown by `action`.
> Example
Expect that a computation should panic as part of a test.
> Example
Expect that a computation should panic as part of a test.
import Standard.Examples
from Standard.Test import Test
import Standard.Examples
from Standard.Test import Test
example_expect_panic_with =
Test.expect_panic_with Examples.throw_panic Examples.My_Error
example_expect_panic_with =
Test.expect_panic_with Examples.throw_panic Examples.My_Error
expect_panic_with : Any -> Any -> Test_Result
expect_panic_with ~action matcher =
res = Panic.recover Any action
@ -140,6 +65,7 @@ type Test
Test.expect_panic_with Examples.My_Error <|
IO.println 'hello'
Examples.throw_panic
IO.println 'this is not reached'
expect_panic : Any -> Any -> Test_Result
expect_panic matcher ~action = Test.expect_panic_with action matcher
@ -169,15 +95,15 @@ type Test
from Standard.Test import Test
example_fail = Test.fail "Something went wrong."
fail : Text -> Nothing|Text -> Test_Result
fail : Text -> Nothing|Text -> Spec_Result
fail message details=Nothing =
failure = Test_Result.Failure (Test.enrich_message_with_clue message) details
failure = Spec_Result.Failure (Test.enrich_message_with_clue message) details
Panic.throw failure
## PRIVATE
enrich_message_with_clue : Text -> Text
enrich_message_with_clue message =
clue = Panic.catch Uninitialized_State (State.get Clue) _->Nothing
clue = Panic.catch Uninitialized_State (State.get Clue) handler=(_-> Nothing)
case clue of
Clue.Value add_clue -> add_clue message
_ -> message
@ -225,127 +151,3 @@ type Test
State.put Clue prev_clue
result
## PRIVATE
Executes a behavior test.
Arguments:
- behavior: The behavior to execute.
run_spec : Any -> Test_Result
run_spec ~behavior =
recovery = Panic.recover Any <|
result = behavior
result.catch Any err->
Panic.throw (Finished_With.Error err result.get_stack_trace_text)
Nothing
maybeExc = case recovery of
_ -> Test_Result.Success
result = maybeExc.catch Any ex->
case ex of
Test_Result.Failure _ _ -> ex
Finished_With.Error err stack_trace_text ->
Test_Result.Failure (Test.enrich_message_with_clue ("An unexpected error was returned: " + err.to_text)) details=stack_trace_text
_ -> Test_Result.Failure (Test.enrich_message_with_clue ("An unexpected panic was thrown: " + ex.to_text)) details=maybeExc.get_stack_trace_text
result
## PRIVATE
An error describing that a test finished with an unexpected error.
type Finished_With
## PRIVATE
An error describing that a test finished with an unexpected error.
Arguments:
- err: The payload of the error that triggered this error.
- stack_trace_text: A textual representation of the stack trace for the
error.
Error err stack_trace_text
## PRIVATE
A group of behaviors for a test.
type Spec
## PRIVATE
A group of behaviors for a test.
Arguments:
- name: The name of the spec.
- behaviors: The results of the behaviors encapsulated in that spec.
Value name behaviors
## PRIVATE
Checks if the spec group contains any failures and hence fails itself.
is_fail : Boolean
is_fail self = self.behaviors.any .is_fail
## Number of tests that passed.
tests_succeeded : Integer
tests_succeeded self = self.behaviors.filter (x-> x.is_success) . length
## Number of tests that failed.
tests_failed : Integer
tests_failed self = self.behaviors.filter (x-> x.is_fail) . length
## Number of tests that were skipped.
tests_pending : Integer
tests_pending self = self.behaviors.filter (x-> x.is_pending) . length
## Counts how many tests have been executed, not including pending tests.
tests_executed : Integer
tests_executed self = self.behaviors.filter (b-> b.is_pending.not) . length
## PRIVATE
A description of a behaviors in a test.
type Behavior
## PRIVATE
A description of a behaviors in a test.
Arguments:
- name: The name of the behavior.
- result: The result of the behavior.
- time_taken: The duration that the behaviour took to run.
Value name result time_taken
## PRIVATE
Checks if the behavior is pending.
is_pending : Boolean
is_pending self = self.result.is_pending
## PRIVATE
Checks if the behavior is a failure.
is_fail : Boolean
is_fail self = self.result.is_fail
## PRIVATE
Checks if the behavior is a success.
is_success : Boolean
is_success self = self.result.is_success
## PRIVATE
prepend_name : Text -> Behavior
prepend_name self name = Behavior.Value (name + " - " + self.name) self.result self.time_taken
## PRIVATE
type Clue
## PRIVATE
Represents a clue as to why a test failed
Arguments:
- add_clue: either Nothing or a function which modifies a failure message
Value add_clue
## PRIVATE
find_parent_spec =
Panic.catch Uninitialized_State handler=(_->Nothing) <|
State.get Spec
## PRIVATE
prepend_list la lb =
la.reverse.fold lb lacc-> elem-> List.Cons elem lacc

View File

@ -1,6 +1,10 @@
private
from Standard.Base import all
import Standard.Base.Runtime.Context
from Standard.Base.Runtime import assert
import project.Spec_Result.Spec_Result
import project.Suite_Config.Suite_Config
import project.Test.Test
import project.Test_Result.Test_Result
@ -26,35 +30,86 @@ wrap_junit_testsuites config builder ~action =
result
## PRIVATE
use_ansi_colors : Boolean
use_ansi_colors = Environment.get "ENSO_TEST_ANSI_COLORS" . is_nothing . not
## PRIVATE
failure_message : Text
failure_message =
fail = 'FAILED'
if use_ansi_colors then '\u001b[31;1m'+fail+'\u001b[0m' else fail
red text =
'\u001b[31;1m' + text + '\u001b[0m'
## PRIVATE
Prints a report on the tests to standard output.
print_report : Test -> Suite_Config -> (StringBuilder|Nothing) -> Nothing
print_report spec config builder =
total_time = spec.behaviors.fold Duration.zero acc-> behavior->
acc + behavior.time_taken
green text =
'\u001b[32;1m' + text + '\u001b[0m'
maybe_red_text (text : Text) (config : Suite_Config) =
if config.use_ansi_colors then (red text) else text
maybe_green_text (text : Text) (config : Suite_Config) =
if config.use_ansi_colors then (green text) else text
## Print result for a single Spec run
print_single_result : Test_Result -> Suite_Config -> Nothing
print_single_result (test_result : Test_Result) (config : Suite_Config) =
times_suffix =
times = test_result.time_taken.total_milliseconds.to_text + "ms"
"[" + times + "]"
case test_result.spec_result of
Spec_Result.Success ->
if config.print_only_failures.not then
txt = " - " + test_result.spec_name + " " + times_suffix
IO.println (maybe_green_text txt config)
Spec_Result.Failure msg details ->
txt = " - [FAILED] " + test_result.spec_name + " " + times_suffix
IO.println (maybe_red_text txt config)
IO.println (" Reason: " + msg)
if details.is_nothing.not then
IO.println details
Spec_Result.Pending reason ->
if config.print_only_failures.not then
IO.println (" - [PENDING] " + test_result.spec_name)
IO.println (" Reason: " + reason)
## Prints all the results, optionally writing them to a jUnit XML output.
Arguments:
- test_results: Vector of `Test_Result`. Can be empty. Can contain results from multiple
groups.
- builder: StringBuilder or Nothing. If StringBuilder, then a jUnit XML format is appended to
that StringBuilder.
print_report : Vector Test_Result -> Suite_Config -> (StringBuilder | Nothing) -> Nothing
print_report (test_results : Vector Test_Result) (config : Suite_Config) (builder : (StringBuilder | Nothing)) =
distinct_group_names = test_results.map (_.group_name) . distinct
results_per_group = distinct_group_names.fold Map.empty acc-> group_name->
group_results = test_results.filter res->
res.group_name == group_name
assert (group_results.length > 0)
acc.insert group_name group_results
results_per_group.each_with_key group_name-> group_results->
print_group_report group_name group_results config builder
## Prints report for test_results from a single group.
Arguments:
- test_results: Test test_results from a single group
print_group_report : Text -> Vector Test_Result -> Suite_Config -> (StringBuilder|Nothing) -> Nothing
print_group_report group_name test_results config builder =
distinct_groups = test_results.distinct (res-> res.group_name)
assert (distinct_groups.length == 1)
total_time = test_results.fold Duration.zero acc-> res->
acc + res.time_taken
if config.should_output_junit then
builder.append (' <testsuite name="' + (escape_xml spec.name) + '" timestamp="' + (Date_Time.now.format "yyyy-MM-dd'T'HH:mm:ss") + '"')
builder.append (' tests="' + spec.behaviors.length.to_text + '"')
builder.append (' disabled="' + spec.behaviors.filter _.is_pending . length . to_text + '"')
builder.append (' errors="' + spec.behaviors.filter _.is_fail . length . to_text + '"')
assert builder.is_nothing.not "Builder must be specified when JUnit output is enabled"
builder.append (' <testsuite name="' + (escape_xml group_name) + '" timestamp="' + (Date_Time.now.format "yyyy-MM-dd'T'HH:mm:ss") + '"')
builder.append (' tests="' + test_results.length.to_text + '"')
builder.append (' disabled="' + test_results.filter _.is_pending . length . to_text + '"')
builder.append (' errors="' + test_results.filter _.is_fail . length . to_text + '"')
builder.append (' time="' + total_time.total_seconds.to_text + '"')
builder.append ('>\n')
spec.behaviors.reverse.each behavior->
builder.append (' <testcase name="' + (escape_xml behavior.name) + '" time="' + ((behavior.time_taken.total_milliseconds / 1000.0).to_text) + '">')
case behavior.result of
Test_Result.Success -> Nothing
Test_Result.Failure msg details ->
test_results.each result->
builder.append (' <testcase name="' + (escape_xml result.spec_name) + '" time="' + ((result.time_taken.total_milliseconds / 1000.0).to_text) + '">')
case result.spec_result of
Spec_Result.Success -> Nothing
Spec_Result.Failure msg details ->
escaped_message = escape_xml msg . replace '\n' '&#10;'
builder.append ('\n <failure message="' + escaped_message + '">\n')
# We always print the message again as content - otherwise the GitHub action may fail to parse it.
@ -64,46 +119,27 @@ print_report spec config builder =
builder.append '\n\n'
builder.append (escape_xml details)
builder.append '\n </failure>\n'
Test_Result.Pending msg -> builder.append ('\n <skipped message="' + (escape_xml msg) + '"/>\n ')
Spec_Result.Pending msg -> builder.append ('\n <skipped message="' + (escape_xml msg) + '"/>\n ')
builder.append ' </testcase>\n'
builder.append ' </testsuite>\n'
should_print_behavior = config.print_only_failures.not || spec.behaviors.any (b -> b.result.is_fail)
should_print_behavior = config.print_only_failures.not || test_results.any (r -> r.is_fail)
if should_print_behavior then
spec_description =
counts = spec.tests_succeeded.to_text + "/" + spec.tests_executed.to_text
tests_succeeded = test_results.fold 0 acc-> res->
if res.is_success then acc + 1 else acc
tests_failed = test_results.fold 0 acc-> res->
if res.is_fail then acc + 1 else acc
some_test_failed = tests_failed > 0
tests_executed = tests_succeeded + tests_failed
group_description =
counts = tests_succeeded.to_text + "/" + tests_executed.to_text
times = total_time.total_milliseconds.to_text + "ms"
"[" + counts + ", " + times + "]"
IO.println (spec.name + ": " + spec_description)
spec.behaviors.reverse.each behavior->
make_behavior_description behavior =
times = behavior.time_taken.total_milliseconds.to_text + "ms"
"[" + times + "]"
case behavior.result of
Test_Result.Success ->
if config.print_only_failures.not then
IO.println (" - " + behavior.name + " " + make_behavior_description behavior)
Test_Result.Failure msg details ->
IO.println (" - ["+failure_message+"] " + behavior.name + " " + make_behavior_description behavior)
IO.println (" Reason: " + msg)
if details.is_nothing.not then
IO.println details
Test_Result.Pending reason ->
if config.print_only_failures.not then
IO.println (" - [PENDING] " + behavior.name)
IO.println (" Reason: " + reason)
## PRIVATE
Record JUnit PENDING group.
report_pending_group : Text -> Text -> Suite_Config -> (StringBuilder|Nothing) -> Nothing
report_pending_group name reason config builder =
if config.should_output_junit then
builder.append (' <testsuite name="' + (escape_xml name) + '" timestamp="' + (Date_Time.now.format "yyyy-MM-dd'T'HH:mm:ss") + '" time="0">\n')
builder.append (' <testcase name="' + (escape_xml name) + '"><skipped message="' + (escape_xml reason) + '" /></testcase>\n')
builder.append ' </testsuite>\n'
IO.println ("[PENDING] " + name)
IO.println (" Reason: " + reason)
group_name + ": " + "[" + counts + ", " + times + "]"
IO.println <| case some_test_failed of
True -> maybe_red_text ("[FAILED] " + group_description) config
False -> maybe_green_text group_description config
test_results.each result->
print_single_result result config
## PRIVATE
Escape Text for XML

View File

@ -1,36 +1,27 @@
from Standard.Base import all
import project.Spec_Result.Spec_Result
## A wrapper for `Spec_Result` that contains also name of the group and name of the spec.
type Test_Result
## Represents a successful behavioral test.
Success
## PRIVATE
Impl (group_name : Text) (spec_name : Text) (spec_result : Spec_Result) (time_taken : Duration)
## Represents a failing behavioral test.
## PRIVATE
Render as Test_Result as Text.
to_text self =
"'" + self.group_name + "' '" + self.spec_name + "': " + self.spec_result.to_text
Arguments:
- message: The reason why the test failed.
- details: Additional context of the error, for example the stack trace.
Failure message details=Nothing
## Was the test pending?
is_pending self =
self.spec_result.is_pending
## Represents a pending behavioral test.
## Was the test successful?
is_success self =
self.spec_result.is_success
Arguments:
- reason: Text describing why the test is pending.
Pending reason
## Checks if the Test_Result is pending.
is_pending : Boolean
is_pending self = case self of
Test_Result.Pending _ -> True
_ -> False
## Checks if the Test_Result is a failure.
is_fail : Boolean
is_fail self = case self of
Test_Result.Failure _ _ -> True
_ -> False
## Checks if the Test_Result is a success.
is_success : Boolean
is_success self = case self of
Test_Result.Success -> True
_ -> False
## Was the test a failure?
is_fail self =
self.spec_result.is_fail

View File

@ -1,90 +0,0 @@
from Standard.Base import all
import Standard.Base.Runtime.State
import project.Suite_Config.Suite_Config
import project.Test_Reporter
polyglot java import java.lang.StringBuilder
type Test_Suite
## PRIVATE
The top-level entry point for a test suite.
Arguments:
- config: Suite_Config controlloing the test run.
- specs: The specs contained within the test suite.
- builder: StringBuilder for JUnit output.
- skipped_groups: Count of skipped groups.
Value config specs builder skipped_groups
## Creates a new test group, describing properties of the object
described by `self`.
Arguments:
- specs: An action encapsulating a number of test specs or groups.
> Example
Building a basic test suite.
from Standard.Test import Test, Test_Suite
example_run_main = Test_Suite.run_main <|
Test.group "Number" <|
Test.specify "should define addition" <|
2+3 . should_equal 5
Test.specify "should define multiplication" <|
2*3 . should_equal 6
run_main : Any -> Nothing
run_main ~specs =
config = Suite_Config.from_environment
r = Test_Suite.run specs config
IO.println r.tests_succeeded.to_text+" tests succeeded."
IO.println r.tests_failed.to_text+" tests failed."
IO.println r.tests_pending.to_text+" tests skipped."
IO.println r.skipped_groups.to_text+" groups of tests skipped."
code = if r.is_fail then 1 else 0
System.exit code
## Creates a new test group, describing properties of the object
described by `self`.
Arguments:
- specs: An action encapsulating a number of test specs or groups.
> Example
Building a basic test suite.
from Standard.Test import Test, Test_Suite
example_run = Test_Suite.run <|
Test.group "Number" <|
Test.specify "should define addition" <|
2+3 . should_equal 5
Test.specify "should define multiplication" <|
2*3 . should_equal 6
run : Any -> Suite_Config -> Any
run ~specs config =
builder = if config.should_output_junit then StringBuilder.new else Nothing
Test_Reporter.wrap_junit_testsuites config builder <|
State.run Test_Suite (Test_Suite.Value config List.Nil builder 0) <|
specs
State.get Test_Suite
## PRIVATE
Checks if the suite contains any failures, and hence fails itself.
is_fail : Boolean
is_fail self = self.specs.any .is_fail
## Number of tests that passed.
tests_succeeded : Integer
tests_succeeded self = self.specs.map .tests_succeeded . to_vector . compute Statistic.Sum . floor
## Number of tests that failed.
tests_failed : Integer
tests_failed self = self.specs.map .tests_failed . to_vector . compute Statistic.Sum . floor
## Number of tests that were skipped.
tests_pending : Integer
tests_pending self = self.specs.map .tests_pending . to_vector . compute Statistic.Sum . floor

View File

@ -1,10 +0,0 @@
name: Test_New
namespace: Standard
version: 0.0.0-dev
license: APLv2
authors:
- name: Enso Team
email: contact@enso.org
maintainers:
- name: Enso Team
email: contact@enso.org

View File

@ -1,15 +0,0 @@
from Standard.Base import all
import Standard.Base.Runtime.Context
import project.Test.Test
## PRIVATE
Runs the action twice, once with the Output context enabled and once with it
disabled, to check that the behaviour is the same regardless of context.
run_with_and_without_output ~action =
Context.Output.with_enabled <|
Test.with_clue "(normal mode - Output context enabled) " <|
action
Context.Output.with_disabled <|
Test.with_clue "(dry run - Output context disabled) " <|
action

View File

@ -1,660 +0,0 @@
from Standard.Base import all
import Standard.Base.Errors.Common.No_Such_Method
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import project.Spec_Result.Spec_Result
import project.Test.Test
## Expect a function to fail with the provided dataflow error.
Arguments:
- matcher: The expected type of dataflow error contained in `self`.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
- unwrap_errors: If true, remove any wrapping errors from the result before
checking against the expected warning.
> Example
Assert that a computation should return an error of a given type.
import Standard.Examples
from Standard.Test import Test
example_should_fail_with =
Examples.throw_error . should_fail_with Examples.My_Error
Any.should_fail_with : Any -> Integer -> Boolean -> Spec_Result
Any.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
_ = unwrap_errors
loc = Meta.get_source_location 1+frames_to_skip
matcher_text = matcher . to_text
Test.fail ("Expected an error " + matcher_text + " but no error occurred, instead got: " + self.to_text + " (at " + loc + ").")
## Expect a function to fail with the provided dataflow error.
Arguments:
- matcher: The expected type of dataflow error contained in `self`.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
- unwrap_errors: If true, remove any wrapping errors from the result before
checking against the expected warning.
> Example
Assert that a computation should return an error of a given type.
import Standard.Examples
from Standard.Test import Test
example_should_fail_with =
Examples.throw_error . should_fail_with Examples.My_Error
Error.should_fail_with : Any -> Integer -> Boolean -> Spec_Result
Error.should_fail_with self matcher frames_to_skip=0 unwrap_errors=True =
unwrap_maybe error = if unwrap_errors then Error.unwrap error else error
caught = unwrap_maybe self.catch
if caught == matcher || caught.is_a matcher then Nothing else
loc = Meta.get_source_location 2+frames_to_skip
matcher_text = matcher . to_text
Test.fail ("Expected error "+matcher_text+", but error " + caught.to_text + " has been returned (at " + loc + ").")
## Asserts that `self` value is equal to the expected value.
Arguments:
- that: The value to check `self` for equality with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should equal another,
import Standard.Examples
from Standard.Test import Test
example_should_equal = Examples.add_1_to 1 . should_equal 2
Any.should_equal : Any -> Integer -> Spec_Result
Any.should_equal self that frames_to_skip=0 = case self == that of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
additional_comment = case self of
_ : Vector -> case that of
_ : Vector ->
case self.length == that.length of
True ->
diff = self.zip that . index_of p->
p.first != p.second
"; first difference at index " + diff.to_text + " "
False -> "; lengths differ (" + self.length.to_text + " != " + that.length.to_text + ") "
_ -> ""
_ -> ""
msg = self.pretty + " did not equal " + that.pretty + additional_comment + " (at " + loc + ")."
Test.fail msg
## Asserts that `self` value is equal to the expected type value.
Arguments:
- that: The type to check `self` for equality with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that some type is equal to another.,
import Standard.Examples
from Standard.Test import Test
example_should_equal = Examples.some_type . should_equal_type Vector
Any.should_equal_type : Any -> Integer -> Spec_Result
Any.should_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that) of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did not equal type " + that.to_text + " (at " + loc + ")."
Test.fail msg
## Added so that dataflow errors are not silently lost.
Error.should_equal_type self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value is not equal to the expected value.
Arguments:
- that: The value to check `self` for equality with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should equal another,
import Standard.Examples
from Standard.Test import Test
example_should_not_equal = Examples.add_1_to 1 . should_not_equal 2
Any.should_not_equal : Any -> Integer -> Spec_Result
Any.should_not_equal self that frames_to_skip=0 = case self != that of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did equal " + that.to_text + " (at " + loc + ")."
Test.fail msg
## Added so that dataflow errors are not silently lost.
Error.should_not_equal self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value is not equal to the expected type value.
Arguments:
- that: The type to check `self` for equality with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that some type is equal to another.,
import Standard.Examples
from Standard.Test import Test
example_should_not_equal = Examples.some_type . should_not_equal_type Vector
Any.should_not_equal_type : Any -> Integer -> Spec_Result
Any.should_not_equal_type self that frames_to_skip=0 = case (self.is_same_object_as that . not) of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did equal type " + that.to_text + " (at " + loc + ")."
Test.fail msg
## Added so that dataflow errors are not silently lost.
Error.should_not_equal_type self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value is a Text value and starts with `that`.
Arguments:
- that: The value to check `self` starts with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should start with another.
from Standard.Test import Test
example_should_start_with = "Hello World!" . should_start_with "Hello"
Any.should_start_with : Text -> Integer -> Spec_Result
Any.should_start_with self that frames_to_skip=0 = case self of
_ : Text -> if self.starts_with that then Spec_Result.Success else
loc = Meta.get_source_location 3+frames_to_skip
msg = self.to_text + " does not start with " + that.to_text + " (at " + loc + ")."
Test.fail msg
_ ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " is not a `Text` value (at " + loc + ")."
Test.fail msg
## Asserts that `self` value is a Text value and ends with `that`.
Arguments:
- that: The value to check `self` ends with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should end with another.
from Standard.Test import Test
example_should_end_with = "Hello World!" . should_end_with "ld!"
Any.should_end_with : Text -> Integer -> Spec_Result
Any.should_end_with self that frames_to_skip=0 = case self of
_ : Text -> if self.ends_with that then Spec_Result.Success else
loc = Meta.get_source_location 3+frames_to_skip
msg = self.to_text + " does not end with " + that.to_text + " (at " + loc + ")."
Test.fail msg
_ ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " is not a `Text` value (at " + loc + ")."
Test.fail msg
## Asserts that `self` value is a Text value and starts with `that`.
Arguments:
- that: The value to check `self` starts with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should start with another.
from Standard.Test import Test
example_should_start_with = "Hello World!" . should_start_with "Hello"
Error.should_start_with : Any -> Integer -> Spec_Result
Error.should_start_with self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value is a Text value and ends with `that`.
Arguments:
- that: The value to check `self` ends with.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one value should end with another.
from Standard.Test import Test
example_should_end_with = "Hello World!" . should_end_with "ld!"
Error.should_end_with : Any -> Integer -> Spec_Result
Error.should_end_with self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value is equal to the expected value.
Arguments:
- _: The value to check `self` for equality with.
> Example
Assert that one value should equal another,
import Standard.Examples
from Standard.Test import Test
example_should_equal = Examples.add_1_to 1 . should_equal 2
Error.should_equal : Any -> Integer -> Spec_Result
Error.should_equal self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` is within `epsilon` from `that`.
Arguments:
- that: The value to compare `self` for equality with.
- epsilon: The epislon for comparing two float numbers.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Compare two float values.
from Standard.Test import Test
example_should_equal = 1.1 . should_equal 1.1
> Example
Compare two float values with an epsilon (tolerance).
from Standard.Test import Test
example_should_equal =
1.00000001 . should_equal 1.00000002 epsilon=0.0001
Number.should_equal : Float -> Float -> Integer -> Spec_Result
Number.should_equal self that epsilon=0 frames_to_skip=0 =
matches = case that of
_ : Number -> self.equals that epsilon
_ -> False
case matches of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2+frames_to_skip
msg = self.to_text + " did not equal " + that.to_text + " (at " + loc + ")."
Test.fail msg
## Asserts that `self` value is not an error.
It returns the original value, so that it can be inspected further.
Arguments:
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that a given action did not result in errors or warnings.
"foobar".write (enso_project.data / "f.txt") . should_succeed
Any.should_succeed : Integer -> Any
Any.should_succeed self frames_to_skip=0 =
_ = frames_to_skip
self
## Asserts that `self` value is not an error.
It returns the original value, so that it can be inspected further.
Arguments:
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that a given action did not result in errors or warnings.
"foobar".write (enso_project.data / "f.txt") . should_succeed
Error.should_succeed : Integer -> Any
Error.should_succeed self frames_to_skip=0 =
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Handles an unexpected dataflow error.
Error.should_be_a : Any -> Integer -> Any
Error.should_be_a self typ frames_to_skip=0 =
_ = typ
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that the given `Boolean` is `True`
> Example
Assert that a boolean value is true.
import Standard.Examples
from Standard.Test import Test
example_should_be_true = Examples.get_boolean . should_be_true
Boolean.should_be_true : Spec_Result
Boolean.should_be_true self = case self of
True -> Spec_Result.Success
False ->
loc = Meta.get_source_location 2
Test.fail "Expected False to be True (at "+loc+")."
## Asserts that the given `Boolean` is `True`.
> Example
Assert that a boolean value is true.
import Standard.Examples
from Standard.Test import Test
example_should_be_true = Examples.get_boolean . should_be_true
Error.should_be_true : Spec_Result
Error.should_be_true self = Test.fail_match_on_unexpected_error self 1
## Asserts that the given `Boolean` is `False`
> Example
Assert that a boolean value is false.
import Standard.Examples
from Standard.Test import Test
example_should_be_false = Examples.get_boolean . should_be_false
Boolean.should_be_false : Spec_Result
Boolean.should_be_false self = case self of
True ->
loc = Meta.get_source_location 2
Test.fail "Expected True to be False (at "+loc+")."
False -> Spec_Result.Success
## Asserts that the given `Boolean` is `False`
> Example
Assert that a boolean value is false.
import Standard.Examples
from Standard.Test import Test
example_should_be_false = Examples.get_boolean . should_be_false
Error.should_be_false : Spec_Result
Error.should_be_false self = Test.fail_match_on_unexpected_error self 1
## Asserts that a value is of a given type.
Arguments:
- typ: The type to assert that `self` is a value of.
> Examples
Assert that 1 is of type Boolean.
from Standard.Test import Test
example_should_be_a = 1.should_be_a Boolean
Any.should_be_a : Any -> Spec_Result
Any.should_be_a self typ =
loc = Meta.get_source_location 1
fail_on_wrong_arg_type =
Panic.throw <|
Illegal_Argument.Error "typ ("+typ.to_display_text+") must either be a type or a constructor. Use `should_equal` for value equality test instead."
case Meta.meta typ of
c : Meta.Constructor -> case Meta.meta self of
a : Meta.Atom ->
if a.constructor == c then Spec_Result.Success else
expected_type = Meta.get_qualified_type_name typ
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value of type "+actual_type+", built with constructor "+a.constructor.name+" instead (at "+loc+")."
Test.fail message
_ ->
expected_type = Meta.get_qualified_type_name typ
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of type "+expected_type+", built with constructor "+c.name+", but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
_ : Meta.Type ->
ok = self.is_a typ || self==typ
if ok then Spec_Result.Success else
expected_type = Meta.get_qualified_type_name typ
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of type "+expected_type+" but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
# Workaround for 0-argument atom constructors which 'unapplies' them.
atom : Meta.Atom ->
ctor = atom . constructor
if ctor.fields.not_empty then fail_on_wrong_arg_type else
self.should_be_a (ctor.value ...)
_ : Meta.Polyglot ->
ok = self.is_a typ
if ok then Spec_Result.Success else
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of Java class "+typ.to_text+" but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
Meta.Primitive.Value (b : Boolean) ->
ok = self == b
if ok then Spec_Result.Success else
actual_type = Meta.get_qualified_type_name self
message = "Expected a value of "+typ.to_text+" but got a value of type "+actual_type+" instead (at "+loc+")."
Test.fail message
_ -> fail_on_wrong_arg_type
## Asserts that `self` value contains the same elements as `that`.
It only checks that all elements from one collection are also present in the
other one. Arities of elements are not checked, so the collections can still
differ in length by containing duplicate elements.
It will work on any collection which supports the methods
`each : (Any -> Nothing) -> Any` and `contains : Any -> Boolean`.
Arguments:
- that: The collection to compare.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one vector should contain the same elements as another.
import Standard.Examples
from Standard.Test import Test
example_should_equal = [1, 2] . should_contain_the_same_elements_as [2, 1]
Any.should_contain_the_same_elements_as : Any -> Integer -> Spec_Result
Any.should_contain_the_same_elements_as self that frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
that.each element->
if self.contains element . not then
msg = "The collection (" + self.to_text + ") did not contain "+element.to_text+" (at " + loc + ")."
Test.fail msg
self.each element->
if that.contains element . not then
msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + loc + ")."
Test.fail msg
Spec_Result.Success
## Asserts that `self` value contains the same elements as `that`.
It only checks that all elements from one collection are also present in the
other one. Arities of elements are not checked, so the collections can still
differ in length by containing duplicate elements.
It will work on any collection which supports the methods
`each : (Any -> Nothing) -> Any` and `contains : Any -> Boolean`.
Arguments:
- _: The collection to compare.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one vector should contain the same elements as another.
import Standard.Examples
from Standard.Test import Test
example_should_equal = [1, 2] . should_contain_the_same_elements_as [2, 1]
Error.should_contain_the_same_elements_as : Any -> Integer -> Spec_Result
Error.should_contain_the_same_elements_as self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value contains only elements in `that`.
It checks that all elements from `self` are also present in `that`. It does
not require that all elements of `that` are contained in `self`. Arities of
elements are not checked, so `self` may still contain more elements than
`that` by containing duplicates.
It will work on any collection which supports the methods
`each : (Any -> Nothing) -> Any` and `contains : Any -> Boolean`.
Arguments:
- that: The collection to compare.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one vector should contain only elements in another.
import Standard.Examples
from Standard.Test import Test
example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4]
Any.should_only_contain_elements_in : Any -> Integer -> Spec_Result
Any.should_only_contain_elements_in self that frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
self.each element->
if that.contains element . not then
msg = "The collection contained an element ("+element.to_text+") which was not expected (at " + loc + ")."
Test.fail msg
Spec_Result.Success
## Asserts that `self` value contains only elements in `that`.
It checks that all elements from `self` are also present in `that`. It does
not require that all elements of `that` are contained in `self`. Arities of
elements are not checked, so the collections can still differ in length by
containing duplicate elements.
It will work on any collection which supports the methods
`each : (Any -> Nothing) -> Any` and `contains : Any -> Boolean`.
Arguments:
- that: The collection to compare.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
> Example
Assert that one vector should contain only elements in another.
import Standard.Examples
from Standard.Test import Test
example_should_equal = [1, 2] . should_only_contain_elements_in [1, 2, 3, 4]
Error.should_only_contain_elements_in : Any -> Integer -> Spec_Result
Error.should_only_contain_elements_in self that frames_to_skip=0 =
_ = [that]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value contains an element.
Arguments:
- element: The element to check.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
> Example
Assert that a string contains a substring.
from Standard.Test import Test
example_should_equal = "foobar".should_contain "foo"
Any.should_contain : Any -> Integer -> Spec_Result
Any.should_contain self element frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic->
if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else
msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")."
Test.fail msg
if contains_result then Spec_Result.Success else
msg = "The value (" + self.to_text + ") did not contain the element (" + element.to_text + ") (at " + loc + ")."
Test.fail msg
## Asserts that `self` value contains an element.
Arguments:
- element: The element to check.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
> Example
Assert that a string contains a substring.
from Standard.Test import Test
example_should_equal = "foobar".should_contain "foo"
Error.should_contain : Any -> Integer -> Spec_Result
Error.should_contain self element frames_to_skip=0 =
_ = [element]
Test.fail_match_on_unexpected_error self 1+frames_to_skip
## Asserts that `self` value does not contain an element.
Arguments:
- element: The element to check.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
Any.should_not_contain : Any -> Integer -> Spec_Result
Any.should_not_contain self element frames_to_skip=0 =
loc = Meta.get_source_location 1+frames_to_skip
contains_result = Panic.catch No_Such_Method (self.contains element) caught_panic->
if caught_panic.payload.method_name != "contains" then Panic.throw caught_panic else
msg = "The value (" + self.to_text + ") does not support the method `contains` (at " + loc + ")."
Test.fail msg
if contains_result.not then Spec_Result.Success else
msg = "The value (" + self.to_text + ") contained the element (" + element.to_text + "), but it was expected to not contain it (at " + loc + ")."
Test.fail msg
## Asserts that `self` value does not contain an element.
Arguments:
- element: The element to check.
- frames_to_skip (optional, advanced): used to alter the location which is
displayed as the source of this error.
This method delegates to the `contains` method of `self` and will use the
rules of the particular type - be it a `Vector`, `Text` or any custom type
implementing a method `contains : a -> Boolean`.
Error.should_not_contain : Any -> Integer -> Spec_Result
Error.should_not_contain self element frames_to_skip=0 =
_ = [element]
Test.fail_match_on_unexpected_error self 1+frames_to_skip

View File

@ -1,10 +0,0 @@
import project.Problems
import project.Suite.Suite
import project.Test.Test
from project.Extensions import all
export project.Problems
export project.Suite.Suite
export project.Test.Test
from project.Extensions export all

View File

@ -1,144 +0,0 @@
from Standard.Base import all
from project import Test
from project.Extensions import all
## Returns values of warnings attached to the value.
get_attached_warnings v =
Warning.get_all v . map .value
## UNSTABLE
Tests how a specific operation behaves depending on the requested
`Problem_Behavior`.
Arguments:
- action: The action to execute. It takes a `Problem_Behavior` which
specifies whether it should ignore problems, report them as warnings or
raise a dataflow error on the first encountered problem.
- expected_problems: a list of expected problems, in the order that they are
expected to be reported. It should not be empty. The problems are assumed
to be Atoms.
- result_checker: A function which should verify that the result generated by
the action is correct. It does not return anything, instead it should use
the standard testing approach, like `x.should_equal y`.
- unwrap_errors: If true, remove any wrapping errors from errors and warnings
before checking them.
test_problem_handling : (Problem_Behavior -> Any) -> Vector Any -> (Any -> Nothing) -> Boolean -> Nothing
test_problem_handling action expected_problems result_checker unwrap_errors=True =
unwrap_maybe error = if unwrap_errors then Error.unwrap error else error
error_checker error_result =
first_problem = expected_problems.first
first_problem_type = Meta.type_of first_problem
error_result . should_fail_with first_problem_type unwrap_errors=unwrap_errors frames_to_skip=3
(unwrap_maybe error_result.catch) . should_equal first_problem frames_to_skip=3
warnings_checker warnings =
## TODO [RW] we are not checking if there are no duplicate warnings, because the warnings are in fact duplicated - we should figure out how to handle that and then possibly modify the test
Test.with_clue "The warnings were "+warnings.to_text+'.\n' <|
warnings . map unwrap_maybe . should_contain_the_same_elements_as expected_problems frames_to_skip=5
test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=1
## UNSTABLE
Tests how a specific operation behaves depending on the requested
`Problem_Behavior`. A variant that allows more customization over how
expected problems are checked.
Arguments:
- action: The action to execute. It takes a `Problem_Behavior` which
specifies whether it should ignore problems, report them as warnings or
raise a dataflow error on the first encountered problem.
- error_checker: A function which should verify that the returned error is as
expected.
- warnings_checker: A function which should verify that the returned warnings
are as expected.
- result_checker: A function which should verify that the result generated by
the action is correct. It does not return anything, instead it should use
the standard testing approach, like `x.should_equal y`.
test_advanced_problem_handling : (Problem_Behavior -> Any) -> (Any -> Nothing) -> (Vector Any -> Nothing) -> (Any -> Nothing) -> Integer -> Nothing
test_advanced_problem_handling action error_checker warnings_checker result_checker frames_to_skip=0 =
# First, we check the action ignoring any warnings.
result_ignoring = action Problem_Behavior.Ignore
result_checker result_ignoring
get_attached_warnings result_ignoring . should_equal [] frames_to_skip=frames_to_skip+1
# Then, we check the fail-on-first-error mode.
error_result = action Problem_Behavior.Report_Error
error_checker error_result
# Lastly, we check the report warnings mode and ensure that both the result is correct and the warnings are as expected.
result_warning = action Problem_Behavior.Report_Warning
result_checker result_warning
warnings_checker (get_attached_warnings result_warning)
## UNSTABLE
Checks if the provided value does not have any attached problems.
assume_no_problems result =
loc = Meta.get_source_location 1
if result.is_error then
Test.fail "Expected the result to not be an error, but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")."
warnings = get_attached_warnings result
if warnings.not_empty then
Test.fail "Expected the result to not contain any warnings, but it did: "+warnings.to_text+" (at "+loc+")."
## UNSTABLE
Checks if the provided value has a specific warning attached.
It allows other warnings to be present also.
Arguments:
- expected_warning: The expected warning. It can either by a warning type or
a concrete value.
- result: The value to check.
- unwrap_errors: If true, remove any wrapping errors from the result before
checking against the expected warning.
expect_warning : Any -> Any -> Boolean -> Nothing
expect_warning expected_warning result unwrap_errors=True =
unwrap_maybe error = if unwrap_errors then Error.unwrap error else error
loc = Meta.get_source_location 1
if result.is_error then
Test.fail "Expected a warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")."
warnings = get_attached_warnings result . map unwrap_maybe
found = warnings.find if_missing=Nothing x->
(x == expected_warning) || (x.is_a expected_warning)
found.if_nothing <|
Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+loc+').'
## UNSTABLE
Checks if the provided value has a specific warning attached and if there are
no other warnings.
As a utility, it also returns the found warning.
Arguments:
- expected_warning: The expected warning. It can either by a warning type or
a concrete value.
- result: The value to check.
- unwrap_errors: If true, remove any wrapping errors from the result before
checking against the expected warning.
expect_only_warning : Any -> Any -> Boolean -> Any
expect_only_warning expected_warning result unwrap_errors=True =
unwrap_maybe error = if unwrap_errors then Error.unwrap error else error
loc = Meta.get_source_location 1
if result.is_error then
Test.fail "Expected only warning "+expected_warning.to_text+", but a dataflow error has been matched: "+result.catch.to_display_text+" (at "+loc+")."
warnings = get_attached_warnings result . map unwrap_maybe
is_expected x =
(x == expected_warning) || (x.is_a expected_warning)
found = warnings.find if_missing=Nothing is_expected
if found.is_nothing then
Test.fail "Expected the result to contain a warning: "+expected_warning.to_text+", but it did not. The warnings were "+warnings.short_display_text+' (at '+loc+').'
invalid = warnings.filter x-> is_expected x . not
if invalid.not_empty then
Test.fail "Expected the result to contain only the warning: "+found.to_text+", but it also contained: "+invalid.to_text+' (at '+loc+').'
found
## UNSTABLE
Checks if the provided value does _not_ have a warning of the specified type.
It allows other warnings to be present also.
not_expect_warning : Any -> Any -> Nothing
not_expect_warning expected_warning_type result =
warnings = get_attached_warnings result
found = warnings.find if_missing=Nothing x-> x.is_a expected_warning_type
if found.is_nothing.not then
loc = Meta.get_source_location 3
Test.fail 'The result contained a warning it was not supposed to: '+found.to_text+' (at '+loc+').'

View File

@ -1,66 +0,0 @@
private
from Standard.Base import all
import Standard.Base.Runtime.Source_Location.Source_Location
import Standard.Base.Runtime.Stack_Trace_Element
polyglot java import java.lang.NullPointerException
## PRIVATE
find_project_root : File -> File
find_project_root path =
if path.is_nothing then Nothing else
handler _ = Nothing
Panic.catch NullPointerException handler=handler <|
if path.name == "src" then path.parent else
@Tail_Call find_project_root path.parent
## PRIVATE
find_caller_script : Vector Stack_Trace_Element -> File
find_caller_script stack =
find_main idx =
if stack.at idx . name . split "." . last == "main" then idx else
@Tail_Call find_main (idx + 1)
main_index = find_main 0
find_caller idx =
source = stack.at idx . source_location
case source of
_ : Source_Location -> stack.at idx . source_location . file
_ ->
if (idx + 1 == stack.length) then Nothing else
@Tail_Call find_caller (idx + 1)
find_caller main_index
## Holds configuration for a Test_Suite
type Suite_Config
## PRIVATE
Construct a configuration
Arguments:
- output_path: The path to the JUnit XML file to write to. If Nothing, no JUnit XML file
will be written.
Value (print_only_failures : Boolean) (output_path : (File | Nothing)) (use_ansi_colors : Boolean)
## Creates an Suite_Config based off environment and caller location
from_environment : Suite_Config
from_environment =
print_only_failures = Environment.get "REPORT_ONLY_FAILED" != Nothing
junit_folder = Environment.get "ENSO_TEST_JUNIT_DIR"
use_ansi_colors = Environment.get "ENSO_TEST_ANSI_COLORS" . is_nothing . not
results_path = if junit_folder.is_nothing then Nothing else
caller_script = find_caller_script Runtime.get_stack_trace
project_root = find_project_root caller_script
case project_root.is_error || project_root.is_nothing of
True ->
IO.println "Unable to determine root project path. JUnit output disabled."
Nothing
False ->
(File.new junit_folder) / project_root.name / "JUnit.xml"
Suite_Config.Value print_only_failures results_path use_ansi_colors
## Should the results be written to JUnit XML file.
should_output_junit self =
self.output_path.is_nothing.not

View File

@ -1,153 +0,0 @@
from Standard.Base import all
from Standard.Base.Errors.Common import Uninitialized_State
from Standard.Base.Runtime import State
import project.Clue.Clue
import project.Group.Group
import project.Spec.Spec
import project.Spec_Result.Spec_Result
import project.Suite.Suite
import project.Suite.Suite_Builder
import project.Test_Result.Test_Result
## Contains only static methods
type Test
## Construct a Test Suite object
build : (Suite_Builder -> Any) -> Suite
build fn =
b = Vector.new_builder
fn (Suite_Builder.Impl b)
groups_vec = b.to_vector
Suite.Impl groups_vec
## Expect a function to fail with the provided panic.
Arguments:
- action: The action to evaluate that is expected to fail with a panic.
- matcher: The expected type of the panic thrown by `action`.
> Example
Expect that a computation should panic as part of a test.
import Standard.Examples
from Standard.Test import Test
example_expect_panic_with =
Test.expect_panic_with Examples.throw_panic Examples.My_Error
expect_panic_with : Any -> Any -> Test_Result
expect_panic_with ~action matcher =
res = Panic.recover Any action
case res of
_ ->
loc = Meta.get_source_location 2
return_suffix = if res.is_nothing then "" else "and returned ["+res.to_text+"]"
Test.fail ("Expected a " + matcher.to_text + " to be thrown, but the action succeeded " + return_suffix + " (at "+loc+").")
err = res.catch
if err.is_a matcher then Nothing else
Test.fail ("Expected a " + matcher.to_text + ", but " + err.to_text + " was thrown instead.")
## Expect a function to fail with the provided panic.
An alternative API to `expect_panic_with` where the order of arguments is
more natural - as it allows blocks without reordering the arguments.
Arguments:
- matcher: The expected type of the panic thrown by `action`.
- action: The action to evaluate that is expected to fail with a panic.
> Example
Expect that a computation should panic as part of a test.
import Standard.Examples
from Standard.Test import Test
example_expect_panic_with =
Test.expect_panic_with Examples.My_Error <|
IO.println 'hello'
Examples.throw_panic
IO.println 'this is not reached'
expect_panic : Any -> Any -> Test_Result
expect_panic matcher ~action = Test.expect_panic_with action matcher
## Checks that the provided action returns without any errors or warnings.
If you just want to check for errors, usage of the `.should_succeed`
extension function is preferred.
assert_no_problems value frames_to_skip=0 =
value.catch Any _->
Test.fail_match_on_unexpected_error value 2+frames_to_skip
warnings = Warning.get_all value . map .value
if warnings.not_empty then
loc = Meta.get_source_location 2+frames_to_skip
msg = "The action returned unexpected warnings: " + warnings.to_text + " (at " + loc + ")."
Test.fail msg
## Fail a test with the given message.
Arguments:
- message: The message printed when failing the test.
> Example
Failing a test manually.
from Standard.Test import Test
example_fail = Test.fail "Something went wrong."
fail : Text -> Nothing|Text -> Spec_Result
fail message details=Nothing =
failure = Spec_Result.Failure (Test.enrich_message_with_clue message) details
Panic.throw failure
## PRIVATE
enrich_message_with_clue : Text -> Text
enrich_message_with_clue message =
clue = Panic.catch Uninitialized_State (State.get Clue) handler=(_-> Nothing)
case clue of
Clue.Value add_clue -> add_clue message
_ -> message
## PRIVATE
Reports an unexpected dataflow error has occurred.
fail_match_on_unexpected_error : Error -> Integer -> Nothing
fail_match_on_unexpected_error error frames_to_skip =
payload = error.catch
loc = Meta.get_source_location 1+frames_to_skip
msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + loc + ")."
Test.fail msg+'\n'+error.get_stack_trace_text
## Executes the block of code passed as behavior and adds a clue modifier which
changes how assertion failures are reported.
Nesting with_clue invocations results in clue aggregation.
Arguments:
- clue: either a text which gets prepended to the failure or a function which transforms the failure message
- behavior: the behavior to test
> Example
Add a clue to a test
from Standard.Test import Test, Test_Suite
import Standard.Test.Extensions
main = Test_Suite.run_main <|
Test.group "Tests" <|
Test.specify "some property" <|
xs = Vector.new 100 (n -> n)
xs.each x->
Test.with_clue ("["+x.to_text+"] ") <|
x . should_equal 0
with_clue : Text|(Text -> Text) -> Any -> Any
with_clue ~clue ~behavior =
add_clue x = case clue of
_ : Text -> clue + x
_ : Function -> clue x
prev_clue = State.get Clue
next_clue = case prev_clue of
Clue.Value prev_add_clue -> (x -> prev_add_clue (add_clue x))
_ -> add_clue
State.put Clue (Clue.Value next_clue)
result = behavior
State.put Clue prev_clue
result

View File

@ -1,22 +0,0 @@
from Standard.Base import all
polyglot java import org.enso.base.Environment_Utils
## ADVANCED
UNSTABLE
Runs a given action with an environment variable modified to a given value.
The environment variable is restored to its original value after the action.
The environment variable override is only visible to the Enso
`Environment.get` method, the environment as seen from a direct
`System.getenv` Java call remains unchanged.
unsafe_with_environment_override : Text -> Text -> Any -> Any
unsafe_with_environment_override key value ~action =
## This has to be done in Enso, not in Java, due to the bug: https://github.com/enso-org/enso/issues/7117
If done in Java, Enso test functions do not work correctly, because they cannot access State.
old_value = Environment_Utils.getOverride key
restore_previous =
if old_value.is_nothing then Environment_Utils.removeOverride key else Environment_Utils.setOverride key old_value
Panic.with_finalizer restore_previous <|
Environment_Utils.setOverride key value
action

View File

@ -1,148 +0,0 @@
private
from Standard.Base import all
import Standard.Base.Runtime.Context
from Standard.Base.Runtime import assert
import project.Spec_Result.Spec_Result
import project.Suite_Config.Suite_Config
import project.Test.Test
import project.Test_Result.Test_Result
polyglot java import java.lang.StringBuilder
## PRIVATE
Write the JUnit XML header.
wrap_junit_testsuites : Suite_Config -> (StringBuilder|Nothing) -> Any -> Nothing
wrap_junit_testsuites config builder ~action =
if config.should_output_junit then
builder.append '<?xml version="1.0" encoding="UTF-8"?>\n'
builder.append '<testsuites>\n'
result = action
if config.should_output_junit then
builder.append '</testsuites>\n'
Context.Output.with_enabled <|
config.output_path.parent.create_directory
builder.toString.write config.output_path
result
red text =
'\u001b[31;1m' + text + '\u001b[0m'
green text =
'\u001b[32;1m' + text + '\u001b[0m'
maybe_red_text (text : Text) (config : Suite_Config) =
if config.use_ansi_colors then (red text) else text
maybe_green_text (text : Text) (config : Suite_Config) =
if config.use_ansi_colors then (green text) else text
## Print result for a single Spec run
print_single_result : Test_Result -> Suite_Config -> Nothing
print_single_result (test_result : Test_Result) (config : Suite_Config) =
times_suffix =
times = test_result.time_taken.total_milliseconds.to_text + "ms"
"[" + times + "]"
case test_result.spec_result of
Spec_Result.Success ->
if config.print_only_failures.not then
txt = " - " + test_result.spec_name + " " + times_suffix
IO.println (maybe_green_text txt config)
Spec_Result.Failure msg details ->
txt = " - [FAILED] " + test_result.spec_name + " " + times_suffix
IO.println (maybe_red_text txt config)
IO.println (" Reason: " + msg)
if details.is_nothing.not then
IO.println details
Spec_Result.Pending reason ->
if config.print_only_failures.not then
IO.println (" - [PENDING] " + test_result.spec_name)
IO.println (" Reason: " + reason)
## Prints all the results, optionally writing them to a jUnit XML output.
Arguments:
- test_results: Vector of `Test_Result`. Can be empty. Can contain results from multiple
groups.
- builder: StringBuilder or Nothing. If StringBuilder, then a jUnit XML format is appended to
that StringBuilder.
print_report : Vector Test_Result -> Suite_Config -> (StringBuilder | Nothing) -> Nothing
print_report (test_results : Vector Test_Result) (config : Suite_Config) (builder : (StringBuilder | Nothing)) =
distinct_group_names = test_results.map (_.group_name) . distinct
results_per_group = distinct_group_names.fold Map.empty acc-> group_name->
group_results = test_results.filter res->
res.group_name == group_name
assert (group_results.length > 0)
acc.insert group_name group_results
results_per_group.each_with_key group_name-> group_results->
print_group_report group_name group_results config builder
## Prints report for test_results from a single group.
Arguments:
- test_results: Test test_results from a single group
print_group_report : Text -> Vector Test_Result -> Suite_Config -> (StringBuilder|Nothing) -> Nothing
print_group_report group_name test_results config builder =
distinct_groups = test_results.distinct (res-> res.group_name)
assert (distinct_groups.length == 1)
total_time = test_results.fold Duration.zero acc-> res->
acc + res.time_taken
if config.should_output_junit then
assert builder.is_nothing.not "Builder must be specified when JUnit output is enabled"
builder.append (' <testsuite name="' + (escape_xml group_name) + '" timestamp="' + (Date_Time.now.format "yyyy-MM-dd'T'HH:mm:ss") + '"')
builder.append (' tests="' + test_results.length.to_text + '"')
builder.append (' disabled="' + test_results.filter _.is_pending . length . to_text + '"')
builder.append (' errors="' + test_results.filter _.is_fail . length . to_text + '"')
builder.append (' time="' + total_time.total_seconds.to_text + '"')
builder.append ('>\n')
test_results.each result->
builder.append (' <testcase name="' + (escape_xml result.spec_name) + '" time="' + ((result.time_taken.total_milliseconds / 1000.0).to_text) + '">')
case result.spec_result of
Spec_Result.Success -> Nothing
Spec_Result.Failure msg details ->
escaped_message = escape_xml msg . replace '\n' '&#10;'
builder.append ('\n <failure message="' + escaped_message + '">\n')
# We always print the message again as content - otherwise the GitHub action may fail to parse it.
builder.append (escape_xml msg)
if details.is_nothing.not then
## If there are additional details, we print them as well.
builder.append '\n\n'
builder.append (escape_xml details)
builder.append '\n </failure>\n'
Spec_Result.Pending msg -> builder.append ('\n <skipped message="' + (escape_xml msg) + '"/>\n ')
builder.append ' </testcase>\n'
builder.append ' </testsuite>\n'
should_print_behavior = config.print_only_failures.not || test_results.any (r -> r.is_fail)
if should_print_behavior then
tests_succeeded = test_results.fold 0 acc-> res->
if res.is_success then acc + 1 else acc
tests_failed = test_results.fold 0 acc-> res->
if res.is_fail then acc + 1 else acc
some_test_failed = tests_failed > 0
tests_executed = tests_succeeded + tests_failed
group_description =
counts = tests_succeeded.to_text + "/" + tests_executed.to_text
times = total_time.total_milliseconds.to_text + "ms"
group_name + ": " + "[" + counts + ", " + times + "]"
IO.println <| case some_test_failed of
True -> maybe_red_text ("[FAILED] " + group_description) config
False -> maybe_green_text group_description config
test_results.each result->
print_single_result result config
## PRIVATE
Escape Text for XML
escape_xml : Text -> Text
escape_xml input =
input.replace '&' '&amp;' . replace '"' '&quot;' . replace "'" '&apos;' . replace '<' '&lt;' . replace '>' '&gt;'

View File

@ -1,27 +0,0 @@
from Standard.Base import all
import project.Spec_Result.Spec_Result
## A wrapper for `Spec_Result` that contains also name of the group and name of the spec.
type Test_Result
## PRIVATE
Impl (group_name : Text) (spec_name : Text) (spec_result : Spec_Result) (time_taken : Duration)
## PRIVATE
Render as Test_Result as Text.
to_text self =
"'" + self.group_name + "' '" + self.spec_name + "': " + self.spec_result.to_text
## Was the test pending?
is_pending self =
self.spec_result.is_pending
## Was the test successful?
is_success self =
self.spec_result.is_success
## Was the test a failure?
is_fail self =
self.spec_result.is_fail

View File

@ -10,7 +10,6 @@ object Editions {
val standardLibraries: Seq[String] = Seq(
"Standard.Base",
"Standard.Test",
"Standard.Test_New",
"Standard.Table",
"Standard.Database",
"Standard.AWS",

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
import project.S3_Spec

View File

@ -5,7 +5,7 @@ import Standard.Base.Runtime.Ref.Ref
from Standard.AWS import S3, AWS_Credential
from Standard.AWS.Errors import AWS_SDK_Error, More_Records_Available, S3_Error, S3_Bucket_Not_Found
from Standard.Test_New import all
from Standard.Test import all
import enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
from enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup import with_retries

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Common.No_Such_Method
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Index_Out_Of_Bounds
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
type Proxy_Object

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Index_Out_Of_Bounds
import Standard.Base.Errors.Illegal_State.Illegal_State
from Standard.Test_New import all
from Standard.Test import all
Array.method self = 0

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Data.Base_64.Base_64
import Standard.Base.Errors.Encoding_Error.Encoding_Error
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.lang.String as Java_String

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
Boolean.method self = self

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -5,8 +5,8 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.No_Such_Key.No_Such_Key
from Standard.Base.Data.Json import Invalid_JSON
from Standard.Test_New import all
import Standard.Test_New.Spec_Result.Spec_Result
from Standard.Test import all
import Standard.Test.Spec_Result.Spec_Result

View File

@ -6,7 +6,7 @@ import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Common.Unsupported_Argument_Types
import Standard.Base.Runtime.State
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "List" group_builder->

View File

@ -1,7 +1,7 @@
from Standard.Base import all
from Standard.Base.Metadata.Choice import Option
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.util.Locale as JavaLocale

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.No_Such_Key.No_Such_Key
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.nio.file.Path as JavaPath

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Maybe" group_builder->

View File

@ -6,7 +6,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Base.Data.Numbers import Number_Parse_Error
from Standard.Test_New import all
from Standard.Test import all
import project.Data.Round_Spec

View File

@ -5,7 +5,7 @@ polyglot java import org.enso.base.ObjectComparator
polyglot java import org.enso.base.CompareException
from Standard.Test_New import all
from Standard.Test import all
# === Test Resources ===

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Natural Order" group_builder->

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Data.Ordering.Vector_Lexicographic_Order
from Standard.Test_New import all
from Standard.Test import all
type My_Type

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Incomparable_Values
import Standard.Base.Errors.Common.Type_Error
from Standard.Test_New import all
from Standard.Test import all
# === Test Resources ===

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Index_Out_Of_Bounds
import Standard.Base.Errors.Common.Not_Found
from Standard.Test_New import all
from Standard.Test import all
type_spec suite_builder name ctor = suite_builder.group name group_builder->

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.lang.Double

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Illegal_State.Illegal_State
from Standard.Test_New import all
from Standard.Test import all
main =

View File

@ -7,7 +7,7 @@ import Standard.Base.Errors.Common.Unsupported_Argument_Types
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.Illegal_State.Illegal_State
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Range" group_builder->

View File

@ -1,7 +1,7 @@
from Standard.Base import Nothing, Vector, Number, Float, True, False, Regression
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.math.BigInteger

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Incomparable_Values
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.Illegal_State.Illegal_State
from Standard.Test_New import all
from Standard.Test import all
# === Test Resources ===

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Encoding_Error.Encoding_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.lang.String as Java_String

View File

@ -6,7 +6,7 @@ import Standard.Base.Errors.Time_Error.Time_Error
import Standard.Base.Data.Json.Invalid_JSON
import Standard.Base.Data.Numbers.Number_Parse_Error
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =
suite_builder.group "parse" group_builder->

View File

@ -10,7 +10,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Base.Data.Text.Regex.Internal.Replacer import get_lru_size, replacer_cache_lookup
from Standard.Test_New import all
from Standard.Test import all
type Data
Value ~data

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Data.Text.Span.Span
import Standard.Base.Data.Text.Span.Utf_16_Span
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Text.Span" group_builder->

View File

@ -1,7 +1,7 @@
from Standard.Base import all
from Standard.Base.Data.Text.Text_Sub_Range import character_ranges
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Text_Sub_Range_Data" group_builder->

View File

@ -4,7 +4,7 @@ polyglot java import org.enso.base.Text_Utils
polyglot java import org.enso.base.text.CaseFoldedString
polyglot java import com.ibm.icu.text.BreakIterator
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.lang.Exception as JException

View File

@ -11,7 +11,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Base.Data.Text.Text_Sub_Range.Text_Sub_Range import all
from Standard.Base.Data.Index_Sub_Range.Index_Sub_Range import all
from Standard.Test_New import all
from Standard.Test import all
type Auto

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder name create_new_date =

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
main =

View File

@ -3,7 +3,7 @@ import Standard.Base.Errors.Common.Incomparable_Values
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Test_New import all
from Standard.Test import all
import project.Data.Time.Date_Part_Spec

View File

@ -3,7 +3,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Base.Data.Time.Errors import Date_Time_Format_Parse_Error, Suspicious_Date_Time_Format
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.time.format.DateTimeFormatter

View File

@ -3,7 +3,7 @@ import Standard.Base.Errors.Common.Incomparable_Values
import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Test_New import all
from Standard.Test import all
import project.Data.Time.Date_Part_Spec

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Incomparable_Values
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.time.Duration as Java_Duration

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Common.Incomparable_Values
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
import project.Data.Time.Duration_Spec

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Type_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.time.LocalTime

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Time_Error.Time_Error
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.time.ZoneId

View File

@ -1,7 +1,7 @@
from Standard.Base import all
from Standard.Base.Data.Index_Sub_Range import sort_and_merge_ranges
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Vector Slicing Helpers" group_builder->

View File

@ -15,7 +15,7 @@ import Standard.Base.Runtime.Ref.Ref
import Standard.Base.Runtime.State
from Standard.Base.Data.Index_Sub_Range.Index_Sub_Range import While, By_Index, Sample, Every
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.util.ArrayList

View File

@ -3,7 +3,7 @@ import Standard.Base.Errors.Common.Syntax_Error
import Standard.Base.Errors.File_Error.File_Error
from Standard.Base.Runtime import assert
from Standard.Test_New import all
from Standard.Test import all
type Test_Data
Value ~data

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
import project.Semantic.Any_Spec
import project.Semantic.Case_Spec

View File

@ -1,7 +1,7 @@
from Standard.Base import all
import Standard.Base.Errors.Illegal_State.Illegal_State
import Standard.Test_New.Test_Environment
import Standard.Test.Test_Environment
polyglot java import java.lang.Thread

View File

@ -4,8 +4,8 @@ import Standard.Base.Errors.Common.No_Such_Conversion
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Network.HTTP.HTTP_Error.HTTP_Error
from Standard.Test_New import all
import Standard.Test_New.Test_Environment
from Standard.Test import all
import Standard.Test.Test_Environment
import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup

View File

@ -2,8 +2,8 @@ from Standard.Base import all
import Standard.Base.Errors.Common.Not_Found
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
import Standard.Test_New.Test_Environment
from Standard.Test import all
import Standard.Test.Test_Environment
import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
from enso_dev.Base_Tests.Network.Enso_Cloud.Cloud_Tests_Setup import with_retries

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
import project.Network.Enso_Cloud.Enso_Cloud_Spec
import project.Network.Enso_Cloud.Enso_File_Spec

View File

@ -10,7 +10,7 @@ import Standard.Base.Network.HTTP.Request.Request
import Standard.Base.Runtime.Context
from Standard.Base.Data.Enso_Cloud.Enso_Secret import as_hideable_value
from Standard.Test_New import all
from Standard.Test import all
from Standard.Test.Execution_Context_Helpers import run_with_and_without_output

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -5,7 +5,7 @@ import Standard.Base.Errors.Encoding_Error.Encoding_Error
import Standard.Base.Network.HTTP.Response.Response
from Standard.Test_New import all
from Standard.Test import all
main =
suite = Test.build suite_builder->

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Syntax_Error
import Standard.Base.Network.HTTP.Request.Request
import Standard.Base.Network.HTTP.Request_Body.Request_Body
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -12,8 +12,8 @@ import Standard.Base.Network.Proxy.Proxy
import Standard.Base.Runtime.Context
from Standard.Base.Network.HTTP import resolve_headers
from Standard.Test_New import all
from Standard.Test_New.Execution_Context_Helpers import run_with_and_without_output
from Standard.Test import all
from Standard.Test.Execution_Context_Helpers import run_with_and_without_output
type Test_Type
Aaa (s:Text)

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Syntax_Error
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Network.HTTP.Request.Request
from Standard.Test_New import all
from Standard.Test import all
import project.Network.Enso_Cloud.Cloud_Tests_Setup.Cloud_Tests_Setup
from project.Network.Enso_Cloud.Cloud_Tests_Setup import with_retries

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
import Standard.Base.Random.Random_Generator
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Random" group_builder->

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
import Standard.Base.Errors.Common.Type_Error

View File

@ -3,7 +3,7 @@ from Standard.Base import all
from Standard.Base.Errors.Common import Assertion_Error
from Standard.Base.Errors.Common import Type_Error
from Standard.Test_New import all
from Standard.Test import all
foreign js js_check = """

View File

@ -1,4 +1,4 @@
from Standard.Test_New import all
from Standard.Test import all
type Generator

View File

@ -3,7 +3,7 @@ from Standard.Base import all
import Standard.Base.Runtime.Ref.Ref
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
from Standard.Test_New import all
from Standard.Test import all
type Lazy

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Errors.Illegal_State.Illegal_State
import Standard.Base.Runtime.Managed_Resource.Managed_Resource
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Managed_Resource" group_builder->

View File

@ -4,7 +4,7 @@ import Standard.Base.Errors.Common.Not_Invokable
import Standard.Base.Runtime.Ref.Ref
from Standard.Test_New import all
from Standard.Test import all
my_function (xyz : Integer = Missing_Required_Argument.ensure_present "xyz") (y : Integer = 100) =

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import Standard.Base.Runtime.Ref.Ref
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Refs" group_builder->

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
type My_Type

View File

@ -3,7 +3,7 @@ from Standard.Base import all
import Standard.Base.Runtime.State
import Standard.Base.Errors.Common.Unsupported_Argument_Types
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "State" group_builder->

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
from project.Semantic.Definitions.Any_Types import all

View File

@ -11,7 +11,7 @@ polyglot java import java.util.AbstractList
polyglot java import java.util.ArrayList
polyglot java import java.util.List as Java_List
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder = suite_builder.group "Pattern Matches" group_builder->

View File

@ -6,7 +6,7 @@ import project.Semantic.Conversion.Methods
import project.Semantic.Conversion.Types
import project.Semantic.Conversion_Use.Hello
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.lang.Object

View File

@ -2,7 +2,7 @@ from Standard.Base import all
import project.Semantic.Deep_Export.Internal
from Standard.Test_New import all
from Standard.Test import all
add_specs suite_builder =

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
from project.Semantic.Default_Args_Spec.Box import all

View File

@ -1,6 +1,6 @@
from Standard.Base import all
from Standard.Test_New import all
from Standard.Test import all
polyglot java import java.math.BigInteger as Java_Big_Integer

Some files were not shown because too many files have changed in this diff Show More