}
[Theory, ClassData(typeof(CompilationTypes))]
+ public static void ConvertByteToSByteRetIntTest(bool useInterpreter)
+ {
+ foreach (byte value in new byte[] { 0, 1, byte.MaxValue })
+ {
+ VerifyByteToSByteRetInt(value, useInterpreter);
+ }
+ }
+
+ [Theory, ClassData(typeof(CompilationTypes))]
public static void ConvertByteToNullableSByteTest(bool useInterpreter)
{
foreach (byte value in new byte[] { 0, 1, byte.MaxValue })
}
[Theory, ClassData(typeof(CompilationTypes))]
+ public static void ConvertSByteToByteRetIntTest(bool useInterpreter)
+ {
+ foreach (sbyte value in new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue })
+ {
+ VerifySByteToByteRetInt(value, useInterpreter);
+ }
+ }
+
+ [Theory, ClassData(typeof(CompilationTypes))]
public static void ConvertSByteToNullableByteTest(bool useInterpreter)
{
foreach (sbyte value in new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue })
}
[Theory, ClassData(typeof(CompilationTypes))]
+ public static void ConvertShortToUShortRetIntTest(bool useInterpreter)
+ {
+ foreach (short value in new short[] { 0, 1, -1, short.MinValue, short.MaxValue })
+ {
+ VerifyShortToUShortRetInt(value, useInterpreter);
+ }
+ }
+
+ [Theory, ClassData(typeof(CompilationTypes))]
public static void ConvertShortToNullableUShortTest(bool useInterpreter)
{
foreach (short value in new short[] { 0, 1, -1, short.MinValue, short.MaxValue })
}
[Theory, ClassData(typeof(CompilationTypes))]
+ public static void ConvertUShortToShortRetIntTest(bool useInterpreter)
+ {
+ foreach (ushort value in new ushort[] { 0, 1, ushort.MaxValue })
+ {
+ VerifyUShortToShortRetInt(value, useInterpreter);
+ }
+ }
+
+ [Theory, ClassData(typeof(CompilationTypes))]
public static void ConvertUShortToNullableShortTest(bool useInterpreter)
{
foreach (ushort value in new ushort[] { 0, 1, ushort.MaxValue })
Assert.Equal(unchecked((sbyte)value), f());
}
+ private static void VerifyByteToSByteRetInt(byte value, bool useInterpreter)
+ {
+ Expression<Func<int>> e =
+ Expression.Lambda<Func<int>>(
+ Expression.Convert(Expression.Convert(Expression.Constant(value, typeof(byte)), typeof(sbyte)), typeof(int)),
+ Enumerable.Empty<ParameterExpression>());
+ Func<int> f = e.Compile(useInterpreter);
+
+ Assert.Equal((int)unchecked((sbyte)value), f());
+ }
+
private static void VerifyByteToNullableSByte(byte value, bool useInterpreter)
{
Expression<Func<sbyte?>> e =
Assert.Equal(unchecked((byte)value), f());
}
+ private static void VerifySByteToByteRetInt(sbyte value, bool useInterpreter)
+ {
+ Expression<Func<int>> e =
+ Expression.Lambda<Func<int>>(
+ Expression.Convert(Expression.Convert(Expression.Constant(value, typeof(sbyte)), typeof(byte)), typeof(int)),
+ Enumerable.Empty<ParameterExpression>());
+ Func<int> f = e.Compile(useInterpreter);
+
+ Assert.Equal((int)unchecked((byte)value), f());
+ }
+
private static void VerifySByteToNullableByte(sbyte value, bool useInterpreter)
{
Expression<Func<byte?>> e =
Assert.Equal(unchecked((ushort)value), f());
}
+ private static void VerifyShortToUShortRetInt(short value, bool useInterpreter)
+ {
+ Expression<Func<int>> e =
+ Expression.Lambda<Func<int>>(
+ Expression.Convert(Expression.Convert(Expression.Constant(value, typeof(short)), typeof(ushort)), typeof(int)),
+ Enumerable.Empty<ParameterExpression>());
+ Func<int> f = e.Compile(useInterpreter);
+
+ Assert.Equal((int)unchecked((ushort)value), f());
+ }
+
private static void VerifyShortToNullableUShort(short value, bool useInterpreter)
{
Expression<Func<ushort?>> e =
Assert.Equal(unchecked((short)value), f());
}
+ private static void VerifyUShortToShortRetInt(ushort value, bool useInterpreter)
+ {
+ Expression<Func<int>> e =
+ Expression.Lambda<Func<int>>(
+ Expression.Convert(Expression.Convert(Expression.Constant(value, typeof(ushort)), typeof(short)), typeof(int)),
+ Enumerable.Empty<ParameterExpression>());
+ Func<int> f = e.Compile(useInterpreter);
+
+ Assert.Equal((int)unchecked((short)value), f());
+ }
+
private static void VerifyUShortToNullableShort(ushort value, bool useInterpreter)
{
Expression<Func<short?>> e =