summary refs log tree commit diff stats
path: root/tests/closure
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-07-18 11:50:06 +0300
committerAndreas Rumpf <rumpf_a@web.de>2017-08-19 08:57:43 +0200
commit7ad115f530942c0fc6718c146ee1a5a97ed61e6f (patch)
tree200af3aa9257690f92c6c91be478bfbbd17f1e51 /tests/closure
parentc3e5c6c326747cf0acbe0e4f3d8dc71f9332a76e (diff)
downloadNim-7ad115f530942c0fc6718c146ee1a5a97ed61e6f.tar.gz
Restore the old behavior of parsing "quote do:"
close #5845
Diffstat (limited to 'tests/closure')
-rw-r--r--tests/closure/tdonotation.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/closure/tdonotation.nim b/tests/closure/tdonotation.nim
index 94eba8ddb..cc4f46bab 100644
--- a/tests/closure/tdonotation.nim
+++ b/tests/closure/tdonotation.nim
@@ -5,7 +5,9 @@ lost focus 1
 lost focus 2
 registered handler for UserEvent 1
 registered handler for UserEvent 2
-registered handler for UserEvent 3'''
+registered handler for UserEvent 3
+registered handler for UserEvent 4
+'''
 """
 
 import future
@@ -35,11 +37,14 @@ b.onFocusLost:
 b.onFocusLost do:
   echo "lost focus 2"
 
-b.onUserEvent "UserEvent 1" do:
+b.onUserEvent("UserEvent 1") do:
   discard
 
 b.onUserEvent "UserEvent 2":
   discard
 
-b.onUserEvent("UserEvent 3", () => echo "event 3")
+b.onUserEvent("UserEvent 3"):
+  discard
+
+b.onUserEvent("UserEvent 4", () => echo "event 4")
 
lor: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
discard """
  output: '''1
2
3
4
1
2'''
"""

proc factory(a, b: int): iterator (): int =
  iterator foo(): int {.closure.} =
    var x = a
    while x <= b:
      yield x
      inc x
  return foo

proc factory2(a, b: int): iterator (): int =
  return iterator (): int =
    var x = a
    while x <= b:
      yield x
      inc x

let foo = factory(1, 4)

for f in foo():
  echo f

let foo2 = factory2(1,2)

for f in foo2(): echo f