~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma/Expressions/11.2.1-3-n.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
7
/**
 
8
   File Name:          11.2.1-2.js
 
9
   ECMA Section:       11.2.1 Property Accessors
 
10
   Description:
 
11
 
 
12
   Properties are accessed by name, using either the dot notation:
 
13
   MemberExpression . Identifier
 
14
   CallExpression . Identifier
 
15
 
 
16
   or the bracket notation:    MemberExpression [ Expression ]
 
17
   CallExpression [ Expression ]
 
18
 
 
19
   The dot notation is explained by the following syntactic conversion:
 
20
   MemberExpression . Identifier
 
21
   is identical in its behavior to
 
22
   MemberExpression [ <identifier-string> ]
 
23
   and similarly
 
24
   CallExpression . Identifier
 
25
   is identical in its behavior to
 
26
   CallExpression [ <identifier-string> ]
 
27
   where <identifier-string> is a string literal containing the same sequence
 
28
   of characters as the Identifier.
 
29
 
 
30
   The production MemberExpression : MemberExpression [ Expression ] is
 
31
   evaluated as follows:
 
32
 
 
33
   1.  Evaluate MemberExpression.
 
34
   2.  Call GetValue(Result(1)).
 
35
   3.  Evaluate Expression.
 
36
   4.  Call GetValue(Result(3)).
 
37
   5.  Call ToObject(Result(2)).
 
38
   6.  Call ToString(Result(4)).
 
39
   7.  Return a value of type Reference whose base object is Result(5) and
 
40
   whose property name is Result(6).
 
41
 
 
42
   The production CallExpression : CallExpression [ Expression ] is evaluated
 
43
   in exactly the same manner, except that the contained CallExpression is
 
44
   evaluated in step 1.
 
45
 
 
46
   Author:             christine@netscape.com
 
47
   Date:               12 november 1997
 
48
*/
 
49
var SECTION = "11.2.1-2";
 
50
var VERSION = "ECMA_1";
 
51
startTest();
 
52
var TITLE   = "Property Accessors";
 
53
writeHeaderToLog( SECTION + " "+TITLE );
 
54
 
 
55
// go through all Native Function objects, methods, and properties and get their typeof.
 
56
 
 
57
var PROPERTY = new Array();
 
58
var p = 0;
 
59
 
 
60
// try to access properties of primitive types
 
61
 
 
62
PROPERTY[p++] = new Property(  "undefined",    void 0,   "undefined",   NaN );
 
63
 
 
64
for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) {
 
65
 
 
66
  DESCRIPTION = PROPERTY[i].object + ".valueOf()";
 
67
  EXPECTED = "error";
 
68
 
 
69
  new TestCase( SECTION,
 
70
                PROPERTY[i].object + ".valueOf()",
 
71
                PROPERTY[i].value,
 
72
                eval( PROPERTY[i].object+ ".valueOf()" ) );
 
73
 
 
74
  new TestCase( SECTION,
 
75
                PROPERTY[i].object + ".toString()",
 
76
                PROPERTY[i].string,
 
77
                eval(PROPERTY[i].object+ ".toString()") );
 
78
}
 
79
test();
 
80
 
 
81
 
 
82
function MyObject( value ) {
 
83
  this.value = value;
 
84
  this.stringValue = value +"";
 
85
  this.numberValue = Number(value);
 
86
  return this;
 
87
}
 
88
 
 
89
function Property( object, value, string, number ) {
 
90
  this.object = object;
 
91
  this.string = String(value);
 
92
  this.number = Number(value);
 
93
  this.value = value;
 
94
}