js/src/tests/ecma/Boolean/15.6.4.2-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Boolean/15.6.4.2-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     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 +   File Name:          15.6.4.2.js
    1.12 +   ECMA Section:       15.6.4.2-1 Boolean.prototype.toString()
    1.13 +   Description:        If this boolean value is true, then the string "true"
    1.14 +   is returned; otherwise this boolean value must be false,
    1.15 +   and the string "false" is returned.
    1.16 +
    1.17 +   The toString function is not generic; it generates
    1.18 +   a runtime error if its this value is not a Boolean
    1.19 +   object.  Therefore it cannot be transferred to other
    1.20 +   kinds of objects for use as a method.
    1.21 +
    1.22 +   Author:             christine@netscape.com
    1.23 +   Date:               june 27, 1997
    1.24 +*/
    1.25 +
    1.26 +var SECTION = "15.6.4.2-1";
    1.27 +var VERSION = "ECMA_1";
    1.28 +startTest();
    1.29 +var TITLE   = "Boolean.prototype.toString()"
    1.30 +  writeHeaderToLog( SECTION + TITLE );
    1.31 +
    1.32 +
    1.33 +new TestCase( SECTION,   "new Boolean(1)",       "true",   (new Boolean(1)).toString() );
    1.34 +new TestCase( SECTION,   "new Boolean(0)",       "false",  (new Boolean(0)).toString() );
    1.35 +new TestCase( SECTION,   "new Boolean(-1)",      "true",   (new Boolean(-1)).toString() );
    1.36 +new TestCase( SECTION,   "new Boolean('1')",     "true",   (new Boolean("1")).toString() );
    1.37 +new TestCase( SECTION,   "new Boolean('0')",     "true",   (new Boolean("0")).toString() );
    1.38 +new TestCase( SECTION,   "new Boolean(true)",    "true",   (new Boolean(true)).toString() );
    1.39 +new TestCase( SECTION,   "new Boolean(false)",   "false",  (new Boolean(false)).toString() );
    1.40 +new TestCase( SECTION,   "new Boolean('true')",  "true",   (new Boolean('true')).toString() );
    1.41 +new TestCase( SECTION,   "new Boolean('false')", "true",   (new Boolean('false')).toString() );
    1.42 +
    1.43 +new TestCase( SECTION,   "new Boolean('')",      "false",  (new Boolean('')).toString() );
    1.44 +new TestCase( SECTION,   "new Boolean(null)",    "false",  (new Boolean(null)).toString() );
    1.45 +new TestCase( SECTION,   "new Boolean(void(0))", "false",  (new Boolean(void(0))).toString() );
    1.46 +new TestCase( SECTION,   "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() );
    1.47 +new TestCase( SECTION,   "new Boolean(NaN)",     "false",  (new Boolean(Number.NaN)).toString() );
    1.48 +new TestCase( SECTION,   "new Boolean()",        "false",  (new Boolean()).toString() );
    1.49 +new TestCase( SECTION,   "new Boolean(x=1)",     "true",   (new Boolean(x=1)).toString() );
    1.50 +new TestCase( SECTION,   "new Boolean(x=0)",     "false",  (new Boolean(x=0)).toString() );
    1.51 +new TestCase( SECTION,   "new Boolean(x=false)", "false",  (new Boolean(x=false)).toString() );
    1.52 +new TestCase( SECTION,   "new Boolean(x=true)",  "true",   (new Boolean(x=true)).toString() );
    1.53 +new TestCase( SECTION,   "new Boolean(x=null)",  "false",  (new Boolean(x=null)).toString() );
    1.54 +new TestCase( SECTION,   "new Boolean(x='')",    "false",  (new Boolean(x="")).toString() );
    1.55 +new TestCase( SECTION,   "new Boolean(x=' ')",   "true",   (new Boolean(x=" ")).toString() );
    1.56 +
    1.57 +new TestCase( SECTION,   "new Boolean(new MyObject(true))",     "true",   (new Boolean(new MyObject(true))).toString() );
    1.58 +new TestCase( SECTION,   "new Boolean(new MyObject(false))",    "true",   (new Boolean(new MyObject(false))).toString() );
    1.59 +
    1.60 +test();
    1.61 +
    1.62 +function MyObject( value ) {
    1.63 +  this.value = value;
    1.64 +  this.valueOf = new Function( "return this.value" );
    1.65 +  return this;
    1.66 +}

mercurial