Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (29 sloc) 0.739 kB
# Scope
# -----
# * Variable Safety
# * Variable Shadowing
# * Auto-closure (`do`)
# * Global Scope Leaks
test "reference `arguments` inside of functions", ->
sumOfArgs = ->
sum = (a,b) -> a + b
sum = 0
sum += num for num in arguments
sum
eq 10, sumOfArgs(0, 1, 2, 3, 4)
test "assignment to an Object.prototype-named variable should not leak to outer scope", ->
# FIXME: fails on IE
(->
constructor = 'word'
)()
ok constructor isnt 'word'
test "siblings of splat parameters shouldn't leak to surrounding scope", ->
x = 10
oops = (x, args...) ->
oops(20, 1, 2, 3)
eq x, 10
test "catch statements should introduce their argument to scope", ->
try throw ''
catch e
do -> e = 5
eq 5, e
Jump to Line
Something went wrong with that request. Please try again.