1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Array/15.4.4.4-001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,119 @@ 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 + * Date: 19 September 2002 1.12 + * SUMMARY: Testing Array.prototype.concat() 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 1.14 + * 1.15 + */ 1.16 +//----------------------------------------------------------------------------- 1.17 +var UBound = 0; 1.18 +var BUGNUMBER = 169795; 1.19 +var summary = 'Testing Array.prototype.concat()'; 1.20 +var status = ''; 1.21 +var statusitems = []; 1.22 +var actual = ''; 1.23 +var actualvalues = []; 1.24 +var expect= ''; 1.25 +var expectedvalues = []; 1.26 +var x; 1.27 + 1.28 + 1.29 +status = inSection(1); 1.30 +x = "Hello"; 1.31 +actual = [].concat(x).toString(); 1.32 +expect = x.toString(); 1.33 +addThis(); 1.34 + 1.35 +status = inSection(2); 1.36 +x = 999; 1.37 +actual = [].concat(x).toString(); 1.38 +expect = x.toString(); 1.39 +addThis(); 1.40 + 1.41 +status = inSection(3); 1.42 +x = /Hello/g; 1.43 +actual = [].concat(x).toString(); 1.44 +expect = x.toString(); 1.45 +addThis(); 1.46 + 1.47 +status = inSection(4); 1.48 +x = new Error("Hello"); 1.49 +actual = [].concat(x).toString(); 1.50 +expect = x.toString(); 1.51 +addThis(); 1.52 + 1.53 +status = inSection(5); 1.54 +x = function() {return "Hello";}; 1.55 +actual = [].concat(x).toString(); 1.56 +expect = x.toString(); 1.57 +addThis(); 1.58 + 1.59 +status = inSection(6); 1.60 +x = [function() {return "Hello";}]; 1.61 +actual = [].concat(x).toString(); 1.62 +expect = x.toString(); 1.63 +addThis(); 1.64 + 1.65 +status = inSection(7); 1.66 +x = [1,2,3].concat([4,5,6]); 1.67 +actual = [].concat(x).toString(); 1.68 +expect = x.toString(); 1.69 +addThis(); 1.70 + 1.71 +status = inSection(8); 1.72 +x = eval('this'); 1.73 +actual = [].concat(x).toString(); 1.74 +expect = x.toString(); 1.75 +addThis(); 1.76 + 1.77 +/* 1.78 + * The next two sections are by igor@icesoft.no; see 1.79 + * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 1.80 + */ 1.81 +status = inSection(9); 1.82 +x={length:0}; 1.83 +actual = [].concat(x).toString(); 1.84 +expect = x.toString(); 1.85 +addThis(); 1.86 + 1.87 +status = inSection(10); 1.88 +x={length:2, 0:0, 1:1}; 1.89 +actual = [].concat(x).toString(); 1.90 +expect = x.toString(); 1.91 +addThis(); 1.92 + 1.93 + 1.94 + 1.95 +//----------------------------------------------------------------------------- 1.96 +test(); 1.97 +//----------------------------------------------------------------------------- 1.98 + 1.99 + 1.100 + 1.101 +function addThis() 1.102 +{ 1.103 + statusitems[UBound] = status; 1.104 + actualvalues[UBound] = actual; 1.105 + expectedvalues[UBound] = expect; 1.106 + UBound++; 1.107 +} 1.108 + 1.109 + 1.110 +function test() 1.111 +{ 1.112 + enterFunc('test'); 1.113 + printBugNumber(BUGNUMBER); 1.114 + printStatus(summary); 1.115 + 1.116 + for (var i=0; i<UBound; i++) 1.117 + { 1.118 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.119 + } 1.120 + 1.121 + exitFunc ('test'); 1.122 +}