js/src/tests/js1_2/Array/general1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/Array/general1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     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 +   Filename:     general1.js
    1.12 +   Description:  'This tests out some of the functionality on methods on the Array objects'
    1.13 +
    1.14 +   Author:       Nick Lerissa
    1.15 +   Date:         Fri Feb 13 09:58:28 PST 1998
    1.16 +*/
    1.17 +
    1.18 +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
    1.19 +var VERSION = 'no version';
    1.20 +startTest();
    1.21 +var TITLE = 'String:push,unshift,shift';
    1.22 +
    1.23 +writeHeaderToLog('Executing script: general1.js');
    1.24 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.25 +
    1.26 +var array1 = [];
    1.27 +
    1.28 +array1.push(123);            //array1 = [123]
    1.29 +array1.push("dog");          //array1 = [123,dog]
    1.30 +array1.push(-99);            //array1 = [123,dog,-99]
    1.31 +array1.push("cat");          //array1 = [123,dog,-99,cat]
    1.32 +new TestCase( SECTION, "array1.pop()", array1.pop(),'cat');
    1.33 +//array1 = [123,dog,-99]
    1.34 +array1.push("mouse");        //array1 = [123,dog,-99,mouse]
    1.35 +new TestCase( SECTION, "array1.shift()", array1.shift(),123);
    1.36 +//array1 = [dog,-99,mouse]
    1.37 +array1.unshift(96);          //array1 = [96,dog,-99,mouse]
    1.38 +new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1));
    1.39 +new TestCase( SECTION, "array1.length", array1.length,4);
    1.40 +array1.shift();              //array1 = [dog,-99,mouse]
    1.41 +array1.shift();              //array1 = [-99,mouse]
    1.42 +array1.shift();              //array1 = [mouse]
    1.43 +new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse");
    1.44 +new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift()));
    1.45 +
    1.46 +test();
    1.47 +

mercurial