michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: michael@0: /** michael@0: * File Name: regress-7703.js michael@0: * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; michael@0: * Description: See the text of the bugnumber above michael@0: */ michael@0: michael@0: var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) michael@0: var VERSION = "JS1_2"; // Version of JavaScript or ECMA michael@0: var TITLE = "Regression test for bugzilla # 7703"; // Provide ECMA section title or a description michael@0: var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; // Provide URL to bugsplat or bugzilla report michael@0: michael@0: startTest(); // leave this alone michael@0: michael@0: /* michael@0: * Calls to AddTestCase here. AddTestCase is a function that is defined michael@0: * in shell.js and takes three arguments: michael@0: * - a string representation of what is being tested michael@0: * - the expected result michael@0: * - the actual result michael@0: * michael@0: * For example, a test might look like this: michael@0: * michael@0: * var zip = /[\d]{5}$/; michael@0: * michael@0: * AddTestCase( michael@0: * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test michael@0: * "02134", // expected result michael@0: * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result michael@0: * michael@0: */ michael@0: michael@0: types = []; michael@0: function inspect(object) { michael@0: for (prop in object) { michael@0: var x = object[prop]; michael@0: types[types.length] = (typeof x); michael@0: } michael@0: } michael@0: michael@0: var o = {a: 1, b: 2}; michael@0: inspect(o); michael@0: michael@0: AddTestCase( "inspect(o),length", 2, types.length ); michael@0: AddTestCase( "inspect(o)[0]", "number", types[0] ); michael@0: AddTestCase( "inspect(o)[1]", "number", types[1] ); michael@0: michael@0: types_2 = []; michael@0: michael@0: function inspect_again(object) { michael@0: for (prop in object) { michael@0: types_2[types_2.length] = (typeof object[prop]); michael@0: } michael@0: } michael@0: michael@0: inspect_again(o); michael@0: AddTestCase( "inspect_again(o),length", 2, types.length ); michael@0: AddTestCase( "inspect_again(o)[0]", "number", types[0] ); michael@0: AddTestCase( "inspect_again(o)[1]", "number", types[1] ); michael@0: michael@0: michael@0: test(); // leave this alone. this executes the test cases and michael@0: // displays results.