Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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: 8.6.2.1-1.js |
michael@0 | 9 | ECMA Section: 8.6.2.1 Get (Value) |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | When the [[Get]] method of O is called with property name P, the following |
michael@0 | 13 | steps are taken: |
michael@0 | 14 | |
michael@0 | 15 | 1. If O doesn't have a property with name P, go to step 4. |
michael@0 | 16 | 2. Get the value of the property. |
michael@0 | 17 | 3. Return Result(2). |
michael@0 | 18 | 4. If the [[Prototype]] of O is null, return undefined. |
michael@0 | 19 | 5. Call the [[Get]] method of [[Prototype]] with property name P. |
michael@0 | 20 | 6. Return Result(5). |
michael@0 | 21 | |
michael@0 | 22 | This tests [[Get]] (Value). |
michael@0 | 23 | |
michael@0 | 24 | Author: christine@netscape.com |
michael@0 | 25 | Date: 12 november 1997 |
michael@0 | 26 | */ |
michael@0 | 27 | var SECTION = "8.6.2.1-1"; |
michael@0 | 28 | var VERSION = "ECMA_1"; |
michael@0 | 29 | startTest(); |
michael@0 | 30 | |
michael@0 | 31 | writeHeaderToLog( SECTION + " [[Get]] (Value)"); |
michael@0 | 32 | |
michael@0 | 33 | new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); |
michael@0 | 34 | // new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); |
michael@0 | 35 | new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); |
michael@0 | 36 | |
michael@0 | 37 | new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); |
michael@0 | 38 | // new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); |
michael@0 | 39 | new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); |
michael@0 | 40 | |
michael@0 | 41 | new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); |
michael@0 | 42 | // new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); |
michael@0 | 43 | new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); |
michael@0 | 44 | |
michael@0 | 45 | test(); |
michael@0 | 46 | |
michael@0 | 47 | function MyProtoValuelessObject(value) { |
michael@0 | 48 | this.valueOf = new Function ( "" ); |
michael@0 | 49 | this.__proto__ = null; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function MyProtolessObject( value ) { |
michael@0 | 53 | this.valueOf = new Function( "return this.value" ); |
michael@0 | 54 | this.__proto__ = null; |
michael@0 | 55 | this.value = value; |
michael@0 | 56 | } |
michael@0 | 57 | function MyValuelessObject(value) { |
michael@0 | 58 | this.__proto__ = new MyPrototypeObject(value); |
michael@0 | 59 | } |
michael@0 | 60 | function MyPrototypeObject(value) { |
michael@0 | 61 | this.valueOf = new Function( "return this.value;" ); |
michael@0 | 62 | this.toString = new Function( "return (this.value + '');" ); |
michael@0 | 63 | this.value = value; |
michael@0 | 64 | } |