Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/rbs/unit_test/type_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ def send_setup(method_type, receiver, method, args, proc)
)
errors = typecheck.method_call(method, method_type, trace, errors: [])

assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, "Call trace does not match with given method type: #{trace.inspect}"
assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, -> { "Call trace does not match with given method type: #{trace.inspect}" }

method_defs = method_defs(method)
all_errors = method_defs.map {|t| typecheck.method_call(method, t.type, trace, errors: [], annotations: t.each_annotation.to_a) }
assert all_errors.any? {|es| es.empty? }, "Call trace does not match one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}"
assert all_errors.any? {|es| es.empty? }, -> { "Call trace does not match one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}" }

raise exception if exception

Expand All @@ -204,11 +204,11 @@ def send_setup(method_type, receiver, method, args, proc)
)
errors = typecheck.method_call(method, method_type, trace, errors: [])

assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, "Call trace does not match with given method type: #{trace.inspect}"
assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, -> { "Call trace does not match with given method type: #{trace.inspect}" }

method_defs = method_defs(method)
all_errors = method_defs.map {|t| typecheck.method_call(method, t.type, trace, errors: [], annotations: t.each_annotation.to_a) }
assert all_errors.any? {|es| es.empty? }, "Call trace does not match one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}"
assert all_errors.any? {|es| es.empty? }, -> { "Call trace does not match one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}" }

# Use `instnace_of?` instead of `is_a?` as we want to check for _the exact exception class_.
assert exception.instance_of? error_type
Expand Down Expand Up @@ -246,7 +246,7 @@ def send_setup(method_type, receiver, method, args, proc)

method_defs = method_defs(method)
all_errors = method_defs.map {|t| typecheck.method_call(method, t.type, trace, errors: [], annotations: t.each_annotation.to_a) }
assert all_errors.all? {|es| es.size > 0 }, "Call trace unexpectedly matches one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}"
assert all_errors.all? {|es| es.size > 0 }, -> { "Call trace unexpectedly matches one of method definitions:\n #{trace.inspect}\n #{method_defs.map(&:type).join(" | ")}" }

result
end
Expand Down
4 changes: 2 additions & 2 deletions sig/unit_test/type_assertions.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ module RBS
type target_type = Types::ClassInstance | Types::ClassSingleton

interface _BaseAssertions
def assert: (untyped, ?String?) -> void
def assert: (untyped, ?(String | ^() -> String)?) -> void

def refute: (untyped, ?String?) -> void

def assert_empty: (untyped, ?String?) -> void
def assert_empty: (untyped, ?(String | ^() -> String)?) -> void

def assert_operator: (untyped, Symbol, *untyped) -> void

Expand Down
Loading