Skip to content

Commit 21bb3d4

Browse files
committed
Sort diagnostics in scenario tests
1 parent ead00b5 commit 21bb3d4

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

lib/typeprof/code_range.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,10 @@ def to_s
105105
def ==(other)
106106
@first == other.first && @last == other.last
107107
end
108+
109+
def <=>(other)
110+
cmp = @first <=> other.first
111+
cmp == 0 ? @last <=> other.last : cmp
112+
end
108113
end
109114
end

scenario/rbs/check-block-return.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ def foo
1313
end
1414

1515
## diagnostics: test0.rb
16-
(11,2)-(11,5): expected: Integer; actual: Float
1716
(7,2)-(7,6): expected: Integer; actual: nil
1817
(9,2)-(9,12): expected: Integer; actual: String
18+
(11,2)-(11,5): expected: Integer; actual: Float

scenario/rbs/check-return-type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def foo
99
end
1010

1111
## diagnostics
12-
(7,2)-(7,5): expected: Integer; actual: Float
1312
(3,2)-(3,8): expected: Integer; actual: nil
1413
(5,2)-(5,14): expected: Integer; actual: String
14+
(7,2)-(7,5): expected: Integer; actual: Float

test/scenario_compiler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def handle_diagnostics
115115
<<-END
116116
output = []
117117
core.diagnostics(#{ @file.dump }) {|diag|
118-
output << (diag.code_range.to_s << ': ' << diag.msg)
118+
output << [diag.code_range, diag.msg]
119119
}
120-
output = output.join(\"\\n\")
120+
output = output.sort.map {|cr, msg| cr.to_s + ": " + msg }.join(\"\\n\")
121121
assert_equal(%q\0DATA\0.rstrip, output)
122122
END
123123
end

0 commit comments

Comments
 (0)