blob: e28c673897d6e17b503bcbcd5e49644368a9587f [file] [log] [blame]
package org.eclipse.jdt.debug.tests.eval;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Common Public License v0.5
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v05.html
Contributors:
IBM Corporation - Initial implementation
*********************************************************************/
import org.eclipse.debug.core.model.IValue;
import org.eclipse.jdt.debug.core.IJavaPrimitiveValue;
public class NumericTypesCastTests extends Tests {
public NumericTypesCastTests(String arg) {
super(arg);
}
protected void init() throws Exception {
initializeFrame("EvalSimpleTests",15,1);
}
protected void end() throws Exception {
destroyFrame();
}
// (byte) {byte, char, short, int, long, float, double}
public void testByteCastByte() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) byte : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) byte : wrong result : ", ( byte) xByteValue, byteValue);
value = eval("(byte)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(byte) byte : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) byte : wrong result : ", ( byte) yByteValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastChar() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) char : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) char : wrong result : ", ( byte) xCharValue, byteValue);
value = eval("(byte)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(byte) char : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) char : wrong result : ", ( byte) yCharValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastShort() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) short : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) short : wrong result : ", ( byte) xShortValue, byteValue);
value = eval("(byte)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(byte) short : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) short : wrong result : ", ( byte) yShortValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastInt() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) int : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) int : wrong result : ", ( byte) xIntValue, byteValue);
value = eval("(byte)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(byte) int : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) int : wrong result : ", ( byte) yIntValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastLong() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) long : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) long : wrong result : ", ( byte) xLongValue, byteValue);
value = eval("(byte)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(byte) long : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) long : wrong result : ", ( byte) yLongValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastFloat() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) float : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) float : wrong result : ", ( byte) xFloatValue, byteValue);
value = eval("(byte)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(byte) float : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) float : wrong result : ", ( byte) yFloatValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testByteCastDouble() throws Throwable {
try {
init();
IValue value = eval("(byte)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(byte) double : wrong type : ", "byte", typeName);
byte byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) double : wrong result : ", ( byte) xDoubleValue, byteValue);
value = eval("(byte)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(byte) double : wrong type : ", "byte", typeName);
byteValue = ((IJavaPrimitiveValue)value).getByteValue();
assertEquals("(byte) double : wrong result : ", ( byte) yDoubleValue, byteValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (char) {byte, char, short, int, long, float, double}
public void testCharCastByte() throws Throwable {
try {
init();
IValue value = eval("(char)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(char) byte : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) byte : wrong result : ", ( char) xByteValue, charValue);
value = eval("(char)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(char) byte : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) byte : wrong result : ", ( char) yByteValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastChar() throws Throwable {
try {
init();
IValue value = eval("(char)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(char) char : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) char : wrong result : ", ( char) xCharValue, charValue);
value = eval("(char)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(char) char : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) char : wrong result : ", ( char) yCharValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastShort() throws Throwable {
try {
init();
IValue value = eval("(char)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(char) short : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) short : wrong result : ", ( char) xShortValue, charValue);
value = eval("(char)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(char) short : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) short : wrong result : ", ( char) yShortValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastInt() throws Throwable {
try {
init();
IValue value = eval("(char)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(char) int : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) int : wrong result : ", ( char) xIntValue, charValue);
value = eval("(char)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(char) int : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) int : wrong result : ", ( char) yIntValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastLong() throws Throwable {
try {
init();
IValue value = eval("(char)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(char) long : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) long : wrong result : ", ( char) xLongValue, charValue);
value = eval("(char)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(char) long : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) long : wrong result : ", ( char) yLongValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastFloat() throws Throwable {
try {
init();
IValue value = eval("(char)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(char) float : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) float : wrong result : ", ( char) xFloatValue, charValue);
value = eval("(char)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(char) float : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) float : wrong result : ", ( char) yFloatValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testCharCastDouble() throws Throwable {
try {
init();
IValue value = eval("(char)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(char) double : wrong type : ", "char", typeName);
char charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) double : wrong result : ", ( char) xDoubleValue, charValue);
value = eval("(char)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(char) double : wrong type : ", "char", typeName);
charValue = ((IJavaPrimitiveValue)value).getCharValue();
assertEquals("(char) double : wrong result : ", ( char) yDoubleValue, charValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (short) {byte, char, short, int, long, float, double}
public void testShortCastByte() throws Throwable {
try {
init();
IValue value = eval("(short)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(short) byte : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) byte : wrong result : ", ( short) xByteValue, shortValue);
value = eval("(short)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(short) byte : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) byte : wrong result : ", ( short) yByteValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastChar() throws Throwable {
try {
init();
IValue value = eval("(short)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(short) char : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) char : wrong result : ", ( short) xCharValue, shortValue);
value = eval("(short)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(short) char : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) char : wrong result : ", ( short) yCharValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastShort() throws Throwable {
try {
init();
IValue value = eval("(short)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(short) short : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) short : wrong result : ", ( short) xShortValue, shortValue);
value = eval("(short)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(short) short : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) short : wrong result : ", ( short) yShortValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastInt() throws Throwable {
try {
init();
IValue value = eval("(short)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(short) int : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) int : wrong result : ", ( short) xIntValue, shortValue);
value = eval("(short)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(short) int : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) int : wrong result : ", ( short) yIntValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastLong() throws Throwable {
try {
init();
IValue value = eval("(short)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(short) long : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) long : wrong result : ", ( short) xLongValue, shortValue);
value = eval("(short)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(short) long : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) long : wrong result : ", ( short) yLongValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastFloat() throws Throwable {
try {
init();
IValue value = eval("(short)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(short) float : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) float : wrong result : ", ( short) xFloatValue, shortValue);
value = eval("(short)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(short) float : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) float : wrong result : ", ( short) yFloatValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testShortCastDouble() throws Throwable {
try {
init();
IValue value = eval("(short)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(short) double : wrong type : ", "short", typeName);
short shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) double : wrong result : ", ( short) xDoubleValue, shortValue);
value = eval("(short)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(short) double : wrong type : ", "short", typeName);
shortValue = ((IJavaPrimitiveValue)value).getShortValue();
assertEquals("(short) double : wrong result : ", ( short) yDoubleValue, shortValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (int) {byte, char, short, int, long, float, double}
public void testIntCastByte() throws Throwable {
try {
init();
IValue value = eval("(int)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(int) byte : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) byte : wrong result : ", ( int) xByteValue, intValue);
value = eval("(int)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(int) byte : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) byte : wrong result : ", ( int) yByteValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastChar() throws Throwable {
try {
init();
IValue value = eval("(int)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(int) char : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) char : wrong result : ", ( int) xCharValue, intValue);
value = eval("(int)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(int) char : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) char : wrong result : ", ( int) yCharValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastShort() throws Throwable {
try {
init();
IValue value = eval("(int)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(int) short : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) short : wrong result : ", ( int) xShortValue, intValue);
value = eval("(int)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(int) short : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) short : wrong result : ", ( int) yShortValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastInt() throws Throwable {
try {
init();
IValue value = eval("(int)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(int) int : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) int : wrong result : ", ( int) xIntValue, intValue);
value = eval("(int)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(int) int : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) int : wrong result : ", ( int) yIntValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastLong() throws Throwable {
try {
init();
IValue value = eval("(int)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(int) long : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) long : wrong result : ", ( int) xLongValue, intValue);
value = eval("(int)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(int) long : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) long : wrong result : ", ( int) yLongValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastFloat() throws Throwable {
try {
init();
IValue value = eval("(int)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(int) float : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) float : wrong result : ", ( int) xFloatValue, intValue);
value = eval("(int)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(int) float : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) float : wrong result : ", ( int) yFloatValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testIntCastDouble() throws Throwable {
try {
init();
IValue value = eval("(int)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(int) double : wrong type : ", "int", typeName);
int intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) double : wrong result : ", ( int) xDoubleValue, intValue);
value = eval("(int)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(int) double : wrong type : ", "int", typeName);
intValue = ((IJavaPrimitiveValue)value).getIntValue();
assertEquals("(int) double : wrong result : ", ( int) yDoubleValue, intValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (long) {byte, char, short, int, long, float, double}
public void testLongCastByte() throws Throwable {
try {
init();
IValue value = eval("(long)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(long) byte : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) byte : wrong result : ", ( long) xByteValue, longValue);
value = eval("(long)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(long) byte : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) byte : wrong result : ", ( long) yByteValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastChar() throws Throwable {
try {
init();
IValue value = eval("(long)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(long) char : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) char : wrong result : ", ( long) xCharValue, longValue);
value = eval("(long)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(long) char : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) char : wrong result : ", ( long) yCharValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastShort() throws Throwable {
try {
init();
IValue value = eval("(long)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(long) short : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) short : wrong result : ", ( long) xShortValue, longValue);
value = eval("(long)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(long) short : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) short : wrong result : ", ( long) yShortValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastInt() throws Throwable {
try {
init();
IValue value = eval("(long)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(long) int : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) int : wrong result : ", ( long) xIntValue, longValue);
value = eval("(long)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(long) int : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) int : wrong result : ", ( long) yIntValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastLong() throws Throwable {
try {
init();
IValue value = eval("(long)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(long) long : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) long : wrong result : ", ( long) xLongValue, longValue);
value = eval("(long)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(long) long : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) long : wrong result : ", ( long) yLongValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastFloat() throws Throwable {
try {
init();
IValue value = eval("(long)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(long) float : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) float : wrong result : ", ( long) xFloatValue, longValue);
value = eval("(long)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(long) float : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) float : wrong result : ", ( long) yFloatValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testLongCastDouble() throws Throwable {
try {
init();
IValue value = eval("(long)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(long) double : wrong type : ", "long", typeName);
long longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) double : wrong result : ", ( long) xDoubleValue, longValue);
value = eval("(long)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(long) double : wrong type : ", "long", typeName);
longValue = ((IJavaPrimitiveValue)value).getLongValue();
assertEquals("(long) double : wrong result : ", ( long) yDoubleValue, longValue);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (float) {byte, char, short, int, long, float, double}
public void testFloatCastByte() throws Throwable {
try {
init();
IValue value = eval("(float)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(float) byte : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) byte : wrong result : ", ( float) xByteValue, floatValue, 0);
value = eval("(float)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(float) byte : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) byte : wrong result : ", ( float) yByteValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastChar() throws Throwable {
try {
init();
IValue value = eval("(float)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(float) char : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) char : wrong result : ", ( float) xCharValue, floatValue, 0);
value = eval("(float)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(float) char : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) char : wrong result : ", ( float) yCharValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastShort() throws Throwable {
try {
init();
IValue value = eval("(float)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(float) short : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) short : wrong result : ", ( float) xShortValue, floatValue, 0);
value = eval("(float)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(float) short : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) short : wrong result : ", ( float) yShortValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastInt() throws Throwable {
try {
init();
IValue value = eval("(float)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(float) int : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) int : wrong result : ", ( float) xIntValue, floatValue, 0);
value = eval("(float)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(float) int : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) int : wrong result : ", ( float) yIntValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastLong() throws Throwable {
try {
init();
IValue value = eval("(float)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(float) long : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) long : wrong result : ", ( float) xLongValue, floatValue, 0);
value = eval("(float)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(float) long : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) long : wrong result : ", ( float) yLongValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastFloat() throws Throwable {
try {
init();
IValue value = eval("(float)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(float) float : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) float : wrong result : ", ( float) xFloatValue, floatValue, 0);
value = eval("(float)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(float) float : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) float : wrong result : ", ( float) yFloatValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testFloatCastDouble() throws Throwable {
try {
init();
IValue value = eval("(float)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(float) double : wrong type : ", "float", typeName);
float floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) double : wrong result : ", ( float) xDoubleValue, floatValue, 0);
value = eval("(float)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(float) double : wrong type : ", "float", typeName);
floatValue = ((IJavaPrimitiveValue)value).getFloatValue();
assertEquals("(float) double : wrong result : ", ( float) yDoubleValue, floatValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
// (double) {byte, char, short, int, long, float, double}
public void testDoubleCastByte() throws Throwable {
try {
init();
IValue value = eval("(double)" + xByte);
String typeName = value.getReferenceTypeName();
assertEquals("(double) byte : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) byte : wrong result : ", ( double) xByteValue, doubleValue, 0);
value = eval("(double)" + yByte);
typeName = value.getReferenceTypeName();
assertEquals("(double) byte : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) byte : wrong result : ", ( double) yByteValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastChar() throws Throwable {
try {
init();
IValue value = eval("(double)" + xChar);
String typeName = value.getReferenceTypeName();
assertEquals("(double) char : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) char : wrong result : ", ( double) xCharValue, doubleValue, 0);
value = eval("(double)" + yChar);
typeName = value.getReferenceTypeName();
assertEquals("(double) char : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) char : wrong result : ", ( double) yCharValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastShort() throws Throwable {
try {
init();
IValue value = eval("(double)" + xShort);
String typeName = value.getReferenceTypeName();
assertEquals("(double) short : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) short : wrong result : ", ( double) xShortValue, doubleValue, 0);
value = eval("(double)" + yShort);
typeName = value.getReferenceTypeName();
assertEquals("(double) short : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) short : wrong result : ", ( double) yShortValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastInt() throws Throwable {
try {
init();
IValue value = eval("(double)" + xInt);
String typeName = value.getReferenceTypeName();
assertEquals("(double) int : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) int : wrong result : ", ( double) xIntValue, doubleValue, 0);
value = eval("(double)" + yInt);
typeName = value.getReferenceTypeName();
assertEquals("(double) int : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) int : wrong result : ", ( double) yIntValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastLong() throws Throwable {
try {
init();
IValue value = eval("(double)" + xLong);
String typeName = value.getReferenceTypeName();
assertEquals("(double) long : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) long : wrong result : ", ( double) xLongValue, doubleValue, 0);
value = eval("(double)" + yLong);
typeName = value.getReferenceTypeName();
assertEquals("(double) long : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) long : wrong result : ", ( double) yLongValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastFloat() throws Throwable {
try {
init();
IValue value = eval("(double)" + xFloat);
String typeName = value.getReferenceTypeName();
assertEquals("(double) float : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) float : wrong result : ", ( double) xFloatValue, doubleValue, 0);
value = eval("(double)" + yFloat);
typeName = value.getReferenceTypeName();
assertEquals("(double) float : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) float : wrong result : ", ( double) yFloatValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
public void testDoubleCastDouble() throws Throwable {
try {
init();
IValue value = eval("(double)" + xDouble);
String typeName = value.getReferenceTypeName();
assertEquals("(double) double : wrong type : ", "double", typeName);
double doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) double : wrong result : ", ( double) xDoubleValue, doubleValue, 0);
value = eval("(double)" + yDouble);
typeName = value.getReferenceTypeName();
assertEquals("(double) double : wrong type : ", "double", typeName);
doubleValue = ((IJavaPrimitiveValue)value).getDoubleValue();
assertEquals("(double) double : wrong result : ", ( double) yDoubleValue, doubleValue, 0);
} catch (Throwable e) {
e.printStackTrace(); throw e;
} finally {;
end();
}
}
}