Function soaks should preserve this. Fixes issue #692.

This commit is contained in:
Stéphan Kochen
2010-09-18 12:27:14 +02:00
parent 43f7f6c355
commit 72d7fe2f7a
3 changed files with 35 additions and 16 deletions

View File

@@ -124,13 +124,17 @@ duration = if options?.animated then 150 else 0
ok duration is 0
# function soak
# Function soaks.
plus1 = (x) -> x + 1
obj = {
returnThis: -> this
}
ok plus1?(41) is 42
ok (plus1? 41) is 42
ok plus2?(41) is undefined
ok (plus2? 41) is undefined
ok obj.returnThis?() is obj
maybe_close = (f, arg) -> if typeof f is 'function' then () -> f(arg) else -1