annotate graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java @ 15406:ca16edfcecd5

mx: fixed site command by removing brittle post-processing of javadoc output
author Doug Simon <doug.simon@oracle.com>
date Mon, 28 Apr 2014 16:22:58 +0200
parents 2c0cfbf454b5
children 01bce59c2749
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
1 /*
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
4 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
8 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
13 * accompanied this code).
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
14 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
18 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
21 * questions.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
22 */
11385
e119ba892b45 Rename StampTest to ObjectStampJoinTest and move IntegerStampTest to com.oracle.graal.nodes.test
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11357
diff changeset
23 package com.oracle.graal.nodes.test;
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
24
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
25 import static org.junit.Assert.*;
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
26
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
27 import org.junit.*;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
28
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15131
diff changeset
30 import com.oracle.graal.compiler.common.type.*;
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
31 import com.oracle.graal.nodes.*;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
32 import com.oracle.graal.nodes.type.*;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
33
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
34 /**
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
35 * This class tests that integer stamps are created correctly for constants.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
36 */
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
37 public class IntegerStampTest {
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
38
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
39 private StructuredGraph graph;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
40
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
41 @Before
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
42 public void before() {
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
43 graph = new StructuredGraph();
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
44 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
45
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
46 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
47 public void testBooleanConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
48 assertEquals(new IntegerStamp(32, 1, 1, 0x1, 0x1), ConstantNode.forBoolean(true, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
49 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forBoolean(false, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
50 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
51
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
52 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
53 public void testByteConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
54 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forByte((byte) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
55 assertEquals(new IntegerStamp(32, 16, 16, 0x10, 0x10), ConstantNode.forByte((byte) 16, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
56 assertEquals(new IntegerStamp(32, -16, -16, 0xfffffff0L, 0xfffffff0L), ConstantNode.forByte((byte) -16, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
57 assertEquals(new IntegerStamp(32, 127, 127, 0x7f, 0x7f), ConstantNode.forByte((byte) 127, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
58 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forByte((byte) -128, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
59 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
60
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
61 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
62 public void testShortConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
63 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forShort((short) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
64 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forShort((short) 128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
65 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forShort((short) -128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
66 assertEquals(new IntegerStamp(32, 32767, 32767, 0x7fff, 0x7fff), ConstantNode.forShort((short) 32767, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
67 assertEquals(new IntegerStamp(32, -32768, -32768, 0xffff8000L, 0xffff8000L), ConstantNode.forShort((short) -32768, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
68 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
69
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
70 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
71 public void testCharConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
72 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forChar((char) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
73 assertEquals(new IntegerStamp(32, 'A', 'A', 'A', 'A'), ConstantNode.forChar('A', graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
74 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forChar((char) 128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
75 assertEquals(new IntegerStamp(32, 65535, 65535, 0xffff, 0xffff), ConstantNode.forChar((char) 65535, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
76 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
77
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
78 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
79 public void testIntConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
80 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forInt(0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
81 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forInt(128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
82 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forInt(-128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
83 assertEquals(new IntegerStamp(32, Integer.MAX_VALUE, Integer.MAX_VALUE, 0x7fffffff, 0x7fffffff), ConstantNode.forInt(Integer.MAX_VALUE, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
84 assertEquals(new IntegerStamp(32, Integer.MIN_VALUE, Integer.MIN_VALUE, 0x80000000L, 0x80000000L), ConstantNode.forInt(Integer.MIN_VALUE, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
85 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
86
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
87 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
88 public void testLongConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
89 assertEquals(new IntegerStamp(64, 0, 0, 0x0, 0x0), ConstantNode.forLong(0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
90 assertEquals(new IntegerStamp(64, 128, 128, 0x80, 0x80), ConstantNode.forLong(128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
91 assertEquals(new IntegerStamp(64, -128, -128, 0xffffffffffffff80L, 0xffffffffffffff80L), ConstantNode.forLong(-128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
92 assertEquals(new IntegerStamp(64, Long.MAX_VALUE, Long.MAX_VALUE, 0x7fffffffffffffffL, 0x7fffffffffffffffL), ConstantNode.forLong(Long.MAX_VALUE, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
93 assertEquals(new IntegerStamp(64, Long.MIN_VALUE, Long.MIN_VALUE, 0x8000000000000000L, 0x8000000000000000L), ConstantNode.forLong(Long.MIN_VALUE, graph).stamp());
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
94 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
95
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
96 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
97 public void testPositiveRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
98 assertEquals(new IntegerStamp(32, 0, 0, 0, 0), StampFactory.forInteger(Kind.Int, 0, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
99 assertEquals(new IntegerStamp(32, 0, 1, 0, 1), StampFactory.forInteger(Kind.Int, 0, 1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
100 assertEquals(new IntegerStamp(32, 0, 0x123, 0, 0x1ff), StampFactory.forInteger(Kind.Int, 0, 0x123));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
101 assertEquals(new IntegerStamp(32, 0x120, 0x123, 0x120, 0x123), StampFactory.forInteger(Kind.Int, 0x120, 0x123));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
102 assertEquals(new IntegerStamp(32, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Int, 10000, 15000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
103 assertEquals(new IntegerStamp(64, 0, 1, 0, 1), StampFactory.forInteger(Kind.Long, 0, 1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
104 assertEquals(new IntegerStamp(64, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Long, 10000, 15000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
105 assertEquals(new IntegerStamp(64, 140000000000L, 150000000000L, 0x2000000000L, 0x23ffffffffL), StampFactory.forInteger(Kind.Long, 140000000000L, 150000000000L));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
106 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
107
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
108 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
109 public void testNegativeRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
110 assertEquals(new IntegerStamp(32, -2, -1, 0xfffffffeL, 0xffffffffL), StampFactory.forInteger(Kind.Int, -2, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
111 assertEquals(new IntegerStamp(32, -20, -10, 0xffffffe0L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -20, -10));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
112 assertEquals(new IntegerStamp(32, -10000, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
113 assertEquals(new IntegerStamp(32, -10000, -1, 0xffffc000L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
114 assertEquals(new IntegerStamp(32, -10010, -10000, 0xffffd8e0L, 0xffffd8ffL), StampFactory.forInteger(Kind.Int, -10010, -10000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
115 assertEquals(new IntegerStamp(64, -2, -1, 0xfffffffffffffffeL, 0xffffffffffffffffL), StampFactory.forInteger(Kind.Long, -2, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
116 assertEquals(new IntegerStamp(64, -10010, -10000, 0xffffffffffffd8e0L, 0xffffffffffffd8ffL), StampFactory.forInteger(Kind.Long, -10010, -10000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
117 assertEquals(new IntegerStamp(64, -150000000000L, -140000000000L, 0xffffffdc00000000L, 0xffffffdfffffffffL), StampFactory.forInteger(Kind.Long, -150000000000L, -140000000000L));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
118 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
119
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
120 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
121 public void testMixedRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
122 assertEquals(new IntegerStamp(32, -1, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -1, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
123 assertEquals(new IntegerStamp(32, -10000, 1000, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 1000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
124 assertEquals(new IntegerStamp(64, -10000, 1000, 0, 0xffffffffffffffffL), StampFactory.forInteger(Kind.Long, -10000, 1000));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
125 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
126
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
127 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
128 public void testNarrowingConversions() {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
129 // byte cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
130 assertEquals(StampFactory.forInteger(Kind.Int, 0, 0), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 0), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
131 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
132 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
133 assertEquals(StampFactory.forInteger(Kind.Int, -10, 0), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10, 0), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
134 assertEquals(StampFactory.forInteger(Kind.Int, -20, -10), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -20, -10), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
135 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 100, 200), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
136 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -100, 200), Kind.Byte));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
137 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -200, -100), Kind.Byte));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
138 // char cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
139 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Char));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
140 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Char));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
141 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 20000, 80000), Kind.Char));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
142 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10000, 40000), Kind.Char));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
143 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -40000, -10000), Kind.Char));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
144 // short cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
145 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Short));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
146 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Short));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
147 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, 20000, 40000), Kind.Short));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
148 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10000, 40000), Kind.Short));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
149 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Int, -40000, -10000), Kind.Short));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
150 // int cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
151 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, 0, 10), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
152 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, 10, 20), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
153 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
154 StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, 20000000000L, 40000000000L), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
155 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
156 StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, -10000000000L, 40000000000L), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
157 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
158 StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, -40000000000L, -10000000000L), Kind.Int));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
159 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
160
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
161 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
162 public void testXor() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
163 assertEquals(new IntegerStamp(32, 0, 0xff, 0, 0xff), StampTool.xor(new IntegerStamp(32, 0, 0, 0, 0), new IntegerStamp(32, 0, 0xff, 0, 0xff)));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
164 assertEquals(new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f), StampTool.xor(new IntegerStamp(32, 0, 0, 0, 0), new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f)));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
165 assertEquals(new IntegerStamp(32, 0x0, 0xf, 0x0, 0xf), StampTool.xor(new IntegerStamp(32, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f)));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
166 assertEquals(new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f), StampTool.xor(new IntegerStamp(32, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, 0x0, 0xf, 0x0, 0xf)));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
167 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
168
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
169 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
170 public void testNot() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
171 assertEquals(new IntegerStamp(32, -11, -1, 0xffff_fff0L, 0xffff_ffffL), StampTool.not(new IntegerStamp(32, 0, 10, 0, 0xf)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
172 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
173
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
174 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
175 public void testAddIntSimple() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
176 assertEquals(StampFactory.forInteger(Kind.Int, 0, 30, 0, 31), StampTool.add(StampFactory.forInteger(Kind.Int, 0, 10), StampFactory.forInteger(Kind.Int, 0, 20)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
177 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
178
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
179 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
180 public void testAddNegativeOverFlowInt1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
181 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0xffff_ffffL),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
182 StampTool.add(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, 0), StampFactory.forInteger(Kind.Int, -1, 0)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
183 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
184
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
185 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
186 public void testAddNegativeOverFlowInt2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
187 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MAX_VALUE - 2, Integer.MAX_VALUE, 0x7fff_fffcL, 0x7fff_ffffL),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
188 StampTool.add(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MIN_VALUE + 1), StampFactory.forInteger(Kind.Int, -3, -2)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
189 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
190
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
191 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
192 public void testAddPositiveOverFlowInt1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
193 assertEquals(StampFactory.forKind(Kind.Int), StampTool.add(StampFactory.forInteger(Kind.Int, 0, 1), StampFactory.forInteger(Kind.Int, 0, Integer.MAX_VALUE)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
194 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
195
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
196 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
197 public void testAddPositiveOverFlowInt2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
198 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MIN_VALUE + 2),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
199 StampTool.add(StampFactory.forInteger(Kind.Int, Integer.MAX_VALUE - 1, Integer.MAX_VALUE), StampFactory.forInteger(Kind.Int, 2, 3)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
200 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
201
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
202 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
203 public void testAddOverFlowsInt() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
204 assertEquals(StampFactory.forKind(Kind.Int), StampTool.add(StampFactory.forInteger(Kind.Int, -1, 1), StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
205 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
206
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
207 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
208 public void testAddLongSimple() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
209 assertEquals(StampFactory.forInteger(Kind.Long, 0, 30, 0, 31), StampTool.add(StampFactory.forInteger(Kind.Long, 0, 10), StampFactory.forInteger(Kind.Long, 0, 20)));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
210 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
211
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
212 @Test
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
213 public void testAddNegativOverFlowLong1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
214 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE, 0, 0xffff_ffff_ffff_ffffL),
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
215 StampTool.add(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 1), StampFactory.forInteger(Kind.Long, Integer.MIN_VALUE, Integer.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
216 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
217
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
218 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
219 public void testAddNegativeOverFlowLong2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
220 assertEquals(StampFactory.forInteger(Kind.Long, Long.MAX_VALUE - 2, Long.MAX_VALUE),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
221 StampTool.add(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 1), StampFactory.forInteger(Kind.Long, -3, -2)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
222 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
223
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
224 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
225 public void testAddPositiveOverFlowLong1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
226 assertEquals(StampFactory.forKind(Kind.Long), StampTool.add(StampFactory.forInteger(Kind.Long, 0, 1), StampFactory.forInteger(Kind.Long, 0, Long.MAX_VALUE)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
227 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
228
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
229 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
230 public void testAddPositiveOverFlowLong2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
231 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 2),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
232 StampTool.add(StampFactory.forInteger(Kind.Long, Long.MAX_VALUE - 1, Long.MAX_VALUE), StampFactory.forInteger(Kind.Long, 2, 3)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
233 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
234
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
235 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
236 public void testAddOverFlowsLong() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
237 assertEquals(StampFactory.forKind(Kind.Long), StampTool.add(StampFactory.forInteger(Kind.Long, -1, 1), StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
238 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
239
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
240 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
241 public void testAdd1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
242 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE + 1, 31 + (Integer.MIN_VALUE + 1)),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
243 StampTool.add(StampFactory.forInteger(Kind.Int, 0, 31), StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE + 1, Integer.MIN_VALUE + 1)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
244 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
245
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
246 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
247 public void testAdd2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
248 assertEquals(StampFactory.forInteger(Kind.Int, 0x8000_007e, 0x8000_007f, 0x8000_007eL, 0x8000_007fL),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
249 StampTool.add(StampFactory.forInteger(Kind.Int, 0x7fff_fffe, 0x7fff_ffff, 0x7fff_fffeL, 0x7ffff_fffL), StampFactory.forInteger(Kind.Int, 128, 128)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
250 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
251
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
252 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
253 public void testAdd3() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
254 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
255 StampTool.add(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL),
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
256 StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
257
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
258 }
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
259
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
260 @Test
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
261 public void testAnd() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
262 assertEquals(new IntegerStamp(32, Integer.MIN_VALUE, 0x40000000L, 0, 0xc0000000L), StampTool.and(StampFactory.forKind(Kind.Int), StampFactory.forConstant(Constant.forInt(0xc0000000))));
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
263 }
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
264
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
265 private static void testSignExtendShort(long lower, long upper) {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
266 Stamp shortStamp = StampFactory.forInteger(16, lower, upper);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
267 Stamp intStamp = StampTool.signExtend(shortStamp, 32);
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
268 assertEquals(StampFactory.forInteger(32, lower, upper), intStamp);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
269 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
270
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
271 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
272 public void testSignExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
273 testSignExtendShort(5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
274 testSignExtendShort(0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
275 testSignExtendShort(-42, -1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
276 testSignExtendShort(-42, 0);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
277 testSignExtendShort(-1, 1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
278 testSignExtendShort(Short.MIN_VALUE, Short.MAX_VALUE);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
279 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
280
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
281 private static void testZeroExtendShort(long lower, long upper, long newLower, long newUpper) {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
282 Stamp shortStamp = StampFactory.forInteger(16, lower, upper);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
283 Stamp intStamp = StampTool.zeroExtend(shortStamp, 32);
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
284 assertEquals(StampFactory.forInteger(32, newLower, newUpper), intStamp);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
285 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
286
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
287 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
288 public void testZeroExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
289 testZeroExtendShort(5, 7, 5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
290 testZeroExtendShort(0, 42, 0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
291 testZeroExtendShort(-42, -1, 0xFFFF - 41, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
292 testZeroExtendShort(-42, 0, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
293 testZeroExtendShort(-1, 1, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
294 testZeroExtendShort(Short.MIN_VALUE, Short.MAX_VALUE, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
295 }
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
296 }