Adds smaller code samples from Chapters 1-3 to the tester.
This commit is contained in:
parent
8081a9b3d0
commit
9e86237855
11 changed files with 642 additions and 1 deletions
33
tests/niminaction/Chapter2/resultreject.nim
Normal file
33
tests/niminaction/Chapter2/resultreject.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
discard """
|
||||
line: 27
|
||||
errormsg: "has to be discarded"
|
||||
"""
|
||||
|
||||
# Page 35.
|
||||
|
||||
proc implicit: string =
|
||||
"I will be returned"
|
||||
|
||||
proc discarded: string =
|
||||
discard "I will not be returned"
|
||||
|
||||
proc explicit: string =
|
||||
return "I will be returned"
|
||||
|
||||
proc resultVar: string =
|
||||
result = "I will be returned"
|
||||
|
||||
proc resultVar2: string =
|
||||
result = ""
|
||||
result.add("I will be ")
|
||||
result.add("returned")
|
||||
|
||||
proc resultVar3: string =
|
||||
result = "I am the result"
|
||||
"I will cause an error"
|
||||
|
||||
doAssert implicit() == "I will be returned"
|
||||
doAssert discarded() == nil
|
||||
doAssert explicit() == "I will be returned"
|
||||
doAssert resultVar() == "I will be returned"
|
||||
doAssert resultVar2() == "I will be returned"
|
||||
Loading…
Add table
Add a link
Reference in a new issue