tests: Trim .nim files trailing whitespace

via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
This commit is contained in:
Adam Strzelecki 2015-09-04 23:04:32 +02:00
commit e80465dacf
372 changed files with 4486 additions and 4486 deletions

View file

@ -110,4 +110,4 @@ when isMainModule:
echo styles
echo body
echo info
echo shader
echo shader

View file

@ -1,10 +1,10 @@
var
var
gx = 88
gy = 44
template templ*(): int =
bind gx, gy
gx + gy

View file

@ -1,219 +1,219 @@
# Fields
const x = 5
# Test substring
static:
assert "test".substring(3) == "t"
assert "test".substring(2,1) == "s"
assert "test".substring(3,2) == "t"
assert "test".substring(1,2) == "es"
# Various parsing tests
when true:
block: #no_substitution
proc actual: string = tmpli html"""
<p>Test!</p>
"""
const expected = html"""
<p>Test!</p>
"""
doAssert actual() == expected
block: #basic
proc actual: string = tmpli html"""
<p>Test $$x</p>
$x
"""
const expected = html"""
<p>Test $x</p>
5
"""
doAssert actual() == expected
block: #expression
proc actual: string = tmpli html"""
<p>Test $$(x * 5)</p>
$(x * 5)
"""
const expected = html"""
<p>Test $(x * 5)</p>
25
"""
doAssert actual() == expected
block: #escape
proc actual: string = tmpli js"""
[{
"hello world"
}]
"""
const expected = js"""
[{
"hello world"
}]
"""
doAssert actual() == expected
block: #forIn
proc actual: string = tmpli html"""
<p>Test for</p>
<ul>
$for y in 0..2 {
<li>$y</li>
}
</ul>
"""
const expected = html"""
<p>Test for</p>
<ul>
<li>0</li>
<li>1</li>
<li>2</li>
</ul>
"""
doAssert actual() == expected
block: #while
proc actual: string = tmpli html"""
<p>Test while/stmt</p>
<ul>
${ var y = 0 }
$while y < 4 {
<li>$y</li>
${ inc(y) }
}
</ul>
"""
const expected = html"""
<p>Test while/stmt</p>
<ul>
<li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
"""
doAssert actual() == expected
block: #ifElifElse
proc actual: string = tmpli html"""
<p>Test if/elif/else</p>
$if x == 8 {
<div>x is 8!</div>
}
$elif x == 7 {
<div>x is 7!</div>
}
$else {
<div>x is neither!</div>
}
"""
const expected = html"""
<p>Test if/elif/else</p>
<div>x is neither!</div>
"""
doAssert actual() == expected
block: #multiLineStatements
proc actual: string = tmpli html"""
<p>Test multiline statements</p>
${
var x = 5
var y = 7
}
<span>$x</span><span>$y</span>
"""
const expected = html"""
<p>Test multiline statements</p>
<span>5</span><span>7</span>
"""
doAssert actual() == expected
block: #caseOfElse
proc actual: string = tmpli html"""
<p>Test case</p>
$case x
$of 5 {
<div>x == 5</div>
}
$of 6 {
<div>x == 6</div>
}
$else {}
"""
const expected = html"""
<p>Test case</p>
<div>x == 5</div>
"""
doAssert actual() == expected
when true: #embeddingTest
proc no_substitution: string = tmpli html"""
<h1>Template test!</h1>
"""
# # Single variable substitution
proc substitution(who = "nobody"): string = tmpli html"""
<div id="greeting">hello $who!</div>
"""
# Expression template
proc test_expression(nums: openarray[int] = []): string =
var i = 2
tmpli html"""
$(no_substitution())
$(substitution("Billy"))
<div id="age">Age: $($nums[i] & "!!")</div>
"""
proc test_statements(nums: openarray[int] = []): string =
tmpli html"""
$(test_expression(nums))
$if true {
<ul>
$for i in nums {
<li>$(i * 2)</li>
}
</ul>
}
"""
var actual = test_statements([0,1,2])
const expected = html"""
<h1>Template test!</h1>
<div id="greeting">hello Billy!</div>
<div id="age">Age: 2!!</div>
<ul>
<li>0</li>
<li>2</li>
<li>4</li>
</ul>
"""
doAssert actual == expected
when defined(future):
block: #tryCatch
proc actual: string = tmpli html"""
<p>Test try/catch</p>
<div>
$try {
<div>Lets try this!</div>
}
$except {
<div>Uh oh!</div>
}
</div>
"""
const expected = html"""
<p>Test try/catch</p>
<div>
<div>Lets try this!</div>
</div>
"""
doAssert actual() == expected
# Fields
const x = 5
# Test substring
static:
assert "test".substring(3) == "t"
assert "test".substring(2,1) == "s"
assert "test".substring(3,2) == "t"
assert "test".substring(1,2) == "es"
# Various parsing tests
when true:
block: #no_substitution
proc actual: string = tmpli html"""
<p>Test!</p>
"""
const expected = html"""
<p>Test!</p>
"""
doAssert actual() == expected
block: #basic
proc actual: string = tmpli html"""
<p>Test $$x</p>
$x
"""
const expected = html"""
<p>Test $x</p>
5
"""
doAssert actual() == expected
block: #expression
proc actual: string = tmpli html"""
<p>Test $$(x * 5)</p>
$(x * 5)
"""
const expected = html"""
<p>Test $(x * 5)</p>
25
"""
doAssert actual() == expected
block: #escape
proc actual: string = tmpli js"""
[{
"hello world"
}]
"""
const expected = js"""
[{
"hello world"
}]
"""
doAssert actual() == expected
block: #forIn
proc actual: string = tmpli html"""
<p>Test for</p>
<ul>
$for y in 0..2 {
<li>$y</li>
}
</ul>
"""
const expected = html"""
<p>Test for</p>
<ul>
<li>0</li>
<li>1</li>
<li>2</li>
</ul>
"""
doAssert actual() == expected
block: #while
proc actual: string = tmpli html"""
<p>Test while/stmt</p>
<ul>
${ var y = 0 }
$while y < 4 {
<li>$y</li>
${ inc(y) }
}
</ul>
"""
const expected = html"""
<p>Test while/stmt</p>
<ul>
<li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
"""
doAssert actual() == expected
block: #ifElifElse
proc actual: string = tmpli html"""
<p>Test if/elif/else</p>
$if x == 8 {
<div>x is 8!</div>
}
$elif x == 7 {
<div>x is 7!</div>
}
$else {
<div>x is neither!</div>
}
"""
const expected = html"""
<p>Test if/elif/else</p>
<div>x is neither!</div>
"""
doAssert actual() == expected
block: #multiLineStatements
proc actual: string = tmpli html"""
<p>Test multiline statements</p>
${
var x = 5
var y = 7
}
<span>$x</span><span>$y</span>
"""
const expected = html"""
<p>Test multiline statements</p>
<span>5</span><span>7</span>
"""
doAssert actual() == expected
block: #caseOfElse
proc actual: string = tmpli html"""
<p>Test case</p>
$case x
$of 5 {
<div>x == 5</div>
}
$of 6 {
<div>x == 6</div>
}
$else {}
"""
const expected = html"""
<p>Test case</p>
<div>x == 5</div>
"""
doAssert actual() == expected
when true: #embeddingTest
proc no_substitution: string = tmpli html"""
<h1>Template test!</h1>
"""
# # Single variable substitution
proc substitution(who = "nobody"): string = tmpli html"""
<div id="greeting">hello $who!</div>
"""
# Expression template
proc test_expression(nums: openarray[int] = []): string =
var i = 2
tmpli html"""
$(no_substitution())
$(substitution("Billy"))
<div id="age">Age: $($nums[i] & "!!")</div>
"""
proc test_statements(nums: openarray[int] = []): string =
tmpli html"""
$(test_expression(nums))
$if true {
<ul>
$for i in nums {
<li>$(i * 2)</li>
}
</ul>
}
"""
var actual = test_statements([0,1,2])
const expected = html"""
<h1>Template test!</h1>
<div id="greeting">hello Billy!</div>
<div id="age">Age: 2!!</div>
<ul>
<li>0</li>
<li>2</li>
<li>4</li>
</ul>
"""
doAssert actual == expected
when defined(future):
block: #tryCatch
proc actual: string = tmpli html"""
<p>Test try/catch</p>
<div>
$try {
<div>Lets try this!</div>
}
$except {
<div>Uh oh!</div>
}
</div>
"""
const expected = html"""
<p>Test try/catch</p>
<div>
<div>Lets try this!</div>
</div>
"""
doAssert actual() == expected

