js/src/tests/ecma/String/15.5.2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 15.5.2.js
michael@0 9 ECMA Section: 15.5.2 The String Constructor
michael@0 10 15.5.2.1 new String(value)
michael@0 11 15.5.2.2 new String()
michael@0 12
michael@0 13 Description: When String is called as part of a new expression, it
michael@0 14 is a constructor; it initializes the newly constructed
michael@0 15 object.
michael@0 16
michael@0 17 - The prototype property of the newly constructed
michael@0 18 object is set to the original String prototype object,
michael@0 19 the one that is the intial value of String.prototype
michael@0 20 - The internal [[Class]] property of the object is "String"
michael@0 21 - The value of the object is ToString(value).
michael@0 22 - If no value is specified, its value is the empty string.
michael@0 23
michael@0 24 Author: christine@netscape.com
michael@0 25 Date: 1 october 1997
michael@0 26 */
michael@0 27
michael@0 28 var SECTION = "15.5.2";
michael@0 29 var VERSION = "ECMA_1";
michael@0 30 startTest();
michael@0 31 var TITLE = "The String Constructor";
michael@0 32
michael@0 33 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 34
michael@0 35
michael@0 36 new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') );
michael@0 37 new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 38 new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() );
michael@0 39 new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring );
michael@0 40
michael@0 41 new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) );
michael@0 42 new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 43 new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() );
michael@0 44 new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString );
michael@0 45
michael@0 46 new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) );
michael@0 47 new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 48 new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() );
michael@0 49 new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf );
michael@0 50
michael@0 51 new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) );
michael@0 52 new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 53 new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() );
michael@0 54 new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt );
michael@0 55
michael@0 56 new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) );
michael@0 57 new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 58 new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() );
michael@0 59 new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt );
michael@0 60
michael@0 61 new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) );
michael@0 62 new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 63 new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() );
michael@0 64 new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf );
michael@0 65
michael@0 66 new TestCase( SECTION, "typeof new String()", "object", typeof new String() );
michael@0 67 new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 68 new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() );
michael@0 69 new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf );
michael@0 70
michael@0 71 new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') );
michael@0 72 new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") );
michael@0 73 new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() );
michael@0 74 new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split );
michael@0 75
michael@0 76 test();

mercurial