Debian Codegraph @

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