View file

@ -1,7 +1,7 @@
var
e = "abc"
raise newException(EIO, e & "ha!")
template t() = echo(foo)

View file

@ -8,10 +8,10 @@ else:
import posix
when defined(Windows):
template orig: expr =
template orig: expr =
winlean
else:
template orig: expr =
template orig: expr =
posix
proc socket(domain, typ, protocol: int): int =

View file

@ -6,7 +6,7 @@ levB'''
# tstempl.nim
import strutils
type
type
TLev = enum
levA,
levB

View file

@ -15,10 +15,10 @@ const
var i = 0
for item in items(tabs):
for item in items(tabs):
var content = $i
var file: TFile
if open(file, changeFileExt(item[1], "html"), fmWrite):
if open(file, changeFileExt(item[1], "html"), fmWrite):
write(file, sunsetTemplate(current=item[1], ticker="", content=content,
tabs=tabs))
close(file)

View file

@ -11,18 +11,18 @@ template withOpenFile(f: expr, filename: string, mode: TFileMode,
close(f)
else:
quit("cannot open for writing: " & filename)
withOpenFile(txt, "ttempl3.txt", fmWrite):
writeLine(txt, "line 1")
txt.writeLine("line 2")
var
myVar: array[0..1, int]
# Test zero argument template:
# Test zero argument template:
template ha: expr = myVar[0]
ha = 1
ha = 1
echo(ha)
@ -37,7 +37,7 @@ template typedef(name: expr, typ: typeDesc) {.immediate, dirty.} =
type
`T name`* = typ
`P name`* = ref `T name`
typedef(myint, int)
var x: PMyInt

View file

@ -4,11 +4,11 @@ discard """
# bug #940
type
Foo* = ref object
type
Foo* = ref object
b*: int
proc new*(this: var Foo) =
proc new*(this: var Foo) =
assert this != nil
this.b = 10