annotate graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java @ 14015:0354f629431a

Bug fixes in StampTool.(zero|sign)Extend.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 25 Feb 2014 13:36:18 +0100
parents f2b300c6e621
children 9c1e53adc159
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.*;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
30 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
31 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
32
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 * 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
35 */
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
36 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
37
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
38 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
39
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
40 @Before
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
41 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
42 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
43 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
46 public void testBooleanConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
47 assertEquals(new IntegerStamp(32, false, 1, 1, 0x1, 0x1), ConstantNode.forBoolean(true, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
48 assertEquals(new IntegerStamp(32, false, 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
49 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
52 public void testByteConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
53 assertEquals(new IntegerStamp(32, false, 0, 0, 0x0, 0x0), ConstantNode.forByte((byte) 0, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
54 assertEquals(new IntegerStamp(32, false, 16, 16, 0x10, 0x10), ConstantNode.forByte((byte) 16, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
55 assertEquals(new IntegerStamp(32, false, -16, -16, 0xfffffff0L, 0xfffffff0L), ConstantNode.forByte((byte) -16, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
56 assertEquals(new IntegerStamp(32, false, 127, 127, 0x7f, 0x7f), ConstantNode.forByte((byte) 127, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
57 assertEquals(new IntegerStamp(32, false, -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
58 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
61 public void testShortConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
62 assertEquals(new IntegerStamp(32, false, 0, 0, 0x0, 0x0), ConstantNode.forShort((short) 0, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
63 assertEquals(new IntegerStamp(32, false, 128, 128, 0x80, 0x80), ConstantNode.forShort((short) 128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
64 assertEquals(new IntegerStamp(32, false, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forShort((short) -128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
65 assertEquals(new IntegerStamp(32, false, 32767, 32767, 0x7fff, 0x7fff), ConstantNode.forShort((short) 32767, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
66 assertEquals(new IntegerStamp(32, false, -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
67 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
70 public void testCharConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
71 assertEquals(new IntegerStamp(32, false, 0, 0, 0x0, 0x0), ConstantNode.forChar((char) 0, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
72 assertEquals(new IntegerStamp(32, false, 'A', 'A', 'A', 'A'), ConstantNode.forChar('A', graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
73 assertEquals(new IntegerStamp(32, false, 128, 128, 0x80, 0x80), ConstantNode.forChar((char) 128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
74 assertEquals(new IntegerStamp(32, false, 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
75 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
78 public void testIntConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
79 assertEquals(new IntegerStamp(32, false, 0, 0, 0x0, 0x0), ConstantNode.forInt(0, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
80 assertEquals(new IntegerStamp(32, false, 128, 128, 0x80, 0x80), ConstantNode.forInt(128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
81 assertEquals(new IntegerStamp(32, false, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forInt(-128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
82 assertEquals(new IntegerStamp(32, false, Integer.MAX_VALUE, Integer.MAX_VALUE, 0x7fffffff, 0x7fffffff), ConstantNode.forInt(Integer.MAX_VALUE, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
83 assertEquals(new IntegerStamp(32, false, 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
84 }
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 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
87 public void testLongConstant() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
88 assertEquals(new IntegerStamp(64, false, 0, 0, 0x0, 0x0), ConstantNode.forLong(0, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
89 assertEquals(new IntegerStamp(64, false, 128, 128, 0x80, 0x80), ConstantNode.forLong(128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
90 assertEquals(new IntegerStamp(64, false, -128, -128, 0xffffffffffffff80L, 0xffffffffffffff80L), ConstantNode.forLong(-128, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
91 assertEquals(new IntegerStamp(64, false, Long.MAX_VALUE, Long.MAX_VALUE, 0x7fffffffffffffffL, 0x7fffffffffffffffL), ConstantNode.forLong(Long.MAX_VALUE, graph).stamp());
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
92 assertEquals(new IntegerStamp(64, false, 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
93 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
96 public void testPositiveRanges() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
97 assertEquals(new IntegerStamp(32, false, 0, 0, 0, 0), StampFactory.forInteger(Kind.Int, 0, 0));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
98 assertEquals(new IntegerStamp(32, false, 0, 1, 0, 1), StampFactory.forInteger(Kind.Int, 0, 1));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
99 assertEquals(new IntegerStamp(32, false, 0, 0x123, 0, 0x1ff), StampFactory.forInteger(Kind.Int, 0, 0x123));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
100 assertEquals(new IntegerStamp(32, false, 0x120, 0x123, 0x120, 0x123), StampFactory.forInteger(Kind.Int, 0x120, 0x123));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
101 assertEquals(new IntegerStamp(32, false, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Int, 10000, 15000));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
102 assertEquals(new IntegerStamp(64, false, 0, 1, 0, 1), StampFactory.forInteger(Kind.Long, 0, 1));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
103 assertEquals(new IntegerStamp(64, false, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Long, 10000, 15000));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
104 assertEquals(new IntegerStamp(64, false, 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
105 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
108 public void testNegativeRanges() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
109 assertEquals(new IntegerStamp(32, false, -2, -1, 0xfffffffeL, 0xffffffffL), StampFactory.forInteger(Kind.Int, -2, -1));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
110 assertEquals(new IntegerStamp(32, false, -20, -10, 0xffffffe0L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -20, -10));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
111 assertEquals(new IntegerStamp(32, false, -10000, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 0));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
112 assertEquals(new IntegerStamp(32, false, -10000, -1, 0xffffc000L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, -1));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
113 assertEquals(new IntegerStamp(32, false, -10010, -10000, 0xffffd8e0L, 0xffffd8ffL), StampFactory.forInteger(Kind.Int, -10010, -10000));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
114 assertEquals(new IntegerStamp(64, false, -2, -1, 0xfffffffffffffffeL, 0xffffffffffffffffL), StampFactory.forInteger(Kind.Long, -2, -1));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
115 assertEquals(new IntegerStamp(64, false, -10010, -10000, 0xffffffffffffd8e0L, 0xffffffffffffd8ffL), StampFactory.forInteger(Kind.Long, -10010, -10000));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
116 assertEquals(new IntegerStamp(64, false, -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
117 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
120 public void testMixedRanges() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
121 assertEquals(new IntegerStamp(32, false, -1, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -1, 0));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
122 assertEquals(new IntegerStamp(32, false, -10000, 1000, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 1000));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
123 assertEquals(new IntegerStamp(64, false, -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
124 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
127 public void testNarrowingConversions() {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
128 // byte cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
129 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
130 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
131 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
132 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
133 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
134 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
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, -200, -100), Kind.Byte));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
137 // char cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
138 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
139 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
140 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
141 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
142 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
143 // short cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
144 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
145 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
146 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
147 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
148 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
149 // int cases
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
150 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
151 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
152 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
153 StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, 20000000000L, 40000000000L), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
154 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
155 StampTool.narrowingKindConversion(StampFactory.forInteger(Kind.Long, -10000000000L, 40000000000L), Kind.Int));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
156 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE),
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12562
diff changeset
157 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
158 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
161 public void testXor() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
162 assertEquals(new IntegerStamp(32, false, 0, 0xff, 0, 0xff), StampTool.xor(new IntegerStamp(32, false, 0, 0, 0, 0), new IntegerStamp(32, false, 0, 0xff, 0, 0xff)));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
163 assertEquals(new IntegerStamp(32, false, 0x10, 0x1f, 0x10, 0x1f), StampTool.xor(new IntegerStamp(32, false, 0, 0, 0, 0), new IntegerStamp(32, false, 0x10, 0x1f, 0x10, 0x1f)));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
164 assertEquals(new IntegerStamp(32, false, 0x0, 0xf, 0x0, 0xf), StampTool.xor(new IntegerStamp(32, false, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, false, 0x10, 0x1f, 0x10, 0x1f)));
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
165 assertEquals(new IntegerStamp(32, false, 0x10, 0x1f, 0x10, 0x1f), StampTool.xor(new IntegerStamp(32, false, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, false, 0x0, 0xf, 0x0, 0xf)));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
166 }
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 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
169 public void testNot() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
170 assertEquals(new IntegerStamp(32, false, -11, -1, 0xffff_fff0L, 0xffff_ffffL), StampTool.not(new IntegerStamp(32, false, 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
171 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
174 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
175 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
176 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
179 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
180 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
181 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
182 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
185 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
186 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
187 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
188 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
191 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
192 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
193 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
196 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
197 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
198 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
199 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
202 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
203 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
204 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
207 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
208 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
209 }
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 @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
212 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
213 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
214 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
215 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
218 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
219 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
220 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
221 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
224 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
225 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
226 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
229 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
230 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
231 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
232 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
233
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
234 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
235 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
236 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
237 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
240 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
241 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
242 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
243 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
244
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
245 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
246 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
247 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
248 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
249 }
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 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
252 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
253 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
254 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
255 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
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
257 }
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
258
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
259 @Test
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
260 public void testAnd() {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents: 12677
diff changeset
261 assertEquals(new IntegerStamp(32, false, 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
262 }
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
263
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
264 private static void testSignExtendShort(long lower, long upper) {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
265 Stamp shortStamp = StampFactory.forInteger(16, false, lower, upper);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
266 Stamp intStamp = StampTool.signExtend(shortStamp, 32);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
267 assertEquals(StampFactory.forInteger(32, false, lower, upper), intStamp);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
268 }
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 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
271 public void testSignExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
272 testSignExtendShort(5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
273 testSignExtendShort(0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
274 testSignExtendShort(-42, -1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
275 testSignExtendShort(-42, 0);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
276 testSignExtendShort(-1, 1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
277 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
278 }
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 private static void testZeroExtendShort(long lower, long upper, long newLower, long newUpper) {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
281 Stamp shortStamp = StampFactory.forInteger(16, false, lower, upper);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
282 Stamp intStamp = StampTool.zeroExtend(shortStamp, 32);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
283 assertEquals(StampFactory.forInteger(32, false, newLower, newUpper), intStamp);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
284 }
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 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
287 public void testZeroExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
288 testZeroExtendShort(5, 7, 5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
289 testZeroExtendShort(0, 42, 0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
290 testZeroExtendShort(-42, -1, 0xFFFF - 41, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
291 testZeroExtendShort(-42, 0, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
292 testZeroExtendShort(-1, 1, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
293 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
294 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
295
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
296 private static void testSignExtendChar(long lower, long upper, long newLower, long newUpper) {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
297 Stamp charStamp = StampFactory.forInteger(16, true, lower, upper);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
298 Stamp uintStamp = StampTool.signExtend(charStamp, 32);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
299 assertEquals(StampFactory.forInteger(32, true, newLower, newUpper), uintStamp);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
300 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
301
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
302 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
303 public void testSignExtendUnsigned() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
304 testSignExtendChar(5, 7, 5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
305 testSignExtendChar(0, 42, 0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
306 testSignExtendChar(5, 0xF000, 5, 0xFFFFF000L);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
307 testSignExtendChar(0, 0xF000, 0, 0xFFFFF000L);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
308 testSignExtendChar(0xF000, Character.MAX_VALUE, 0xFFFFF000L, 0xFFFFFFFFL);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
309 testSignExtendChar(Character.MIN_VALUE, Character.MAX_VALUE, 0, 0xFFFFFFFFL);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
310 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
311
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
312 private static void testZeroExtendChar(long lower, long upper) {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
313 Stamp charStamp = StampFactory.forInteger(16, true, lower, upper);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
314 Stamp uintStamp = StampTool.zeroExtend(charStamp, 32);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
315 assertEquals(StampFactory.forInteger(32, true, lower, upper), uintStamp);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
316 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
317
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
318 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
319 public void testZeroExtendUnsigned() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
320 testZeroExtendChar(5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
321 testZeroExtendChar(0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
322 testZeroExtendChar(5, 0xF000);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
323 testZeroExtendChar(0, 0xF000);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
324 testZeroExtendChar(0xF000, Character.MAX_VALUE);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
325 testZeroExtendChar(Character.MIN_VALUE, Character.MAX_VALUE);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
326 }
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
327 }