1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Operators/order-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 433672; 1.11 +var summary = 'operator evaluation order'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +function makeObject(label) 1.16 +{ 1.17 + var o = (function (){}); 1.18 + 1.19 + o.label = label; 1.20 + o.valueOf = (function() { actual += this.label + ' valueOf, '; return Object.prototype.valueOf.call(this); }); 1.21 + o.toString = (function() { actual += this.label + ' toString, '; return Object.prototype.toString.call(this); }); 1.22 + 1.23 + return o; 1.24 +} 1.25 + 1.26 +operators = [ 1.27 + {section: '11.5.1', operator: '*'}, 1.28 + {section: '11.5.2', operator: '/'}, 1.29 + {section: '11.5.3', operator: '%'}, 1.30 + {section: '11.6.1', operator: '+'}, 1.31 + {section: '11.6.2', operator: '-'}, 1.32 + {section: '11.7.1', operator: '<<'}, 1.33 + {section: '11.7.2', operator: '>>'}, 1.34 + {section: '11.7.3', operator: '>>>'}, 1.35 + {section: '11.8.1', operator: '<'}, 1.36 + {section: '11.8.2', operator: '>'}, 1.37 + {section: '11.8.3', operator: '<='}, 1.38 + {section: '11.8.4', operator: '>='}, 1.39 + {section: '11.10', operator: '&'}, 1.40 + {section: '11.10', operator: '^'}, 1.41 + {section: '11.10', operator: '|'}, 1.42 + {section: '11.13.2', operator: '*='}, 1.43 + {section: '11.13.2', operator: '/='}, 1.44 + {section: '11.13.2', operator: '%='}, 1.45 + {section: '11.13.2', operator: '+='}, 1.46 + {section: '11.13.2', operator: '<<='}, 1.47 + {section: '11.13.2', operator: '>>='}, 1.48 + {section: '11.13.2', operator: '>>>='}, 1.49 + {section: '11.13.2', operator: '&='}, 1.50 + {section: '11.13.2', operator: '^='}, 1.51 + {section: '11.13.2', operator: '|='}, 1.52 + ]; 1.53 + 1.54 +//----------------------------------------------------------------------------- 1.55 +test(); 1.56 +//----------------------------------------------------------------------------- 1.57 + 1.58 +function test() 1.59 +{ 1.60 + enterFunc ('test'); 1.61 + printBugNumber(BUGNUMBER); 1.62 + printStatus (summary); 1.63 + 1.64 + for (var i = 0; i < operators.length; i++) 1.65 + { 1.66 + expect = 'left valueOf, left toString, right valueOf, right toString, '; 1.67 + actual = ''; 1.68 + 1.69 + var left = makeObject('left'); 1.70 + var right = makeObject('right'); 1.71 + 1.72 + eval('left ' + operators[i].operator + ' right'); 1.73 + 1.74 + reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); 1.75 + } 1.76 + 1.77 + exitFunc ('test'); 1.78 +}