~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

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
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
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/
 
9
 *
 
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
 
13
 * License.
 
14
 *
 
15
 * The Original Code is Mozilla Communicator client code, released
 
16
 * March 31, 1998.
 
17
 *
 
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.
 
22
 *
 
23
 * Contributor(s):
 
24
 *
 
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.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
gTestfile = '11.6.1-1.js';
 
40
 
 
41
/**
 
42
   File Name:          11.6.1-1.js
 
43
   ECMA Section:       11.6.1 The addition operator ( + )
 
44
   Description:
 
45
 
 
46
   The addition operator either performs string concatenation or numeric
 
47
   addition.
 
48
 
 
49
   The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression
 
50
   is evaluated as follows:
 
51
 
 
52
   1.  Evaluate AdditiveExpression.
 
53
   2.  Call GetValue(Result(1)).
 
54
   3.  Evaluate MultiplicativeExpression.
 
55
   4.  Call GetValue(Result(3)).
 
56
   5.  Call ToPrimitive(Result(2)).
 
57
   6.  Call ToPrimitive(Result(4)).
 
58
   7.  If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12.
 
59
   (Note that this step differs from step 3 in the algorithm for comparison
 
60
   for the relational operators in using or instead of and.)
 
61
   8.  Call ToNumber(Result(5)).
 
62
   9.  Call ToNumber(Result(6)).
 
63
   10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3).
 
64
   11. Return Result(10).
 
65
   12. Call ToString(Result(5)).
 
66
   13. Call ToString(Result(6)).
 
67
   14. Concatenate Result(12) followed by Result(13).
 
68
   15. Return Result(14).
 
69
 
 
70
   Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6.
 
71
   All native ECMAScript objects except Date objects handle the absence of a
 
72
   hint as if the hint Number were given; Date objects handle the absence of a
 
73
   hint as if the hint String were given. Host objects may handle the absence
 
74
   of a hint in some other manner.
 
75
 
 
76
   This test does not cover cases where the Additive or Mulplicative expression
 
77
   ToPrimitive is string.
 
78
 
 
79
   Author:             christine@netscape.com
 
80
   Date:               12 november 1997
 
81
*/
 
82
var SECTION = "11.6.1-1";
 
83
var VERSION = "ECMA_1";
 
84
startTest();
 
85
 
 
86
writeHeaderToLog( SECTION + " The Addition operator ( + )");
 
87
 
 
88
// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is
 
89
// a boolean primitive and a boolean object.
 
90
 
 
91
new TestCase(   SECTION,
 
92
                "var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2",
 
93
                1,
 
94
                eval("var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2") );
 
95
 
 
96
new TestCase(   SECTION,
 
97
                "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2",
 
98
                1,
 
99
                eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2") );
 
100
 
 
101
new TestCase(   SECTION,
 
102
                "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2",
 
103
                1,
 
104
                eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2") );
 
105
 
 
106
new TestCase(   SECTION,
 
107
                "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2",
 
108
                1,
 
109
                eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") );
 
110
 
 
111
new TestCase(   SECTION,
 
112
                "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2",
 
113
                1,
 
114
                eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2") );
 
115
 
 
116
new TestCase(   SECTION,
 
117
                "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2",
 
118
                "[object Object][object Object]",
 
119
                eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") );
 
120
 
 
121
// tests for number primitive, number object, Object object, a "MyObject" whose value is
 
122
// a number primitive and a number object.
 
123
 
 
124
new TestCase(   SECTION,
 
125
                "var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2",
 
126
                99,
 
127
                eval("var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2") );
 
128
 
 
129
new TestCase(   SECTION,
 
130
                "var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2",
 
131
                99,
 
132
                eval("var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2") );
 
133
 
 
134
new TestCase(   SECTION,
 
135
                "var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2",
 
136
                99,
 
137
                eval("var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2") );
 
138
 
 
139
new TestCase(   SECTION,
 
140
                "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2",
 
141
                99,
 
142
                eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") );
 
143
 
 
144
new TestCase(   SECTION,
 
145
                "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2",
 
146
                99,
 
147
                eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2") );
 
148
 
 
149
new TestCase(   SECTION,
 
150
                "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2",
 
151
                "[object Object][object Object]",
 
152
                eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") );
 
153
 
 
154
 
 
155
test();
 
156
 
 
157
function MyObject( value ) {
 
158
  this.valueOf = new Function( "return this.value" );
 
159
  this.value = value;
 
160
}