diff options
author | Arne Döring <arne.doering@gmx.net> | 2018-11-14 23:14:16 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-11-23 11:58:28 +0100 |
commit | e012eb100109d343b7cdbe2598d439d84eda7830 (patch) | |
tree | ec977218e469415b04cc7005473f9f3358dcd553 /tests/closure | |
parent | 8ea72bdceab5a13318a0269bb44990e514bf03a7 (diff) | |
download | Nim-e012eb100109d343b7cdbe2598d439d84eda7830.tar.gz |
updated tests to be executed
Diffstat (limited to 'tests/closure')
-rw-r--r-- | tests/closure/tmacrobust1512.nim | 40 | ||||
-rw-r--r-- | tests/closure/ttimeinfo.nim | 7 |
2 files changed, 20 insertions, 27 deletions
diff --git a/tests/closure/tmacrobust1512.nim b/tests/closure/tmacrobust1512.nim index 5f13e8286..0f44c5e1a 100644 --- a/tests/closure/tmacrobust1512.nim +++ b/tests/closure/tmacrobust1512.nim @@ -1,8 +1,12 @@ +discard """ +output: "" +""" + import macros, strutils # https://github.com/nim-lang/Nim/issues/1512 -proc macrobust0(raw_input: string) = +proc macrobust0(input: string): string = var output = "" proc p1(a:string) = output.add(a) @@ -27,13 +31,9 @@ proc macrobust0(raw_input: string) = proc p19(a:string) = p18(a) proc p20(a:string) = p19(a) - let input = $raw_input - for a in input.split(): p20(a) p19(a) - - p18(a) p17(a) p16(a) @@ -53,11 +53,9 @@ proc macrobust0(raw_input: string) = p2(a) p1(a) + result = output - echo output - -macro macrobust(raw_input: untyped): untyped = - +macro macrobust(input: static[string]): untyped = var output = "" proc p1(a:string) = output.add(a) @@ -82,12 +80,9 @@ macro macrobust(raw_input: untyped): untyped = proc p19(a:string) = p18(a) proc p20(a:string) = p19(a) - let input = $raw_input - for a in input.split(): p20(a) p19(a) - p18(a) p17(a) p16(a) @@ -105,11 +100,11 @@ macro macrobust(raw_input: untyped): untyped = p4(a) p3(a) p2(a) + p1(a) - echo output - discard result + result = newLit(output) -macrobust """ +const input = """ fdsasadfsdfa sadfsdafsdaf dsfsdafdsfadsfa fsdaasdfasdf fsdafsadfsad asdfasdfasdf @@ -122,16 +117,7 @@ macrobust """ sdfasdafsadf sdfasdafsdaf sdfasdafsdaf """ +let str1 = macrobust(input) +let str2 = macrobust0(input) -macrobust0 """ - fdsasadfsdfa sadfsdafsdaf - dsfsdafdsfadsfa fsdaasdfasdf - fsdafsadfsad asdfasdfasdf - fdsasdfasdfa sadfsadfsadf - sadfasdfsdaf sadfsdafsdaf dsfasdaf - sadfsdafsadf fdsasdafsadf fdsasadfsdaf - sdfasadfsdafdfsa sadfsadfsdaf - sdafsdaffsda sdfasadfsadf - fsdasdafsdfa sdfasdfafsda - sdfasdafsadf sdfasdafsdaf sdfasdafsdaf -""" +doAssert str1 == str2 diff --git a/tests/closure/ttimeinfo.nim b/tests/closure/ttimeinfo.nim index 3096a5d65..7416c0d31 100644 --- a/tests/closure/ttimeinfo.nim +++ b/tests/closure/ttimeinfo.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00] +@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00] +''' +""" + # bug #2073 import sequtils |