Skip to content

Commit

Permalink
0.1.7: line numbers match the file
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Aug 7, 2020
1 parent a110706 commit 1f888a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions testes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ proc prefixLines(s: string; p: string): string =
for line in items(splitLines(s, keepEol = true)):
result.add p & line

proc numberLines(s: string): string =
proc numberLines(s: string; first = 1): string =
for n, line in pairs(splitLines(s, keepEol = true)):
if n > 0:
result.add "$1 $2" % [ align($n, 3), line ]
result.add "$1 $2" % [ align($(n + first), 3), line ]

proc report(ss: varargs[string, `$`]) =
writeLine(stderr, ss)
Expand Down Expand Up @@ -145,11 +144,12 @@ proc renderTrace(t: Test; n: NimNode = nil): NimNode =
proc renderSource(t: Test): NimNode =
## strip the first comment, include the remainder
var node = copyNimTree(t.orig)
var info = lineInfoObj(t.orig)
if len(node) > 0:
if node[0].kind == nnkCommentStmt:
let dropFirst = node[0].strVal.splitLines(keepEol = true)[1..^1].join("")
node[0] = newCommentStmtNode(dropFirst)
result = t.output(repr(node).numberLines.prefixLines " 🗏 ")
result = t.output(repr(node).numberLines(info.line).prefixLines " 🗏 ")

proc setExitCode(t: Test; code = QuitFailure): NimNode =
let isAtty = bindSym"isAtty"
Expand Down
2 changes: 1 addition & 1 deletion testes.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.1.6"
version = "0.1.7"
author = "disruptek"
description = "a cure for salty testes"
license = "MIT"
Expand Down

0 comments on commit 1f888a7

Please sign in to comment.