@@ -85,6 +85,33 @@ def test_markup_code
85
85
assert_equal expected , @c2_a . markup_code
86
86
end
87
87
88
+ def test_markup_code_with_line_numbers
89
+ position_comment = "# File #{ @file_name } , line 1"
90
+ tokens = [
91
+ { :line_no => 1 , :char_no => 0 , :kind => :on_comment , :text => position_comment } ,
92
+ { :line_no => 1 , :char_no => position_comment . size , :kind => :on_nl , :text => "\n " } ,
93
+ { :line_no => 2 , :char_no => 0 , :kind => :on_const , :text => 'A' } ,
94
+ { :line_no => 2 , :char_no => 1 , :kind => :on_nl , :text => "\n " } ,
95
+ { :line_no => 3 , :char_no => 0 , :kind => :on_const , :text => 'B' }
96
+ ]
97
+
98
+ @c2_a . collect_tokens
99
+ @c2_a . add_tokens ( *tokens )
100
+
101
+ assert_equal <<-EXPECTED . chomp , @c2_a . markup_code
102
+ <span class="ruby-comment"># File xref_data.rb, line 1</span>
103
+ <span class="ruby-constant">A</span>
104
+ <span class="ruby-constant">B</span>
105
+ EXPECTED
106
+
107
+ @options . line_numbers = true
108
+ assert_equal <<-EXPECTED . chomp , @c2_a . markup_code
109
+ <span class="ruby-comment"># File xref_data.rb</span>
110
+ <span class="line-num">1</span> <span class="ruby-constant">A</span>
111
+ <span class="line-num">2</span> <span class="ruby-constant">B</span>
112
+ EXPECTED
113
+ end
114
+
88
115
def test_markup_code_empty
89
116
assert_equal '' , @c2_a . markup_code
90
117
end
0 commit comments