|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 |
|
8 /** |
|
9 * File Name: regress-7703.js |
|
10 * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; |
|
11 * Description: See the text of the bugnumber above |
|
12 */ |
|
13 |
|
14 var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) |
|
15 var VERSION = "JS1_2"; // Version of JavaScript or ECMA |
|
16 var TITLE = "Regression test for bugzilla # 7703"; // Provide ECMA section title or a description |
|
17 var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; // Provide URL to bugsplat or bugzilla report |
|
18 |
|
19 startTest(); // leave this alone |
|
20 |
|
21 /* |
|
22 * Calls to AddTestCase here. AddTestCase is a function that is defined |
|
23 * in shell.js and takes three arguments: |
|
24 * - a string representation of what is being tested |
|
25 * - the expected result |
|
26 * - the actual result |
|
27 * |
|
28 * For example, a test might look like this: |
|
29 * |
|
30 * var zip = /[\d]{5}$/; |
|
31 * |
|
32 * AddTestCase( |
|
33 * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test |
|
34 * "02134", // expected result |
|
35 * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result |
|
36 * |
|
37 */ |
|
38 |
|
39 types = []; |
|
40 function inspect(object) { |
|
41 for (prop in object) { |
|
42 var x = object[prop]; |
|
43 types[types.length] = (typeof x); |
|
44 } |
|
45 } |
|
46 |
|
47 var o = {a: 1, b: 2}; |
|
48 inspect(o); |
|
49 |
|
50 AddTestCase( "inspect(o),length", 2, types.length ); |
|
51 AddTestCase( "inspect(o)[0]", "number", types[0] ); |
|
52 AddTestCase( "inspect(o)[1]", "number", types[1] ); |
|
53 |
|
54 types_2 = []; |
|
55 |
|
56 function inspect_again(object) { |
|
57 for (prop in object) { |
|
58 types_2[types_2.length] = (typeof object[prop]); |
|
59 } |
|
60 } |
|
61 |
|
62 inspect_again(o); |
|
63 AddTestCase( "inspect_again(o),length", 2, types.length ); |
|
64 AddTestCase( "inspect_again(o)[0]", "number", types[0] ); |
|
65 AddTestCase( "inspect_again(o)[1]", "number", types[1] ); |
|
66 |
|
67 |
|
68 test(); // leave this alone. this executes the test cases and |
|
69 // displays results. |