Class: RBS::Test::Tester::MethodCallTester
- Inherits:
-
Object
- Object
- RBS::Test::Tester::MethodCallTester
- Defined in:
- lib/rbs/test/tester.rb
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#sample_size ⇒ Object
readonly
Returns the value of attribute sample_size.
-
#self_class ⇒ Object
readonly
Returns the value of attribute self_class.
-
#unchecked_classes ⇒ Object
readonly
Returns the value of attribute unchecked_classes.
Instance Method Summary collapse
- #call(receiver, trace) ⇒ Object
- #check ⇒ Object
- #env ⇒ Object
- #format_method_name(name) ⇒ Object
-
#initialize(self_class, builder, definition, kind:, sample_size:, unchecked_classes:) ⇒ MethodCallTester
constructor
A new instance of MethodCallTester.
Constructor Details
#initialize(self_class, builder, definition, kind:, sample_size:, unchecked_classes:) ⇒ MethodCallTester
Returns a new instance of MethodCallTester.
121 122 123 124 125 126 127 128 |
# 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 ⇒ Object (readonly)
Returns the value of attribute builder.
116 117 118 |
# File 'lib/rbs/test/tester.rb', line 116 def builder @builder end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
115 116 117 |
# File 'lib/rbs/test/tester.rb', line 115 def definition @definition end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
117 118 119 |
# File 'lib/rbs/test/tester.rb', line 117 def kind @kind end |
#sample_size ⇒ Object (readonly)
Returns the value of attribute sample_size.
118 119 120 |
# File 'lib/rbs/test/tester.rb', line 118 def sample_size @sample_size end |
#self_class ⇒ Object (readonly)
Returns the value of attribute self_class.
114 115 116 |
# File 'lib/rbs/test/tester.rb', line 114 def self_class @self_class end |
#unchecked_classes ⇒ Object (readonly)
Returns the value of attribute unchecked_classes.
119 120 121 |
# File 'lib/rbs/test/tester.rb', line 119 def unchecked_classes @unchecked_classes end |
Instance Method Details
#call(receiver, trace) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# 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 ⇒ Object
134 135 136 |
# 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 ⇒ Object
130 131 132 |
# File 'lib/rbs/test/tester.rb', line 130 def env builder.env end |
#format_method_name(name) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/rbs/test/tester.rb', line 138 def format_method_name(name) case kind when :instance "##{name}" when :singleton ".#{name}" end end |