Debian Codegraph @

rhino/testsrc/tests/ecma/extensions/8.6.2.1-1.js

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