|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative '../support/test_case' |
| 4 | + |
| 5 | +module DEBUGGER__ |
| 6 | + |
| 7 | + class HoverTest < TestCase |
| 8 | + PROGRAM = <<~RUBY |
| 9 | + 1| a = 1 |
| 10 | + 2| b = 2 |
| 11 | + 3| c = 3 |
| 12 | + 4| d = 4 |
| 13 | + 5| e = 5 |
| 14 | + RUBY |
| 15 | + |
| 16 | + def test_hover |
| 17 | + run_protocol_scenario PROGRAM do |
| 18 | + req_set_breakpoints 4 |
| 19 | + req_continue |
| 20 | + assert_hover_result 2, expression: 'b' |
| 21 | + assert_hover_result 3, expression: 'c' |
| 22 | + assert_hover_result 1, expression: 'a' |
| 23 | + req_continue |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + class HoverTest2 < TestCase |
| 29 | + PROGRAM = <<~RUBY |
| 30 | + 1| p 1 |
| 31 | + RUBY |
| 32 | + |
| 33 | + def test_hover |
| 34 | + run_protocol_scenario PROGRAM do |
| 35 | + b = TOPLEVEL_BINDING.dup |
| 36 | + assert_hover_result b.eval('self').method(:p), expression: 'p' |
| 37 | + req_continue |
| 38 | + end |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + class HoverTest3 < TestCase |
| 43 | + PROGRAM = <<~RUBY |
| 44 | + 1| module Abc |
| 45 | + 2| class Def123 |
| 46 | + 3| class Ghi |
| 47 | + 4| def initialize |
| 48 | + 5| @a = 1 |
| 49 | + 6| end |
| 50 | + 7| |
| 51 | + 8| def a |
| 52 | + 9| ::Abc.foo |
| 53 | + 10| ::Abc::Def123.bar |
| 54 | + 11| p @a |
| 55 | + 12| end |
| 56 | + 13| end |
| 57 | + 14| |
| 58 | + 15| def bar |
| 59 | + 16| p :bar1 |
| 60 | + 17| end |
| 61 | + 18| |
| 62 | + 19| def self.bar |
| 63 | + 20| p :bar2 |
| 64 | + 21| end |
| 65 | + 22| end |
| 66 | + 23| |
| 67 | + 24| def self.foo |
| 68 | + 25| p :foo |
| 69 | + 26| end |
| 70 | + 27| end |
| 71 | + 28| |
| 72 | + 29| Abc::Def123.new.bar |
| 73 | + 30| |
| 74 | + 31| ghi = Abc::Def123::Ghi.new |
| 75 | + 32| ghi.a |
| 76 | + RUBY |
| 77 | + |
| 78 | + def test_hover |
| 79 | + run_protocol_scenario PROGRAM do |
| 80 | + req_set_breakpoints 31 |
| 81 | + req_continue |
| 82 | + assert_hover_result Object.const_set('Abc', Module.new), expression: 'Abc' |
| 83 | + assert_hover_result Abc.const_set('Def123', Class.new), expression: 'Abc::Def123' |
| 84 | + assert_hover_result Abc::Def123.const_set('Ghi', Class.new), expression: 'Abc::Def123::Ghi' |
| 85 | + assert_hover_result Abc::Def123::Ghi, expression: 'Abc::Def123::Ghi.new' |
| 86 | + assert_hover_result Abc, expression: '::Abc.foo' |
| 87 | + assert_hover_result Abc::Def123, expression: '::Abc::Def123' |
| 88 | + assert_hover_result Abc::Def123, expression: '::Abc::Def123.bar' |
| 89 | + req_continue |
| 90 | + end |
| 91 | + end |
| 92 | + end |
| 93 | +end |
0 commit comments