Skip to content

bound functions do not perserve arities #3257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/classes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ test "a bound function in a bound function", ->
eq (func() for func in m.generate()).join(' '), '10 10 10'


test "bound functions in a class do perserve arities", ->
class Mini
unary_func: (a0)=>
binary_func: (a0, a1)=>
tinary_func: (a0, a1, a2)=>
obj = new Mini
obj2 =
unary_func: obj.unary_func
binary_func: obj.binary_func
tinary_func: obj.tinary_func

eq obj2.unary_func.length, 1
eq obj2.binary_func.length, 2
eq obj2.tinary_func.length, 3

test "contructor called with varargs", ->

class Connection
Expand Down
15 changes: 15 additions & 0 deletions test/functions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ test "self-referencing functions", ->
eq changeMe, 2


test "bound functions do perserve arities", ->
obj =
unary_func: (a0)=>
binary_func: (a0, a1)=>
tinary_func: (a0, a1, a2)=>
obj2 =
unary_func: obj.unary_func
binary_func: obj.binary_func
tinary_func: obj.tinary_func

eq obj2.unary_func.length, 1
eq obj2.binary_func.length, 2
eq obj2.tinary_func.length, 3


# Parameter List Features

test "splats", ->
Expand Down