js/src/tests/js1_2/regress/regress-7703.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/regress/regress-7703.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +
    1.11 +/**
    1.12 + *  File Name:          regress-7703.js
    1.13 + *  Reference:          "http://bugzilla.mozilla.org/show_bug.cgi?id=7703";
    1.14 + *  Description:        See the text of the bugnumber above
    1.15 + */
    1.16 +
    1.17 +var SECTION = "js1_2";       // provide a document reference (ie, ECMA section)
    1.18 +var VERSION = "JS1_2"; // Version of JavaScript or ECMA
    1.19 +var TITLE   = "Regression test for bugzilla # 7703";       // Provide ECMA section title or a description
    1.20 +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703";     // Provide URL to bugsplat or bugzilla report
    1.21 +
    1.22 +startTest();               // leave this alone
    1.23 +
    1.24 +/*
    1.25 + * Calls to AddTestCase here. AddTestCase is a function that is defined
    1.26 + * in shell.js and takes three arguments:
    1.27 + * - a string representation of what is being tested
    1.28 + * - the expected result
    1.29 + * - the actual result
    1.30 + *
    1.31 + * For example, a test might look like this:
    1.32 + *
    1.33 + * var zip = /[\d]{5}$/;
    1.34 + *
    1.35 + * AddTestCase(
    1.36 + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)",   // description of the test
    1.37 + *  "02134",                                                           // expected result
    1.38 + *  "PO Box 12345 Boston, MA 02134".match(zip) );                      // actual result
    1.39 + *
    1.40 + */
    1.41 +
    1.42 +types = [];
    1.43 +function inspect(object) {
    1.44 +  for (prop in object) {
    1.45 +    var x = object[prop];
    1.46 +    types[types.length] = (typeof x);
    1.47 +  }
    1.48 +}
    1.49 +
    1.50 +var o = {a: 1, b: 2};
    1.51 +inspect(o);
    1.52 +
    1.53 +AddTestCase( "inspect(o),length",   2,       types.length );
    1.54 +AddTestCase( "inspect(o)[0]",      "number", types[0] );
    1.55 +AddTestCase( "inspect(o)[1]",      "number", types[1] );
    1.56 +
    1.57 +types_2 = [];
    1.58 +
    1.59 +function inspect_again(object) {
    1.60 +  for (prop in object) {
    1.61 +    types_2[types_2.length] = (typeof object[prop]);
    1.62 +  }
    1.63 +}
    1.64 +
    1.65 +inspect_again(o);
    1.66 +AddTestCase( "inspect_again(o),length",   2,       types.length );
    1.67 +AddTestCase( "inspect_again(o)[0]",      "number", types[0] );
    1.68 +AddTestCase( "inspect_again(o)[1]",      "number", types[1] );
    1.69 +
    1.70 +
    1.71 +test();       // leave this alone.  this executes the test cases and
    1.72 +// displays results.

mercurial