add alignTable, parseTableCells to align/format a tab(etc) delimited table (#10182)
* add compiler/unittest_light.nim for easy diffing: assertEquals and mismatch * fixup * add alignTable, parseTableCells
This commit is contained in:
parent
258952832f
commit
23c1ee982e
5 changed files with 291 additions and 0 deletions
55
tests/compiler/tunittest_light.nim
Normal file
55
tests/compiler/tunittest_light.nim
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import compiler/unittest_light
|
||||
|
||||
proc testAssertEquals() =
|
||||
assertEquals("foo", "foo")
|
||||
doAssertRaises(AssertionError):
|
||||
assertEquals("foo", "foo ")
|
||||
|
||||
proc testMismatch() =
|
||||
assertEquals(1+1, 2*1)
|
||||
|
||||
let a = """
|
||||
some test with space at the end of lines
|
||||
|
||||
can be hard to spot differences when diffing in a terminal
|
||||
without this helper function
|
||||
|
||||
"""
|
||||
|
||||
let b = """
|
||||
some test with space at the end of lines
|
||||
|
||||
can be hard to spot differences when diffing in a terminal
|
||||
without this helper function
|
||||
|
||||
"""
|
||||
|
||||
doAssert mismatch(a, b) == """
|
||||
|
||||
lhs:{
|
||||
some test with space at the end of lines \n
|
||||
\n
|
||||
can be hard to spot differences when diffing in a terminal \n
|
||||
without this helper function\n
|
||||
\n
|
||||
}
|
||||
rhs:{
|
||||
some test with space at the end of lines \n
|
||||
\n
|
||||
can be hard to spot differences when diffing in a terminal \n
|
||||
without this helper function\n
|
||||
\n
|
||||
}
|
||||
lhs.len: 144 rhs.len: 143
|
||||
first mismatch index: 110
|
||||
lhs[i]: {" "} rhs[i]: {"\n"}lhs[0..<i]:{
|
||||
some test with space at the end of lines \n
|
||||
\n
|
||||
can be hard to spot differences when diffing in a terminal }
|
||||
rhs[0..<i]:{
|
||||
some test with space at the end of lines \n
|
||||
\n
|
||||
can be hard to spot differences when diffing in a terminal }"""
|
||||
|
||||
testMismatch()
|
||||
testAssertEquals()
|
||||
Loading…
Add table
Add a link
Reference in a new issue