From 61fa9148bccc9cc79fc55081868cdf1c1933fbf5 Mon Sep 17 00:00:00 2001 From: aaronp Date: Mon, 21 Jan 2008 07:21:55 +0000 Subject: [PATCH] testing function length property git-svn-id: svn://rubyforge.org/var/svn/rkelly/trunk@158 bf63cea8-67a3-4864-ab90-c58634fce689 --- lib/rkelly/js/function.rb | 7 ++++--- test/function/test_15_3_1_1-1.rb | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/rkelly/js/function.rb b/lib/rkelly/js/function.rb index 5d682f3..90c40f0 100644 --- a/lib/rkelly/js/function.rb +++ b/lib/rkelly/js/function.rb @@ -6,9 +6,9 @@ def create(*args) if args.length > 0 parser = RKelly::Parser.new body = args.pop - arguments = args.map { |x| RKelly::Nodes::ParameterNode.new(x) } - body = RKelly::Nodes::FunctionBodyNode.new(parser.parse(body)) - self.new(body, arguments) + tree = parser.parse("function x(#{args.join(',')}) { #{body} }") + func = tree.value.first + self.new(func.function_body, func.arguments) else self.new end @@ -21,6 +21,7 @@ def initialize(body = nil, arguments = []) @body = body @arguments = arguments self['toString'] = :undefined + self['length'] = arguments.length end def js_call(scope_chain, *params) diff --git a/test/function/test_15_3_1_1-1.rb b/test/function/test_15_3_1_1-1.rb index 374df76..441c513 100644 --- a/test/function/test_15_3_1_1-1.rb +++ b/test/function/test_15_3_1_1-1.rb @@ -4,8 +4,7 @@ class Expressions_15_3_1_1_1_Test < ECMAScriptTestCase def setup super @runtime.execute(<