Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | //----------------------------------------------------------------------------- |
michael@0 | 7 | var BUGNUMBER = 433672; |
michael@0 | 8 | var summary = 'operator evaluation order'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | function makeObject(label) |
michael@0 | 13 | { |
michael@0 | 14 | var o = (function (){}); |
michael@0 | 15 | |
michael@0 | 16 | o.label = label; |
michael@0 | 17 | o.valueOf = (function() { actual += this.label + ' valueOf, '; return Object.prototype.valueOf.call(this); }); |
michael@0 | 18 | o.toString = (function() { actual += this.label + ' toString, '; return Object.prototype.toString.call(this); }); |
michael@0 | 19 | |
michael@0 | 20 | return o; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | operators = [ |
michael@0 | 24 | {section: '11.5.1', operator: '*'}, |
michael@0 | 25 | {section: '11.5.2', operator: '/'}, |
michael@0 | 26 | {section: '11.5.3', operator: '%'}, |
michael@0 | 27 | {section: '11.6.1', operator: '+'}, |
michael@0 | 28 | {section: '11.6.2', operator: '-'}, |
michael@0 | 29 | {section: '11.7.1', operator: '<<'}, |
michael@0 | 30 | {section: '11.7.2', operator: '>>'}, |
michael@0 | 31 | {section: '11.7.3', operator: '>>>'}, |
michael@0 | 32 | {section: '11.8.1', operator: '<'}, |
michael@0 | 33 | {section: '11.8.2', operator: '>'}, |
michael@0 | 34 | {section: '11.8.3', operator: '<='}, |
michael@0 | 35 | {section: '11.8.4', operator: '>='}, |
michael@0 | 36 | {section: '11.10', operator: '&'}, |
michael@0 | 37 | {section: '11.10', operator: '^'}, |
michael@0 | 38 | {section: '11.10', operator: '|'}, |
michael@0 | 39 | {section: '11.13.2', operator: '*='}, |
michael@0 | 40 | {section: '11.13.2', operator: '/='}, |
michael@0 | 41 | {section: '11.13.2', operator: '%='}, |
michael@0 | 42 | {section: '11.13.2', operator: '+='}, |
michael@0 | 43 | {section: '11.13.2', operator: '<<='}, |
michael@0 | 44 | {section: '11.13.2', operator: '>>='}, |
michael@0 | 45 | {section: '11.13.2', operator: '>>>='}, |
michael@0 | 46 | {section: '11.13.2', operator: '&='}, |
michael@0 | 47 | {section: '11.13.2', operator: '^='}, |
michael@0 | 48 | {section: '11.13.2', operator: '|='}, |
michael@0 | 49 | ]; |
michael@0 | 50 | |
michael@0 | 51 | //----------------------------------------------------------------------------- |
michael@0 | 52 | test(); |
michael@0 | 53 | //----------------------------------------------------------------------------- |
michael@0 | 54 | |
michael@0 | 55 | function test() |
michael@0 | 56 | { |
michael@0 | 57 | enterFunc ('test'); |
michael@0 | 58 | printBugNumber(BUGNUMBER); |
michael@0 | 59 | printStatus (summary); |
michael@0 | 60 | |
michael@0 | 61 | for (var i = 0; i < operators.length; i++) |
michael@0 | 62 | { |
michael@0 | 63 | expect = 'left valueOf, left toString, right valueOf, right toString, '; |
michael@0 | 64 | actual = ''; |
michael@0 | 65 | |
michael@0 | 66 | var left = makeObject('left'); |
michael@0 | 67 | var right = makeObject('right'); |
michael@0 | 68 | |
michael@0 | 69 | eval('left ' + operators[i].operator + ' right'); |
michael@0 | 70 | |
michael@0 | 71 | reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | exitFunc ('test'); |
michael@0 | 75 | } |