js/src/tests/ecma/ObjectObjects/15.2.4.3.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.

     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/. */
     7 /**
     8    File Name:          15.2.4.3.js
     9    ECMA Section:       15.2.4.3 Object.prototype.valueOf()
    11    Description:        As a rule, the valueOf method for an object simply
    12    returns the object; but if the object is a "wrapper"
    13    for a host object, as may perhaps be created by the
    14    Object constructor, then the contained host object
    15    should be returned.
    17    This only covers native objects.
    19    Author:             christine@netscape.com
    20    Date:               28 october 1997
    22 */
    23 var SECTION = "15.2.4.3";
    24 var VERSION = "ECMA_1";
    25 startTest();
    26 var TITLE   = "Object.prototype.valueOf()";
    28 writeHeaderToLog( SECTION + " "+ TITLE);
    31 var myarray = new Array();
    32 myarray.valueOf = Object.prototype.valueOf;
    33 var myboolean = new Boolean();
    34 myboolean.valueOf = Object.prototype.valueOf;
    35 var myfunction = new Function();
    36 myfunction.valueOf = Object.prototype.valueOf;
    37 var myobject = new Object();
    38 myobject.valueOf = Object.prototype.valueOf;
    39 var mymath = Math;
    40 mymath.valueOf = Object.prototype.valueOf;
    41 var mydate = new Date();
    42 mydate.valueOf = Object.prototype.valueOf;
    43 var mynumber = new Number();
    44 mynumber.valueOf = Object.prototype.valueOf;
    45 var mystring = new String();
    46 mystring.valueOf = Object.prototype.valueOf;
    48 new TestCase( SECTION,  "Object.prototype.valueOf.length",      0,      Object.prototype.valueOf.length );
    50 new TestCase( SECTION,
    51 	      "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()",
    52 	      myarray,
    53 	      myarray.valueOf() );
    54 new TestCase( SECTION,
    55 	      "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()",
    56 	      myboolean,
    57 	      myboolean.valueOf() );
    58 new TestCase( SECTION,
    59 	      "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()",
    60 	      myfunction,
    61 	      myfunction.valueOf() );
    62 new TestCase( SECTION,
    63 	      "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()",
    64 	      myobject,
    65 	      myobject.valueOf() );
    66 new TestCase( SECTION,
    67 	      "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()",
    68 	      mymath,
    69 	      mymath.valueOf() );
    70 new TestCase( SECTION,
    71 	      "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()",
    72 	      mynumber,
    73 	      mynumber.valueOf() );
    74 new TestCase( SECTION,
    75 	      "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()",
    76 	      mystring,
    77 	      mystring.valueOf() );
    78 new TestCase( SECTION,
    79 	      "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()",
    80 	      mydate,
    81 	      mydate.valueOf() );
    83 test();

mercurial