Class: RBS::Test::Tester::MethodCallTester
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/test/tester.rb |
Class Method Summary
Instance Attribute Summary
- #builder readonly
- #definition readonly
- #kind readonly
- #sample_size readonly
- #self_class readonly
- #unchecked_classes readonly
Instance Method Summary
Constructor Details
.new(self_class, builder, definition, kind:, sample_size:, unchecked_classes:) ⇒ MethodCallTester
# File 'lib/rbs/test/tester.rb', line 121
def initialize(self_class, builder, definition, kind:, sample_size:, unchecked_classes:) @self_class = self_class @definition = definition @builder = builder @kind = kind @sample_size = sample_size @unchecked_classes = unchecked_classes end
Instance Attribute Details
#builder (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 116
attr_reader :builder
#definition (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 115
attr_reader :definition
#kind (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 117
attr_reader :kind
#sample_size (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 118
attr_reader :sample_size
#self_class (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 114
attr_reader :self_class
#unchecked_classes (readonly)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 119
attr_reader :unchecked_classes
Instance Method Details
#call(receiver, trace)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 147
def call(receiver, trace) method_name = trace.method_name method = definition.methods[method_name] if method RBS.logger.debug { "Type checking `#{self_class}#{format_method_name(method_name)}`..."} errors = check.overloaded_call(method, method_name, trace, errors: []) if errors.empty? RBS.logger.debug { "No type error detected 👏" } else RBS.logger.debug { "Detected type error 🚨" } raise TypeError.new(errors) end else RBS.logger.error { "Type checking `#{self_class}#{method_name}` call but no method found in definition" } end end
#check
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 134
def check @check ||= TypeCheck.new(self_class: self_class, builder: builder, sample_size: sample_size, unchecked_classes: unchecked_classes) end
#env
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 130
def env builder.env end
#format_method_name(name)
[ GitHub ]# File 'lib/rbs/test/tester.rb', line 138
def format_method_name(name) case kind when :instance "##{name}" when :singleton ".#{name}" end end