From: christian.plesner.hansen@gmail.com Date: Tue, 15 Sep 2009 13:30:46 +0000 (+0000) Subject: Added test suite adapter for es5conform. X-Git-Tag: upstream/4.7.83~23274 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6519951e069a25574f51cfc71bc2cbeca63825cc;p=platform%2Fupstream%2Fv8.git Added test suite adapter for es5conform. Review URL: http://codereview.chromium.org/193112 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2892 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index c1daa57..3ddca3f 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1471,7 +1471,7 @@ void Genesis::MakeFunctionInstancePrototypeWritable() { HandleScope scope; Handle function_map_descriptors = - ComputeFunctionInstanceDescriptor(false, true); + ComputeFunctionInstanceDescriptor(false); Handle fm = Factory::CopyMapDropDescriptors(Top::function_map()); fm->set_instance_descriptors(*function_map_descriptors); Top::context()->global_context()->set_function_map(*fm); diff --git a/src/v8natives.js b/src/v8natives.js index b63ce5f..3f60109 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -277,7 +277,7 @@ function ObjectLookupSetter(name) { function ObjectKeys(obj) { - if (!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) + if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) throw MakeTypeError('object_keys_non_object', [obj]); return %LocalKeys(obj); } diff --git a/test/es5conform/README b/test/es5conform/README new file mode 100644 index 0000000..a88f4a3 --- /dev/null +++ b/test/es5conform/README @@ -0,0 +1,14 @@ +This directory contains code for binding the es5conform test suite +into the v8 test harness. To use the tests check out the es5conform +tests from + + https://es5conform.svn.codeplex.com/svn + +in revision 59101 as 'data' in this directory. Using later version +may be possible but the tests are only known to pass (and indeed run) +with that revision. + +If you do update to a newer revision you may have to change the test +harness adapter code since it uses internal functionality from the +harness that comes bundled with the tests. You will most likely also +have to update the test expectation file. diff --git a/test/es5conform/es5conform.status b/test/es5conform/es5conform.status new file mode 100644 index 0000000..49cffb2 --- /dev/null +++ b/test/es5conform/es5conform.status @@ -0,0 +1,68 @@ +# Copyright 2009 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +prefix es5conform +def UNIMPLEMENTED = PASS || FAIL +def FAIL_OK = FAIL, OKAY + +chapter07: UNIMPLEMENTED +chapter08: UNIMPLEMENTED +chapter10: UNIMPLEMENTED +chapter11: UNIMPLEMENTED +chapter12: UNIMPLEMENTED +chapter13: UNIMPLEMENTED +chapter14: UNIMPLEMENTED +chapter15/15.1: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.1: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.2: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.3: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.4: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.5: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.6: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.7: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.8: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.9: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.10: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.11: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.12: UNIMPLEMENTED +chapter15/15.2/15.2.3/15.2.3.13: UNIMPLEMENTED + +# Object.keys +chapter15/15.2/15.2.3/15.2.3.14: PASS + +# We fail this because Object.keys returns numbers for element indices +# rather than strings. +chapter15/15.2/15.2.3/15.2.3.14/15.2.3.14-3-3: FAIL_OK + +chapter15/15.3: UNIMPLEMENTED +chapter15/15.4: UNIMPLEMENTED +chapter15/15.5: UNIMPLEMENTED +chapter15/15.6: UNIMPLEMENTED +chapter15/15.7: UNIMPLEMENTED +chapter15/15.9: UNIMPLEMENTED +chapter15/15.10: UNIMPLEMENTED +chapter15/15.12: UNIMPLEMENTED diff --git a/test/es5conform/harness-adapt.js b/test/es5conform/harness-adapt.js new file mode 100644 index 0000000..396d4ed --- /dev/null +++ b/test/es5conform/harness-adapt.js @@ -0,0 +1,74 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +var global = this; + +function ES5Error(ut) { + this.ut = ut; +} + +ES5Error.prototype.toString = function () { + return this.ut.res; +}; + +// The harness uses the IE specific .description property of exceptions but +// that's nothing we can't hack our way around. +Error.prototype.__defineGetter__('description', function () { + return this.message; +}); + +function TestHarness() { + sth.call(this, global); + this._testResults = [] +} + +// Borrow sth's registerTest method. +TestHarness.prototype.registerTest = sth.prototype.registerTest; + +// Drop the before/after stuff, just run the test. +TestHarness.prototype.startTesting = function () { + sth.prototype.run.call(this); + this.report(); +}; + +TestHarness.prototype.report = function () { + for (var i = 0; i < this._testResults.length; i++) { + var ut = this._testResults[i]; + // We don't fail on preconditions. Yet. + if (ut.res == "Precondition failed") + continue; + if (ut.res != 'pass') + throw new ES5Error(ut); + } +}; + +TestHarness.prototype.startingTest = function (ut) { + this.currentTest = ut; + this._testResults.push(ut); +}; + +var ES5Harness = new TestHarness(); diff --git a/test/es5conform/testcfg.py b/test/es5conform/testcfg.py new file mode 100644 index 0000000..d1f23aa --- /dev/null +++ b/test/es5conform/testcfg.py @@ -0,0 +1,108 @@ +# Copyright 2008 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +import test +import os +from os.path import join, exists + + +HARNESS_FILES = ['sth.js'] + + +class ES5ConformTestCase(test.TestCase): + + def __init__(self, filename, path, context, root, mode, framework): + super(ES5ConformTestCase, self).__init__(context, path) + self.filename = filename + self.mode = mode + self.framework = framework + self.root = root + + def IsNegative(self): + return self.filename.endswith('-n.js') + + def GetLabel(self): + return "%s es5conform %s" % (self.mode, self.GetName()) + + def IsFailureOutput(self, output): + if output.exit_code != 0: + return True + return 'FAILED!' in output.stdout + + def GetCommand(self): + result = [self.context.GetVm(self.mode)] + result += ['-e', 'var window = this'] + result += self.framework + result.append(self.filename) + result += ['-e', 'ES5Harness.startTesting()'] + return result + + def GetName(self): + return self.path[-1] + + def GetSource(self): + return open(self.filename).read() + + +class ES5ConformTestConfiguration(test.TestConfiguration): + + def __init__(self, context, root): + super(ES5ConformTestConfiguration, self).__init__(context, root) + + def ListTests(self, current_path, path, mode): + tests = [] + current_root = join(self.root, 'data', 'TestCases') + harness = [] + harness += [join(self.root, 'data', 'SimpleTestHarness', f) for f in HARNESS_FILES] + harness += [join(self.root, 'harness-adapt.js')] + for root, dirs, files in os.walk(current_root): + for dotted in [x for x in dirs if x.startswith('.')]: + dirs.remove(dotted) + root_path = root[len(self.root):].split(os.path.sep) + root_path = current_path + [x for x in root_path if x] + for file in files: + if file.endswith('.js'): + full_path = root_path + [file[:-3]] + full_path = [x for x in full_path if not (x in ['data', 'TestCases'])] + if self.Contains(path, full_path): + test = ES5ConformTestCase(join(root, file), full_path, self.context, + self.root, mode, harness) + tests.append(test) + return tests + + def GetBuildRequirements(self): + return ['sample', 'sample=shell'] + + def GetTestStatus(self, sections, defs): + status_file = join(self.root, 'es5conform.status') + if exists(status_file): + test.ReadConfigurationInto(status_file, sections, defs) + + +def GetConfiguration(context, root): + return ES5ConformTestConfiguration(context, root) diff --git a/test/mjsunit/third_party/object-keys.js b/test/mjsunit/third_party/object-keys.js index 883937d..206ee94 100644 --- a/test/mjsunit/third_party/object-keys.js +++ b/test/mjsunit/third_party/object-keys.js @@ -49,6 +49,7 @@ assertEquals(Object.keys({__proto__:[1,2,3]}), []); var x = []; x.__proto__ = [1, 2, 3]; assertEquals(Object.keys(x), []); +assertEquals(Object.keys(function () {}), []); function argsTest(a, b, c) { assertEquals([], Object.keys(arguments));