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.
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/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 418641;
8 var summary = '++ and -- correctness';
9 var actual = '';
10 var expect = '';
12 printBugNumber(BUGNUMBER);
13 printStatus (summary);
15 function get_pre_check(operand, op)
16 {
17 return "{\n"+
18 " "+operand+" = I;\n"+
19 " let tmp = "+op+op+operand+";\n"+
20 " if ("+operand+" !== Number(I) "+op+" 1)\n"+
21 " throw Error('"+op+op+operand+" case 1 for '+uneval(I));\n"+
22 " if (tmp !== "+operand+")\n"+
23 " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+
24 "}\n";
25 }
27 function get_post_check(operand, op)
28 {
29 return "{\n"+
30 " "+operand+" = I;\n"+
31 " let tmp = "+operand+op+op+";\n"+
32 " if ("+operand+" !== Number(I) "+op+" 1)\n"+
33 " throw Error('"+operand+op+op+" case 1 for '+uneval(I));\n"+
34 " if (tmp !== Number(I))\n"+
35 " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+
36 "}\n";
37 }
39 function get_check_source(operand)
40 {
41 return get_pre_check(operand, '+')+
42 get_pre_check(operand, '-')+
43 get_post_check(operand, '+')+
44 get_post_check(operand, '-');
45 }
47 var arg_check = Function('I', 'a', get_check_source('a'));
48 var let_check = Function('I', 'let a;'+get_check_source('a'));
49 var var_check = Function('I', 'var a;'+get_check_source('a'));
51 var my_name;
52 var my_obj = {};
53 var my_index = 0;
54 var name_check = Function('I', get_check_source('my_name'));
55 var prop_check = Function('I', get_check_source('my_obj.x'));
56 var elem_check = Function('I', get_check_source('my_obj[my_index]'));
58 var test_values = [0 , 0.5, -0.0, (1 << 30) - 1, 1 - (1 << 30)];
60 for (let i = 0; i != test_values.length; i = i + 1) {
61 let x = [test_values[i], String(test_values[i])];
62 for (let j = 0; j != x.length; j = j + 1) {
63 try
64 {
65 expect = actual = 'No Error';
66 let test_value = x[j];
67 arg_check(test_value, 0);
68 let_check(test_value);
69 var_check(test_value);
70 name_check(test_value);
71 prop_check(test_value);
72 elem_check(test_value);
73 }
74 catch(ex)
75 {
76 actual = ex + '';
77 }
78 reportCompare(expect, actual, summary + ': ' + i + ', ' + j);
79 }
80 }