diff options
author | Clyybber <darkmine956@gmail.com> | 2020-09-05 22:01:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 22:01:47 +0200 |
commit | 35ff17410f303ce0434ef149f3e372d7243f41ab (patch) | |
tree | 9579d1f87b999641672bc01d39623f90397f7276 /tests | |
parent | 70d62387568d55cd276472f28ce22ab8bafadf1c (diff) | |
download | Nim-35ff17410f303ce0434ef149f3e372d7243f41ab.tar.gz |
Expand hoisted default params in sem (#15270)
* Expand hoisted default params in sem Introduce ast.newTree{I,IT} Add test for default params in procs * Cleanup * Simplify hoist transformation and expand test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/defaultprocparam/tdefaultprocparam.nim | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/defaultprocparam/tdefaultprocparam.nim b/tests/defaultprocparam/tdefaultprocparam.nim index 5f8c1adab..0d62cc955 100644 --- a/tests/defaultprocparam/tdefaultprocparam.nim +++ b/tests/defaultprocparam/tdefaultprocparam.nim @@ -1,8 +1,83 @@ discard """ output: ''' hi +hi +topLevel|topLevel| +topLevel2|topLevel2| +inProc|inProc| +inProc2|inProc2| +topLevel|9 +topLevel2|10 +inProc|7 +inProc2|8 +must have been the wind.. +I'm there +must have been the wind.. +I'm there +symbol'a'symbol'a' +symbol'b'symbol'b' +symbol'a'symbol'b' +symbol'a'9 +symbol'b'9 +symbol'a'0 ''' """ import mdefaultprocparam p() + +proc testP = + p() + +testP() + +proc p2(s: string, count = s): string = s & count + +proc testP2 = + echo p2 """inProc|""" + echo p2 """inProc2|""" + +echo p2 """topLevel|""" +echo p2 """topLevel2|""" + +testP2() + +import macros +macro dTT(a: typed) = echo a.treeRepr + +proc p3(s: string, count = len(s)): string = s & $count + +proc testP3 = + echo p3 """inProc|""" + echo p3 """inProc2|""" + +echo p3 """topLevel|""" +echo p3 """topLevel2|""" + +testP3() + +proc cut(s: string, c = len(s)): string = + s[0..<s.len-c] + +echo "must have been the wind.." & cut "I'm gone" +echo cut("I'm gone", 4) & "there" + +proc testCut = + echo "must have been the wind.." & cut "I'm gone" + echo cut("I'm gone", 4) & "there" + +testCut() + +var a = "symbol'a'" +var b = "symbol'b'" + +block: + echo p2(a) +block: + echo p2(b) +block: + echo p2(a, b) +block: + echo p3(a) + echo p3(b) + echo p3(a, 0) |