Class: TLDR::Test
- Inherits:
-
Struct
- Object
- Struct
- TLDR::Test
- Defined in:
- lib/tldr/value/test.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#test_class ⇒ Object
Returns the value of attribute test_class.
Instance Method Summary collapse
-
#covers_line?(l) ⇒ Boolean
Test exact match starting line condition first to save us a potential re-parsing to look up end_line.
-
#end_line ⇒ Object
Memoizing at call time, because re-parsing isn’t free and isn’t usually necessary.
- #group? ⇒ Boolean
-
#initialize(*args) ⇒ Test
constructor
A new instance of Test.
Constructor Details
#initialize(*args) ⇒ Test
Returns a new instance of Test.
5 6 7 8 9 |
# File 'lib/tldr/value/test.rb', line 5 def initialize(*args) super @file, @line = SorbetCompatibility.unwrap_method(test_class.instance_method(method_name)).source_location @location = Location.new(file, line) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/tldr/value/test.rb', line 3 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/tldr/value/test.rb', line 3 def line @line end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/tldr/value/test.rb', line 3 def location @location end |
#method_name ⇒ Object
Returns the value of attribute method_name
2 3 4 |
# File 'lib/tldr/value/test.rb', line 2 def method_name @method_name end |
#test_class ⇒ Object
Returns the value of attribute test_class
2 3 4 |
# File 'lib/tldr/value/test.rb', line 2 def test_class @test_class end |
Instance Method Details
#covers_line?(l) ⇒ Boolean
Test exact match starting line condition first to save us a potential re-parsing to look up end_line
20 21 22 |
# File 'lib/tldr/value/test.rb', line 20 def covers_line? l line == l || (l >= line && l <= end_line) end |
#end_line ⇒ Object
Memoizing at call time, because re-parsing isn’t free and isn’t usually necessary
12 13 14 15 16 17 |
# File 'lib/tldr/value/test.rb', line 12 def end_line @end_line ||= begin test_method = SorbetCompatibility.unwrap_method(test_class.instance_method(method_name)) RubyVM::AbstractSyntaxTree.of(test_method).last_lineno end end |
#group? ⇒ Boolean
24 25 26 |
# File 'lib/tldr/value/test.rb', line 24 def group? false end |