Tue, 22 Jul 2014 10:48:36 -0700
Merge
1 /*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 /**
25 * range analysis test. check that computation return values are correct
26 * both with and without range analysis
27 *
28 * @subtest
29 */
31 function f(c) {
32 var v = c & 0xffff;
33 var w = v & 0xfff;
34 var x = v * w;
35 return x;
36 }
38 function g() {
39 var sum = 0;
40 for (var x = 0; x < 4711; x++) {
41 sum += x;
42 }
43 return sum;
44 }
46 function g2() {
47 var sum = 0;
48 //make sure we overflow
49 var displacement = 0x7ffffffe;
50 for (var x = displacement; x < (displacement + 2); x++) {
51 sum += x;
52 }
53 return sum;
54 }
56 //mostly provide code coverage for all the range operations
57 function h() {
58 var sum = 0;
59 sum += 4711;
60 sum &= 0xffff;
61 sum /= 2;
62 sum *= 2;
63 sum -= 4;
64 sum |= 2;
65 sum ^= 17;
66 sum = sum % 10000;
67 sum = -sum;
68 return sum
69 }
71 print(f(17));
72 print(g());
73 print(g2());
74 print(h());