|
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 * Date: 19 September 2002 |
|
9 * SUMMARY: Testing Array.prototype.concat() |
|
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 |
|
11 * |
|
12 */ |
|
13 //----------------------------------------------------------------------------- |
|
14 var UBound = 0; |
|
15 var BUGNUMBER = 169795; |
|
16 var summary = 'Testing Array.prototype.concat()'; |
|
17 var status = ''; |
|
18 var statusitems = []; |
|
19 var actual = ''; |
|
20 var actualvalues = []; |
|
21 var expect= ''; |
|
22 var expectedvalues = []; |
|
23 var x; |
|
24 |
|
25 |
|
26 status = inSection(1); |
|
27 x = "Hello"; |
|
28 actual = [].concat(x).toString(); |
|
29 expect = x.toString(); |
|
30 addThis(); |
|
31 |
|
32 status = inSection(2); |
|
33 x = 999; |
|
34 actual = [].concat(x).toString(); |
|
35 expect = x.toString(); |
|
36 addThis(); |
|
37 |
|
38 status = inSection(3); |
|
39 x = /Hello/g; |
|
40 actual = [].concat(x).toString(); |
|
41 expect = x.toString(); |
|
42 addThis(); |
|
43 |
|
44 status = inSection(4); |
|
45 x = new Error("Hello"); |
|
46 actual = [].concat(x).toString(); |
|
47 expect = x.toString(); |
|
48 addThis(); |
|
49 |
|
50 status = inSection(5); |
|
51 x = function() {return "Hello";}; |
|
52 actual = [].concat(x).toString(); |
|
53 expect = x.toString(); |
|
54 addThis(); |
|
55 |
|
56 status = inSection(6); |
|
57 x = [function() {return "Hello";}]; |
|
58 actual = [].concat(x).toString(); |
|
59 expect = x.toString(); |
|
60 addThis(); |
|
61 |
|
62 status = inSection(7); |
|
63 x = [1,2,3].concat([4,5,6]); |
|
64 actual = [].concat(x).toString(); |
|
65 expect = x.toString(); |
|
66 addThis(); |
|
67 |
|
68 status = inSection(8); |
|
69 x = eval('this'); |
|
70 actual = [].concat(x).toString(); |
|
71 expect = x.toString(); |
|
72 addThis(); |
|
73 |
|
74 /* |
|
75 * The next two sections are by igor@icesoft.no; see |
|
76 * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 |
|
77 */ |
|
78 status = inSection(9); |
|
79 x={length:0}; |
|
80 actual = [].concat(x).toString(); |
|
81 expect = x.toString(); |
|
82 addThis(); |
|
83 |
|
84 status = inSection(10); |
|
85 x={length:2, 0:0, 1:1}; |
|
86 actual = [].concat(x).toString(); |
|
87 expect = x.toString(); |
|
88 addThis(); |
|
89 |
|
90 |
|
91 |
|
92 //----------------------------------------------------------------------------- |
|
93 test(); |
|
94 //----------------------------------------------------------------------------- |
|
95 |
|
96 |
|
97 |
|
98 function addThis() |
|
99 { |
|
100 statusitems[UBound] = status; |
|
101 actualvalues[UBound] = actual; |
|
102 expectedvalues[UBound] = expect; |
|
103 UBound++; |
|
104 } |
|
105 |
|
106 |
|
107 function test() |
|
108 { |
|
109 enterFunc('test'); |
|
110 printBugNumber(BUGNUMBER); |
|
111 printStatus(summary); |
|
112 |
|
113 for (var i=0; i<UBound; i++) |
|
114 { |
|
115 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
116 } |
|
117 |
|
118 exitFunc ('test'); |
|
119 } |