|
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 Filename: general1.js |
|
9 Description: 'This tests out some of the functionality on methods on the Array objects' |
|
10 |
|
11 Author: Nick Lerissa |
|
12 Date: Fri Feb 13 09:58:28 PST 1998 |
|
13 */ |
|
14 |
|
15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
|
16 var VERSION = 'no version'; |
|
17 startTest(); |
|
18 var TITLE = 'String:push,unshift,shift'; |
|
19 |
|
20 writeHeaderToLog('Executing script: general1.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 var array1 = []; |
|
24 |
|
25 array1.push(123); //array1 = [123] |
|
26 array1.push("dog"); //array1 = [123,dog] |
|
27 array1.push(-99); //array1 = [123,dog,-99] |
|
28 array1.push("cat"); //array1 = [123,dog,-99,cat] |
|
29 new TestCase( SECTION, "array1.pop()", array1.pop(),'cat'); |
|
30 //array1 = [123,dog,-99] |
|
31 array1.push("mouse"); //array1 = [123,dog,-99,mouse] |
|
32 new TestCase( SECTION, "array1.shift()", array1.shift(),123); |
|
33 //array1 = [dog,-99,mouse] |
|
34 array1.unshift(96); //array1 = [96,dog,-99,mouse] |
|
35 new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1)); |
|
36 new TestCase( SECTION, "array1.length", array1.length,4); |
|
37 array1.shift(); //array1 = [dog,-99,mouse] |
|
38 array1.shift(); //array1 = [-99,mouse] |
|
39 array1.shift(); //array1 = [mouse] |
|
40 new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse"); |
|
41 new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift())); |
|
42 |
|
43 test(); |
|
44 |