js/src/tests/ecma/String/15.5.1.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.1.js
michael@0 9 ECMA Section: 15.5.1 The String Constructor called as a Function
michael@0 10 15.5.1.1 String(value)
michael@0 11 15.5.1.2 String()
michael@0 12
michael@0 13 Description: When String is called as a function rather than as
michael@0 14 a constructor, it performs a type conversion.
michael@0 15 - String(value) returns a string value (not a String
michael@0 16 object) computed by ToString(value)
michael@0 17 - String() returns the empty string ""
michael@0 18
michael@0 19 Author: christine@netscape.com
michael@0 20 Date: 1 october 1997
michael@0 21 */
michael@0 22
michael@0 23 var SECTION = "15.5.1";
michael@0 24 var VERSION = "ECMA_1";
michael@0 25 startTest();
michael@0 26 var TITLE = "The String Constructor Called as a Function";
michael@0 27
michael@0 28 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 29
michael@0 30 new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') );
michael@0 31 new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) );
michael@0 32 new TestCase( SECTION, "String(null)", "null", String( null ) );
michael@0 33 new TestCase( SECTION, "String(true)", "true", String( true) );
michael@0 34 new TestCase( SECTION, "String(false)", "false", String( false ) );
michael@0 35 new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) );
michael@0 36 new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) );
michael@0 37 new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) );
michael@0 38 new TestCase( SECTION, "String(new Array())", "", String( new Array()) );
michael@0 39 new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) );
michael@0 40
michael@0 41
michael@0 42 new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) );
michael@0 43 new TestCase( SECTION, "String( 0 )", "0", String( 0 ) );
michael@0 44 new TestCase( SECTION, "String( -0 )", "0", String( -0 ) );
michael@0 45 new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) );
michael@0 46 new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) );
michael@0 47 new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) );
michael@0 48
michael@0 49 // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21
michael@0 50
michael@0 51 new TestCase( SECTION, "String( 1 )", "1", String( 1 ) );
michael@0 52 new TestCase( SECTION, "String( 10 )", "10", String( 10 ) );
michael@0 53 new TestCase( SECTION, "String( 100 )", "100", String( 100 ) );
michael@0 54 new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) );
michael@0 55 new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) );
michael@0 56 new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) );
michael@0 57 new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) );
michael@0 58 new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) );
michael@0 59
michael@0 60 new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) );
michael@0 61 new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) );
michael@0 62
michael@0 63 new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) );
michael@0 64 new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) );
michael@0 65 new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) );
michael@0 66 new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) );
michael@0 67 new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) );
michael@0 68 new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) );
michael@0 69 new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) );
michael@0 70 new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) );
michael@0 71
michael@0 72 new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) );
michael@0 73 new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) );
michael@0 74
michael@0 75 // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21,
michael@0 76 new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) );
michael@0 77
michael@0 78
michael@0 79 // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0
michael@0 80
michael@0 81 // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6
michael@0 82
michael@0 83 new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) );
michael@0 84 new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) );
michael@0 85
michael@0 86 // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6
michael@0 87 new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345));
michael@0 88 new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 ));
michael@0 89
michael@0 90 new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) );
michael@0 91 new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) );
michael@0 92 new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) );
michael@0 93 new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) );
michael@0 94 new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) );
michael@0 95 new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) );
michael@0 96 new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345));
michael@0 97
michael@0 98 new TestCase( "15.5.2", "String()", "", String() );
michael@0 99
michael@0 100 test();

mercurial