|
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 var BUGNUMBER = 433672; |
|
8 var summary = 'operator evaluation order'; |
|
9 var actual = ''; |
|
10 var expect = ''; |
|
11 |
|
12 function makeObject(label) |
|
13 { |
|
14 var o = (function (){}); |
|
15 |
|
16 o.label = label; |
|
17 o.valueOf = (function() { actual += this.label + ' valueOf, '; return Object.prototype.valueOf.call(this); }); |
|
18 o.toString = (function() { actual += this.label + ' toString, '; return Object.prototype.toString.call(this); }); |
|
19 |
|
20 return o; |
|
21 } |
|
22 |
|
23 operators = [ |
|
24 {section: '11.5.1', operator: '*'}, |
|
25 {section: '11.5.2', operator: '/'}, |
|
26 {section: '11.5.3', operator: '%'}, |
|
27 {section: '11.6.1', operator: '+'}, |
|
28 {section: '11.6.2', operator: '-'}, |
|
29 {section: '11.7.1', operator: '<<'}, |
|
30 {section: '11.7.2', operator: '>>'}, |
|
31 {section: '11.7.3', operator: '>>>'}, |
|
32 {section: '11.8.1', operator: '<'}, |
|
33 {section: '11.8.2', operator: '>'}, |
|
34 {section: '11.8.3', operator: '<='}, |
|
35 {section: '11.8.4', operator: '>='}, |
|
36 {section: '11.10', operator: '&'}, |
|
37 {section: '11.10', operator: '^'}, |
|
38 {section: '11.10', operator: '|'}, |
|
39 {section: '11.13.2', operator: '*='}, |
|
40 {section: '11.13.2', operator: '/='}, |
|
41 {section: '11.13.2', operator: '%='}, |
|
42 {section: '11.13.2', operator: '+='}, |
|
43 {section: '11.13.2', operator: '<<='}, |
|
44 {section: '11.13.2', operator: '>>='}, |
|
45 {section: '11.13.2', operator: '>>>='}, |
|
46 {section: '11.13.2', operator: '&='}, |
|
47 {section: '11.13.2', operator: '^='}, |
|
48 {section: '11.13.2', operator: '|='}, |
|
49 ]; |
|
50 |
|
51 //----------------------------------------------------------------------------- |
|
52 test(); |
|
53 //----------------------------------------------------------------------------- |
|
54 |
|
55 function test() |
|
56 { |
|
57 enterFunc ('test'); |
|
58 printBugNumber(BUGNUMBER); |
|
59 printStatus (summary); |
|
60 |
|
61 for (var i = 0; i < operators.length; i++) |
|
62 { |
|
63 expect = 'left valueOf, left toString, right valueOf, right toString, '; |
|
64 actual = ''; |
|
65 |
|
66 var left = makeObject('left'); |
|
67 var right = makeObject('right'); |
|
68 |
|
69 eval('left ' + operators[i].operator + ' right'); |
|
70 |
|
71 reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); |
|
72 } |
|
73 |
|
74 exitFunc ('test'); |
|
75 } |