Fix Function#argumentNames.

This commit is contained in:
Tobie Langel 2008-05-05 16:26:31 +02:00
parent d1d2c3592d
commit 5a1ef1e05c
2 changed files with 2 additions and 1 deletions

View File

@ -159,7 +159,7 @@ Object.extend(Object, {
Object.extend(Function.prototype, {
argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(/\s*,\s*/);
var names = this.toString().match(/^[\s\(]*function[^(]*\(\s*(.*?)\s*\)/)[1].split(/\s*,\s*/);
return names.length == 1 && !names[0] ? [] : names;
},

View File

@ -3,6 +3,7 @@ new Test.Unit.Runner({
this.assertEnumEqual([], (function() {}).argumentNames());
this.assertEnumEqual(["one"], (function(one) {}).argumentNames());
this.assertEnumEqual(["one", "two", "three"], (function(one, two, three) {}).argumentNames());
this.assertEnumEqual(["one", "two", "three"], (function( one , two , three ) {}).argumentNames());
this.assertEqual("$super", (function($super) {}).argumentNames().first());
function named1() {};