mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
first draft of mandatory parentheses around function definition param lists -- all tests pass
This commit is contained in:
22
test/fixtures/execution/test_functions.coffee
vendored
22
test/fixtures/execution/test_functions.coffee
vendored
@@ -1,6 +1,6 @@
|
||||
x: 1
|
||||
y: {}
|
||||
y.x: => 3
|
||||
y.x: () => 3
|
||||
|
||||
print x is 1
|
||||
print typeof(y.x) is 'function'
|
||||
@@ -9,17 +9,17 @@ print y.x.name is 'x'
|
||||
|
||||
|
||||
# The empty function should not cause a syntax error.
|
||||
=>
|
||||
() =>
|
||||
|
||||
|
||||
obj: {
|
||||
name: "Fred"
|
||||
|
||||
bound: =>
|
||||
(==> print(this.name is "Fred"))()
|
||||
bound: () =>
|
||||
(() ==> print(this.name is "Fred"))()
|
||||
|
||||
unbound: =>
|
||||
(=> print(!this.name?))()
|
||||
unbound: () =>
|
||||
(() => print(!this.name?))()
|
||||
}
|
||||
|
||||
obj.unbound()
|
||||
@@ -29,18 +29,18 @@ obj.bound()
|
||||
# The named function should be cleared out before a call occurs:
|
||||
|
||||
# Python decorator style wrapper that memoizes any function
|
||||
memoize: fn =>
|
||||
memoize: (fn) =>
|
||||
cache: {}
|
||||
self: this
|
||||
args... =>
|
||||
(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
|
||||
Add: (a, b) => a + b
|
||||
AnonymousAdd: ((a, b) => a + b)
|
||||
FastAdd: memoize (a, b) => a + b
|
||||
}
|
||||
|
||||
print Math.Add(5, 5) is 10
|
||||
|
||||
Reference in New Issue
Block a user