From 5a1ef1e05c2cc0428f70dc7c95e406b465b268b7 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Mon, 5 May 2008 16:26:31 +0200 Subject: [PATCH] Fix Function#argumentNames. --- src/base.js | 2 +- test/unit/base_test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base.js b/src/base.js index 6120c41..eae7f18 100644 --- a/src/base.js +++ b/src/base.js @@ -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; }, diff --git a/test/unit/base_test.js b/test/unit/base_test.js index 8b6a466..73e268f 100644 --- a/test/unit/base_test.js +++ b/test/unit/base_test.js @@ -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() {};