saxophonit :: SAXEventLogger :: diff
# Show the differences between the internal logs of `self` and `expected`.
#
# If there is no differences, return an empty string. Else, return a string
# designed to be printed in the terminal. In this case, `=` means “in both”,
# `<` means “in `self`” and `>` means “in `expected`”.
fun diff(expected: SAXEventLogger): Text do
var buf = new FlatBuffer
var sub_diff: Array[Int]
var equal: Bool
var i = 0
var min: Int
var max: Int
if log.length < expected.log.length then
equal = false
min = log.length
max = expected.log.length
else if expected.log.length < log.length then
equal = false
min = expected.log.length
max = log.length
else
equal = true
min = log.length
max = log.length
end
while i < min do
sub_diff = diff_entry(log[i], expected.log[i])
if sub_diff.length > 0 then
if equal then
diff_append_matches(buf, log, [0..i[)
equal = false
end
diff_append_deletion(buf, log, i, sub_diff)
diff_append_insertion(buf, expected.log, i, sub_diff)
else if not equal then
diff_append_matches(buf, log, [i..i])
end
i += 1
end
if log.length < expected.log.length then
while i < max do
diff_append_insertion(buf, expected.log, i,
[0..(expected.log[i].length)[)
i += 1
end
else
while i < max do
diff_append_deletion(buf, log, i, [0..(log[i].length)[)
i += 1
end
end
return buf
end
lib/saxophonit/testing.nit:80,2--134,4