summary refs log blame commit diff stats
path: root/tests/niminaction/Chapter2/resultreject.nim
blob: 87c84bf0a42615ecc1769c207bdbb951b78ac2d4 (plain) (tree)
1
2
3
4
5
6
7
8
9
           
                                 
          





                       
 







                                  
 












                                            
                                             
discard """
  errormsg: "has to be discarded"
  line: 27
"""

# 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"