2010-06-12 19:05:13 -04:00
|
|
|
# Ensure that we don't wrap Nodes that are "pureStatement" in a closure.
|
2010-07-25 01:23:37 -04:00
|
|
|
items = [1, 2, 3, "bacon", 4, 5]
|
2010-02-11 02:41:24 -05:00
|
|
|
|
|
|
|
for item in items
|
|
|
|
break if item is "bacon"
|
2010-01-16 12:10:31 -05:00
|
|
|
|
2010-07-25 01:23:37 -04:00
|
|
|
findit = (items) ->
|
2010-01-16 12:10:31 -05:00
|
|
|
for item in items
|
|
|
|
return item if item is "bacon"
|
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok findit(items) is "bacon"
|
2010-01-16 12:10:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
# When when a closure wrapper is generated for expression conversion, make sure
|
|
|
|
# that references to "this" within the wrapper are safely converted as well.
|
2010-07-25 01:23:37 -04:00
|
|
|
obj = {
|
2010-02-11 02:41:24 -05:00
|
|
|
num: 5
|
|
|
|
func: ->
|
2010-07-25 01:23:37 -04:00
|
|
|
this.result = if false
|
2010-02-11 02:41:24 -05:00
|
|
|
10
|
|
|
|
else
|
|
|
|
"a"
|
|
|
|
"b"
|
|
|
|
this.num
|
|
|
|
}
|
|
|
|
|
2010-02-16 19:45:25 -05:00
|
|
|
ok obj.num is obj.func()
|
2010-09-12 15:48:31 -04:00
|
|
|
ok obj.num is obj.result
|
|
|
|
|
|
|
|
|
|
|
|
# Should be able to look at prototypes on keywords.
|
|
|
|
obj =
|
|
|
|
withAt: -> @::prop
|
|
|
|
withThis: -> this::prop
|
|
|
|
proto:
|
|
|
|
prop: 100
|
|
|
|
|
|
|
|
obj.prototype = obj.proto
|
|
|
|
ok obj.withAt() is 100
|
|
|
|
ok obj.withThis() is 100
|