mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
simplification of function and prototype naming -- last_assign, immediate_assign, and proto_assign are gone, in favor of 'name' and 'proto' properties on CodeNodes
This commit is contained in:
22
test/fixtures/execution/test_functions.coffee
vendored
22
test/fixtures/execution/test_functions.coffee
vendored
@@ -24,3 +24,25 @@ obj: {
|
||||
|
||||
obj.unbound()
|
||||
obj.bound()
|
||||
|
||||
|
||||
# The named function should be cleared out before a call occurs:
|
||||
|
||||
# Python decorator style wrapper that memoizes any function
|
||||
memoize: fn =>
|
||||
cache: {}
|
||||
self: this
|
||||
args... =>
|
||||
key: args.toString()
|
||||
return cache[key] if cache[key]
|
||||
cache[key] = fn.apply(self, args)
|
||||
|
||||
Math: {
|
||||
Add: a, b => a + b
|
||||
AnonymousAdd: (a, b => a + b)
|
||||
FastAdd: memoize() a, b => a + b
|
||||
}
|
||||
|
||||
print(Math.Add(5, 5) is 10)
|
||||
print(Math.AnonymousAdd(10, 10) is 20)
|
||||
print(Math.FastAdd(20, 20) is 40)
|
||||
|
||||
Reference in New Issue
Block a user