remove trailing whitespace requirement from subexes test file
This commit is contained in:
parent
1652fd0431
commit
1639de0a4e
1 changed files with 13 additions and 14 deletions
|
|
@ -351,6 +351,7 @@ proc format*(formatstr: Subex, a: varargs[string, `$`]): string {.noSideEffect,
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
from strutils import replace
|
||||||
|
|
||||||
proc `%`(formatstr: string, a: openarray[string]): string =
|
proc `%`(formatstr: string, a: openarray[string]): string =
|
||||||
result = newStringOfCap(formatstr.len + a.len shl 4)
|
result = newStringOfCap(formatstr.len + a.len shl 4)
|
||||||
|
|
@ -382,18 +383,18 @@ when isMainModule:
|
||||||
doAssert "${$1}" % "1" == "1"
|
doAssert "${$1}" % "1" == "1"
|
||||||
doAssert "${$$-1} $$1" % "1" == "1 $1"
|
doAssert "${$$-1} $$1" % "1" == "1 $1"
|
||||||
|
|
||||||
doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] ==
|
doAssert(("$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"]).replace(" \n", "\n") ==
|
||||||
"""doAssert(
|
"""doAssert(
|
||||||
longishA,
|
longishA,
|
||||||
longish)"""
|
longish)""")
|
||||||
|
|
||||||
assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA",
|
doAssert(("type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA",
|
||||||
"fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] ==
|
"fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"]).replace(" \n", "\n") ==
|
||||||
strutils.unindent """
|
strutils.unindent """
|
||||||
type MyEnum* = enum
|
type MyEnum* = enum
|
||||||
fieldA, fieldB,
|
fieldA, fieldB,
|
||||||
FiledClkad, fieldD,
|
FiledClkad, fieldD,
|
||||||
fieldE, longishFieldName"""
|
fieldE, longishFieldName""")
|
||||||
|
|
||||||
doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)"
|
doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)"
|
||||||
|
|
||||||
|
|
@ -401,12 +402,10 @@ when isMainModule:
|
||||||
|
|
||||||
doAssert subex"$['''|'|''''|']']#" % "0" == "'|"
|
doAssert subex"$['''|'|''''|']']#" % "0" == "'|"
|
||||||
|
|
||||||
assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [
|
doAssert((subex("type\n Enum = enum\n $', '40c'\n '{..}") % [
|
||||||
"fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] ==
|
"fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"]).replace(" \n", "\n") ==
|
||||||
strutils.unindent """
|
strutils.unindent """
|
||||||
type
|
type
|
||||||
Enum = enum
|
Enum = enum
|
||||||
fieldNameA, fieldNameB, fieldNameC,
|
fieldNameA, fieldNameB, fieldNameC,
|
||||||
fieldNameD"""
|
fieldNameD""")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue