1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 File Name: 11.2.1-4-n.js
42 ECMA Section: 11.2.1 Property Accessors
45 Properties are accessed by name, using either the dot notation:
46 MemberExpression . Identifier
47 CallExpression . Identifier
49 or the bracket notation: MemberExpression [ Expression ]
50 CallExpression [ Expression ]
52 The dot notation is explained by the following syntactic conversion:
53 MemberExpression . Identifier
54 is identical in its behavior to
55 MemberExpression [ <identifier-string> ]
57 CallExpression . Identifier
58 is identical in its behavior to
59 CallExpression [ <identifier-string> ]
60 where <identifier-string> is a string literal containing the same sequence
61 of characters as the Identifier.
63 The production MemberExpression : MemberExpression [ Expression ] is
66 1. Evaluate MemberExpression.
67 2. Call GetValue(Result(1)).
68 3. Evaluate Expression.
69 4. Call GetValue(Result(3)).
70 5. Call ToObject(Result(2)).
71 6. Call ToString(Result(4)).
72 7. Return a value of type Reference whose base object is Result(5) and
73 whose property name is Result(6).
75 The production CallExpression : CallExpression [ Expression ] is evaluated
76 in exactly the same manner, except that the contained CallExpression is
79 Author: christine@netscape.com
80 Date: 12 november 1997
82 var SECTION = "11.2.1-4-n";
83 var VERSION = "ECMA_1";
85 var TITLE = "Property Accessors";
86 writeHeaderToLog( SECTION + " "+TITLE );
88 // go through all Native Function objects, methods, and properties and get their typeof.
90 var PROPERTY = new Array();
93 // try to access properties of primitive types
95 PROPERTY[p++] = new Property( "null", null, "null", 0 );
97 for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) {
99 DESCRIPTION = PROPERTY[i].object + ".valueOf()";
102 new TestCase( SECTION,
103 PROPERTY[i].object + ".valueOf()",
105 eval( PROPERTY[i].object+ ".valueOf()" ) );
107 new TestCase( SECTION,
108 PROPERTY[i].object + ".toString()",
110 eval(PROPERTY[i].object+ ".toString()") );
116 function MyObject( value ) {
118 this.stringValue = value +"";
119 this.numberValue = Number(value);
122 function Property( object, value, string, number ) {
123 this.object = object;
124 this.string = String(value);
125 this.number = Number(value);