Class: RubyIndexer::ConstantTest

Inherits:
TestCase
  • Object
show all
Defined in:
lib/ruby_indexer/test/constant_test.rb

Instance Method Summary collapse

Methods inherited from TestCase

#setup

Instance Method Details

#test_comments_for_constantsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/ruby_indexer/test/constant_test.rb', line 69

def test_comments_for_constants
  index("    # FOO comment\n    FOO = 1\n\n    class A\n      # A::FOO comment\n      FOO = 1\n\n      # ::BAR comment\n      ::BAR = 1\n    end\n\n    # A::BAZ comment\n    A::BAZ = 1\n  RUBY\n\n  foo_comment = @index[\"FOO\"].first.comments.join(\"\\n\")\n  assert_equal(\"FOO comment\", foo_comment)\n\n  a_foo_comment = @index[\"A::FOO\"].first.comments.join(\"\\n\")\n  assert_equal(\"A::FOO comment\", a_foo_comment)\n\n  bar_comment = @index[\"BAR\"].first.comments.join(\"\\n\")\n  assert_equal(\"::BAR comment\", bar_comment)\n\n  a_baz_comment = @index[\"A::BAZ\"].first.comments.join(\"\\n\")\n  assert_equal(\"A::BAZ comment\", a_baz_comment)\nend\n")

#test_constant_or_writesObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby_indexer/test/constant_test.rb', line 21

def test_constant_or_writes
  index("    FOO ||= 1\n\n    class ::Bar\n      FOO ||= 2\n    end\n  RUBY\n\n  assert_entry(\"FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:0-0:0-8\")\n  assert_entry(\"Bar::FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:3-2:3-10\")\nend\n")

#test_constant_path_or_writesObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ruby_indexer/test/constant_test.rb', line 54

def test_constant_path_or_writes
  index("    class A\n      FOO ||= 1\n      ::BAR ||= 1\n    end\n\n    A::BAZ ||= 1\n  RUBY\n\n  assert_entry(\"A::FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:1-2:1-10\")\n  assert_entry(\"BAR\", Index::Entry::Constant, \"/fake/path/foo.rb:2-2:2-12\")\n  assert_entry(\"A::BAZ\", Index::Entry::Constant, \"/fake/path/foo.rb:5-0:5-11\")\nend\n")

#test_constant_path_writesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby_indexer/test/constant_test.rb', line 34

def test_constant_path_writes
  index("    class A\n      FOO = 1\n      ::BAR = 1\n\n      module B\n        FOO = 1\n      end\n    end\n\n    A::BAZ = 1\n  RUBY\n\n  assert_entry(\"A::FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:1-2:1-8\")\n  assert_entry(\"BAR\", Index::Entry::Constant, \"/fake/path/foo.rb:2-2:2-10\")\n  assert_entry(\"A::B::FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:5-4:5-10\")\n  assert_entry(\"A::BAZ\", Index::Entry::Constant, \"/fake/path/foo.rb:9-0:9-9\")\nend\n")

#test_constant_writesObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_indexer/test/constant_test.rb', line 8

def test_constant_writes
  index("    FOO = 1\n\n    class ::Bar\n      FOO = 2\n    end\n  RUBY\n\n  assert_entry(\"FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:0-0:0-6\")\n  assert_entry(\"Bar::FOO\", Index::Entry::Constant, \"/fake/path/foo.rb:3-2:3-8\")\nend\n")

#test_variable_path_constants_are_ignoredObject



99
100
101
102
103
104
105
106
# File 'lib/ruby_indexer/test/constant_test.rb', line 99

def test_variable_path_constants_are_ignored
  index("    var::FOO = 1\n    self.class::FOO = 1\n  RUBY\n\n  assert_no_entry\nend\n")