Debian Codegraph @

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