Add byte and Byte to Painless standard cast tests (#39415)
This commit is contained in:
parent
976f988358
commit
687a66b580
|
@ -795,4 +795,166 @@ public class StandardCastTests extends ScriptTestCase {
|
|||
expectScriptThrows(ClassCastException.class, () -> exec("Boolean o = Boolean.valueOf(true); ArrayList b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Boolean o = Boolean.valueOf(true); ArrayList b = (ArrayList)o;"));
|
||||
}
|
||||
|
||||
public void testPrimitiveByteCasts() {
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Object n = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Object n = (Object)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Number n = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Number n = (Number)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; String n = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; String n = (String)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; boolean b = (boolean)o;"));
|
||||
|
||||
exec("byte o = 0; byte b = o;");
|
||||
exec("byte o = 0; byte b = (byte)o;");
|
||||
|
||||
exec("byte o = 0; short b = o;");
|
||||
exec("byte o = 0; short b = (short)o;");
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; char b = o;"));
|
||||
exec("byte o = 0; char b = (char)o;");
|
||||
|
||||
exec("byte o = 0; int b = o;");
|
||||
exec("byte o = 0; int b = (int)o;");
|
||||
|
||||
exec("byte o = 0; long b = o;");
|
||||
exec("byte o = 0; long b = (long)o;");
|
||||
|
||||
exec("byte o = 0; float b = o;");
|
||||
exec("byte o = 0; float b = (float)o;");
|
||||
|
||||
exec("byte o = 0; double b = o;");
|
||||
exec("byte o = 0; double b = (double)o;");
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Boolean b = (Boolean)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Byte b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Byte b = (Byte)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Short b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Short b = (Short)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Character b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Character b = (Character)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Integer b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Integer b = (Integer)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Long b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Long b = (Long)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Float b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Float b = (Float)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Double b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = 0; Double b = (Double)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = Byte.valueOf((byte)0); ArrayList b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("byte o = Byte.valueOf((byte)0); ArrayList b = (ArrayList)o;"));
|
||||
}
|
||||
|
||||
public void testByteCasts() {
|
||||
exec("Byte o = Byte.valueOf((byte)0); Object n = o;");
|
||||
exec("Byte o = null; Object n = o;");
|
||||
exec("Byte o = Byte.valueOf((byte)0); Object n = (Object)o;");
|
||||
exec("Byte o = null; Object n = (Object)o;");
|
||||
|
||||
exec("Byte o = Byte.valueOf((byte)0); Number n = o;");
|
||||
exec("Byte o = null; Number n = o;");
|
||||
exec("Byte o = Byte.valueOf((byte)0); Number n = (Number)o;");
|
||||
exec("Byte o = null; Number n = (Number)o;");
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); String n = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; String n = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((Byte)0); String n = (String)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; String n = (String)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); boolean b = (boolean)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; boolean b = (boolean)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); byte b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; byte b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); byte b = (byte)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; byte b = (byte)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); short b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; short b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); short b = (short)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; short b = (short)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); char b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; char b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); char b = (char)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; char b = (char)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); int b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; int b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); int b = (int)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; int b = (int)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); long b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; long b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); long b = (long)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; long b = (long)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); float b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; float b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); float b = (float)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; float b = (float)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); double b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; double b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); double b = (double)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; double b = (double)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Boolean b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Boolean b = (Boolean)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Boolean b = (Boolean)o;"));
|
||||
|
||||
exec("Byte o = Byte.valueOf((byte)0); Byte b = o;");
|
||||
exec("Byte o = null; Byte b = o;");
|
||||
exec("Byte o = Byte.valueOf((byte)0); Byte b = (Byte)o;");
|
||||
exec("Byte o = null; Byte b = (Byte)o;");
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Short b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Short b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Short b = (Short)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; short b = (Short)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Character b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Character b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Character b = (Character)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; char b = (Character)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Integer b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Integer b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Integer b = (Integer)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; int b = (Integer)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Long b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Long b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Long b = (Long)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; long b = (Long)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Float b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Float b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Float b = (Float)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; float b = (Float)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Double b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; Double b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); Double b = (Double)o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = null; double b = (Double)o;"));
|
||||
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); ArrayList b = o;"));
|
||||
expectScriptThrows(ClassCastException.class, () -> exec("Byte o = Byte.valueOf((byte)0); ArrayList b = (ArrayList)o;"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue