Cosmos/Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs
fanoI eb533357b0 - Correctly plugged Enum's GetHashCode()
- Removed GetHashCode() methods that were not really needed
- Plugged class CultureInfo for GetHashCode()
- Plugged class Runtime.CompilerServices for GetHashCode()
- Plugged class RuntimeTypeImpl for GetHashCode()
- Fixed tests that were failing using true .NET GetHashCode()
- Fixed IL Interpreter added SHIFT, AND, XOR... for sbyte and short
2016-03-05 23:10:06 +01:00

51 lines
1.9 KiB
C#

using System;
using System.Linq;
using System.Threading.Tasks;
using Cosmos.TestRunner;
namespace Cosmos.Compiler.Tests.Bcl.System
{
class Int64Test
{
public static void Execute()
{
Int64 value;
String result;
String expectedResult;
value = Int64.MaxValue;
result = value.ToString();
expectedResult = "9223372036854775807";
Assert.IsTrue((result == expectedResult), "Int64.ToString doesn't work");
// Now let's try to concat to a String using '+' operator
result = "The Maximum value of an Int64 is " + value;
expectedResult = "The Maximum value of an Int64 is 9223372036854775807";
Assert.IsTrue((result == expectedResult), "String concat (Int64) doesn't work");
// Now let's try to use '$ instead of '+'
result = $"The Maximum value of an Int64 is {value}";
// Actually 'expectedResult' should be the same so...
Assert.IsTrue((result == expectedResult), "String format (Int64) doesn't work");
// Now let's Get the HashCode of a value
int resultAsInt = value.GetHashCode();
// actually the Hash Code of a Int64 is the value interpolated with XOR to obtain an Int32... so not the same of 'value'!
int expectedResultAsInt = (unchecked((int)((long)value)) ^ (int)(value >> 32));
Assert.IsTrue((resultAsInt == expectedResultAsInt), "Int64.GetHashCode() doesn't work"); // XXX TODO when GetHashCode() works
#if false
// Now let's try ToString() again but printed in hex (this test fails for now!)
result = value.ToString("X2");
expectedResult = "0x7FFFFFFFFFFFFFFF";
Assert.IsTrue((result == expectedResult), "Int64.ToString(X2) doesn't work");
#endif
}
}
}