diff --git a/test/mjsunit/bugs/bug-1231206.js b/test/mjsunit/bugs/bug-1231206.js new file mode 100644 index 0000000000..3b6cb60d66 --- /dev/null +++ b/test/mjsunit/bugs/bug-1231206.js @@ -0,0 +1,39 @@ +// Copyright 2008 Google Inc. 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. + +// When calling user-defined functions on strings, booleans or +// numbers, we should create a wrapper object. + +function TypeOfThis() { return typeof this; } + +String.prototype.TypeOfThis = TypeOfThis; +Boolean.prototype.TypeOfThis = TypeOfThis; +Number.prototype.TypeOfThis = TypeOfThis; + +assertEquals('object', 'xxx'.TypeOfThis()); +assertEquals('object', true.TypeOfThis()); +assertEquals('object', (42).TypeOfThis()); diff --git a/test/mjsunit/bugs/bug-1344252.js b/test/mjsunit/bugs/bug-1344252.js new file mode 100644 index 0000000000..436ece9c47 --- /dev/null +++ b/test/mjsunit/bugs/bug-1344252.js @@ -0,0 +1,79 @@ +// Copyright 2008 Google Inc. 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. + +// Test that setter accessors added to the prototype chain are called +// when setting properties. + +// Test that accessors added to the prototype chain are called +// eventhough there are inline caches for setting the property + +function F() { + this.x = 42; + this.y = 87; +} + +// Force the inline caches to monomorphic state. +new F(); new F(); + +// Add a setter for x to Object.prototype and make sure it gets +// called. +var result_x; +Object.prototype.__defineSetter__('x', function(value) { result_x = value; }); +var f = new F(); +assertEquals(42, result_x); +assertTrue(typeof f.x == 'undefined'); + +// Add a setter for y by changing the prototype of f and make sure +// that gets called too. +var result_y; +var proto = new Object(); +proto.__defineSetter__('y', function (value) { result_y = value; }); +var f = new F(); +f.y = undefined; +f.__proto__ = proto; +F.call(f); +assertEquals(87, result_y); +assertTrue(typeof f.y == 'undefined'); + + +// Test the same issue in the runtime system. Make sure that +// accessors added to the prototype chain are called instead of +// following map transitions. +// +// Create two objects. +var result_z; +var o1 = new Object(); +var o2 = new Object(); +// Add a z property to o1 to create a map transition. +o1.z = 32; +// Add a z accessor in the prototype chain for o1 and o2. +Object.prototype.__defineSetter__('z', function(value) { result_z = value; }); +// The accessor should be called for o2. +o2.z = 27; +assertEquals(27, result_z); +assertTrue(typeof o2.z == 'undefined'); + diff --git a/test/mjsunit/bugs/bug-900066.js b/test/mjsunit/bugs/bug-900066.js new file mode 100644 index 0000000000..b0d0db8cfe --- /dev/null +++ b/test/mjsunit/bugs/bug-900066.js @@ -0,0 +1,38 @@ +// Copyright 2008 Google Inc. 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. + +// When a property of the arguments array is deleted, it +// must be "disconnected" from the corresponding parameter. +// Re-introducing the property does not connect to the parameter. + +function f(x) { + delete arguments[0]; + arguments[0] = 100; + return x; +} + +assertEquals(10, f(10)); diff --git a/test/mjsunit/bugs/bug-941049.js b/test/mjsunit/bugs/bug-941049.js new file mode 100644 index 0000000000..9a6fe6dbed --- /dev/null +++ b/test/mjsunit/bugs/bug-941049.js @@ -0,0 +1,100 @@ +// Copyright 2008 Google Inc. 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. + +// This test fails because we copy the arguments array on indirect +// access + +function g(f) { + assertEquals(100, f.arguments = 100); // read-only + assertEquals(3, f.arguments.length); + assertEquals(1, f.arguments[0]); + assertEquals(2, f.arguments[1]); + assertEquals(3, f.arguments[2]); + f.arguments[0] = 999; + f.arguments.extra = 'kallevip'; +} + +function h(f) { + assertEquals('kallevip', f.arguments.extra); + return f.arguments; +} + +// Test function with a materialized arguments array. +function f0() { + g(f0); + var result = h(f0); + var a = arguments; + assertEquals(999, a[0]); + return result; +} + + +// Test function without a materialized arguments array. +function f1(x) { + g(f1); + var result = h(f1); + assertEquals(999, x); + return result; +} + + +function test(f) { + assertTrue(null === f.arguments); + var args = f(1,2,3); + assertTrue(null === f.arguments); + + assertEquals(3, args.length); + assertEquals(999, args[0]); + assertEquals(2, args[1]); + assertEquals(3, args[2]); + assertEquals('kallevip', args.extra); +} + +test(f0); +test(f1); + + + + +function w() { + return q.arguments; +} + +function q(x, y) { + x = 2; + var result = w(); + y = 3; + return result; +} + +var a = q(0, 1); +// x is set locally *before* the last use of arguments before the +// activation of q is popped from the stack. +assertEquals(2, a[0]); +// y is set locally *after* the last use of arguments before the +// activation of q is popped from the stack. +assertEquals(1, a[1]); diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status new file mode 100644 index 0000000000..145aeab563 --- /dev/null +++ b/test/mjsunit/mjsunit.status @@ -0,0 +1,36 @@ +# Copyright 2008 Google Inc. 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 mjsunit + +# All tests in the bug directory are expected to fail. + +bugs: FAIL + +# This one fails in debug mode. + +regexp-multiline-stack-trace: PASS IF $MODE==RELEASE, FAIL IF $MODE==DEBUG diff --git a/test/mjsunit/testcfg.py b/test/mjsunit/testcfg.py index bd056d54c7..67ee85d3ef 100644 --- a/test/mjsunit/testcfg.py +++ b/test/mjsunit/testcfg.py @@ -27,7 +27,7 @@ import test import os -from os.path import join, dirname +from os.path import join, dirname, exists import re @@ -41,7 +41,7 @@ class MjsunitTestCase(test.TestCase): self.file = file self.config = config self.mode = mode - + def GetLabel(self): return "%s %s" % (self.mode, self.GetName()) @@ -63,7 +63,7 @@ class MjsunitTestConfiguration(test.TestConfiguration): def __init__(self, context, root): super(MjsunitTestConfiguration, self).__init__(context, root) - + def Ls(self, path): def SelectTest(name): return name.endswith('.js') and name != 'mjsunit.js' @@ -72,18 +72,24 @@ class MjsunitTestConfiguration(test.TestConfiguration): def ListTests(self, current_path, path, mode): mjsunit = [current_path + [t] for t in self.Ls(self.root)] regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))] - all_tests = mjsunit + regress + bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))] + all_tests = mjsunit + regress + bugs result = [] for test in all_tests: if self.Contains(path, test): - full_name = current_path + test file_path = join(self.root, reduce(join, test[1:], "") + ".js") - result.append(MjsunitTestCase(full_name, file_path, mode, self.context, self)) + result.append(MjsunitTestCase(test, file_path, mode, self.context, self)) return result def GetBuildRequirements(self): return ['sample', 'sample=shell'] + def GetTestStatus(self, sections, defs): + status_file = join(self.root, 'mjsunit.status') + if exists(status_file): + test.ReadConfigurationInto(status_file, sections, defs) + + def GetConfiguration(context, root): return MjsunitTestConfiguration(context, root) diff --git a/test/mozilla/testcfg.py b/test/mozilla/testcfg.py index ea638b83da..0214f9b238 100644 --- a/test/mozilla/testcfg.py +++ b/test/mozilla/testcfg.py @@ -120,6 +120,11 @@ class MozillaTestConfiguration(test.TestConfiguration): def GetBuildRequirements(self): return ['sample', 'sample=shell'] + def GetTestStatus(self, sections, defs): + status_file = join(self.root, 'mozilla.status') + if exists(status_file): + test.ReadConfigurationInto(status_file, sections, defs) + def GetConfiguration(context, root): return MozillaTestConfiguration(context, root) diff --git a/tools/test.py b/tools/test.py index 95398e0c15..b7d7d4c5cf 100755 --- a/tools/test.py +++ b/tools/test.py @@ -355,6 +355,9 @@ class TestConfiguration(object): return False return True + def GetTestStatus(self, sections, defs): + pass + class TestSuite(object): @@ -393,6 +396,9 @@ class TestRepository(TestSuite): def ListTests(self, current_path, path, context, mode): return self.GetConfiguration(context).ListTests(current_path, path, mode) + def GetTestStatus(self, context, sections, defs): + self.GetConfiguration(context).GetTestStatus(sections, defs) + class LiteralTestSuite(TestSuite): @@ -418,6 +424,10 @@ class LiteralTestSuite(TestSuite): result += test.ListTests(full_path, path, context, mode) return result + def GetTestStatus(self, context, sections, defs): + for test in self.tests: + test.GetTestStatus(context, sections, defs) + PREFIX = {'debug': '_g', 'release': ''} @@ -866,15 +876,6 @@ def ReadConfigurationInto(path, sections, defs): return True -def ReadConfiguration(paths): - sections = [ ] - defs = { } - for path in paths: - if not ReadConfigurationInto(path, sections, defs): - return None - return Configuration(sections, defs) - - # --------------- # --- M a i n --- # --------------- @@ -889,9 +890,6 @@ def BuildOptions(): result.add_option("-p", "--progress", help="The style of progress indicator (verbose, dots, color, mono)", choices=PROGRESS_INDICATORS.keys(), default="mono") - result.add_option("-c", "--config", - help="Use this test expectation configuration", - default=[], action="append") result.add_option("--no-build", help="Don't build requirements", default=False, action="store_true") result.add_option("--report", help="Print a summary of the tests to be run", @@ -969,9 +967,6 @@ def Main(): if not ProcessOptions(options): parser.print_help() return 1 - config = ReadConfiguration(options.config) - if not config: - return 1 workspace = abspath(join(dirname(sys.argv[0]), '..')) repositories = [TestRepository(join(workspace, 'test', name)) for name in BUILT_IN_TESTS] @@ -1000,7 +995,13 @@ def Main(): if not BuildRequirements(context, reqs, options.mode): return 1 - # Then list the tests + # Get status for tests + sections = [ ] + defs = { } + root.GetTestStatus(context, sections, defs) + config = Configuration(sections, defs) + + # List the tests all_cases = [ ] all_unused = [ ] for path in paths: