Skip to content

Commit fa7c0e4

Browse files
committed
Add Ruby tests for bug w.r.t. {Symquo} mismatch after string interp.
1 parent b265abf commit fa7c0e4

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

test/org/opensolaris/opengrok/analysis/ruby/RubyXrefTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.InputStreamReader;
3232
import java.io.OutputStream;
3333
import java.io.PrintStream;
34+
import java.io.StringReader;
3435
import java.io.StringWriter;
3536
import java.io.Writer;
3637
import org.junit.Test;
@@ -71,6 +72,26 @@ public void sampleTest() throws IOException {
7172
assertLinesEqual("Ruby xref", estr, ostr);
7273
}
7374

75+
@Test
76+
public void colonQuoteAfterInterpolation() throws IOException {
77+
final String RUBY_COLON_QUOTE =
78+
"\"from #{logfn}:\"\n";
79+
RubyXref xref = new RubyXref(new StringReader(RUBY_COLON_QUOTE));
80+
81+
StringWriter out = new StringWriter();
82+
xref.write(out);
83+
String xout = out.toString();
84+
85+
final String xexpected = "<a class=\"l\" name=\"1\" href=\"#1\">1</a>"
86+
+ "<span class=\"s\">&quot;from #{</span>"
87+
+ "<a href=\"/source/s?defs=logfn\" "
88+
+ "class=\"intelliWindow-symbol\" "
89+
+ "data-definition-place=\"undefined-in-file\">logfn</a>"
90+
+ "<span class=\"s\">}:&quot;</span>\n" +
91+
"<a class=\"l\" name=\"2\" href=\"#2\">2</a>\n";
92+
assertLinesEqual("Ruby colon-quote", xexpected, xout);
93+
}
94+
7495
private void writeRubyXref(InputStream iss, PrintStream oss)
7596
throws IOException {
7697
oss.print(getHtmlBegin());

test/org/opensolaris/opengrok/analysis/ruby/ruby_xrefres.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,7 @@
183183
<a class="l" name="175" href="#175">175</a><b>end</b>
184184
<a class="l" name="176" href="#176">176</a><b>print</b> <span class="s">&quot;\n&quot;</span>
185185
<a class="l" name="177" href="#177">177</a><b>print</b> <span class="s">&apos;<a href="http://example.com">http://example.com</a>&apos;</span>
186-
<a class="l" name="178" href="#178">178</a></body>
186+
<a class="l" name="178" href="#178">178</a><b>puts</b> <span class="s">&quot;Last #{</span><a href="/source/s?defs=log_lines" class="intelliWindow-symbol" data-definition-place="undefined-in-file">log_lines</a><span class="s">} lines from #{</span><a href="/source/s?defs=logfn" class="intelliWindow-symbol" data-definition-place="undefined-in-file">logfn</a><span class="s">}:&quot;</span>
187+
<a class="l" name="179" href="#179">179</a><b>print</b> <span class="s">&quot;\n&quot;</span>
188+
<a class="hl" name="180" href="#180">180</a></body>
187189
</html>

test/org/opensolaris/opengrok/analysis/ruby/sample.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,5 @@ def right
175175
end
176176
print "\n"
177177
print 'http://example.com'
178+
puts "Last #{log_lines} lines from #{logfn}:"
179+
print "\n"

test/org/opensolaris/opengrok/analysis/ruby/samplesymbols.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,5 @@ over?
184184
STDIN
185185
bd
186186
reset
187+
log_lines # 177:puts "Last #{log_lines} lines from #{logfn}:"
188+
logfn

0 commit comments

Comments
 (0)