mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
Merge pull request #343 from fanoI/master
Added new BCL Tests for Primitive Types
This commit is contained in:
commit
c2566edcf5
34 changed files with 899 additions and 48 deletions
|
|
@ -15,23 +15,23 @@
|
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<Profile>Bochs</Profile>
|
||||
<Profile>VMware</Profile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<Framework>MicrosoftNET</Framework>
|
||||
<UseInternalAssembler>False</UseInternalAssembler>
|
||||
<EnableGDB>False</EnableGDB>
|
||||
<DebugMode>IL</DebugMode>
|
||||
<DebugMode>Source</DebugMode>
|
||||
<TraceMode>User</TraceMode>
|
||||
<BuildTarget>PXE</BuildTarget>
|
||||
<VMWareFlavor>Player</VMWareFlavor>
|
||||
<StartCosmosGDB>False</StartCosmosGDB>
|
||||
<VMwareEdition>Workstation</VMwareEdition>
|
||||
<VMwareEdition>Player</VMwareEdition>
|
||||
<VMwareDeploy>ISO</VMwareDeploy>
|
||||
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
|
||||
<Deployment>ISO</Deployment>
|
||||
<Launch>Bochs</Launch>
|
||||
<DebugEnabled>False</DebugEnabled>
|
||||
<Launch>VMware</Launch>
|
||||
<DebugEnabled>True</DebugEnabled>
|
||||
<TraceAssemblies>All</TraceAssemblies>
|
||||
<PXE_Deployment>PXE</PXE_Deployment>
|
||||
<PXE_Launch>None</PXE_Launch>
|
||||
|
|
@ -62,13 +62,13 @@
|
|||
<VMware_DebugEnabled>True</VMware_DebugEnabled>
|
||||
<VMware_DebugMode>Source</VMware_DebugMode>
|
||||
<VMware_IgnoreDebugStubAttribute>False</VMware_IgnoreDebugStubAttribute>
|
||||
<VMware_VMwareEdition>Workstation</VMware_VMwareEdition>
|
||||
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
|
||||
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
|
||||
<VMware_Framework>MicrosoftNET</VMware_Framework>
|
||||
<VMware_UseInternalAssembler>False</VMware_UseInternalAssembler>
|
||||
<VMware_TraceAssemblies>All</VMware_TraceAssemblies>
|
||||
<VMware_EnableGDB>True</VMware_EnableGDB>
|
||||
<VMware_StartCosmosGDB>True</VMware_StartCosmosGDB>
|
||||
<VMware_EnableGDB>False</VMware_EnableGDB>
|
||||
<VMware_StartCosmosGDB>False</VMware_StartCosmosGDB>
|
||||
<ISO_Deployment>ISO</ISO_Deployment>
|
||||
<ISO_Launch>None</ISO_Launch>
|
||||
<ISO_DebugEnabled>False</ISO_DebugEnabled>
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
<ISO_EnableGDB>False</ISO_EnableGDB>
|
||||
<ISO_StartCosmosGDB>false</ISO_StartCosmosGDB>
|
||||
<Name>Guess</Name>
|
||||
<Description>Use Bochs emulator to deploy and debug.</Description>
|
||||
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
|
||||
<ISO_Name>User 001</ISO_Name>
|
||||
<ISO_Description>Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system.</ISO_Description>
|
||||
<USB_Name>Guess</USB_Name>
|
||||
|
|
@ -129,8 +129,8 @@
|
|||
<ISO_VisualStudioDebugPort>Pipe: Cosmos\Serial</ISO_VisualStudioDebugPort>
|
||||
<PXE_ShowLaunchConsole>False</PXE_ShowLaunchConsole>
|
||||
<PXE_VisualStudioDebugPort>Pipe: Cosmos\Serial</PXE_VisualStudioDebugPort>
|
||||
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
|
||||
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
|
||||
<StackCorruptionDetectionEnabled>False</StackCorruptionDetectionEnabled>
|
||||
<VMware_StackCorruptionDetectionEnabled>False</VMware_StackCorruptionDetectionEnabled>
|
||||
<Bochs_Name>Guess</Bochs_Name>
|
||||
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
|
||||
<Bochs_Deployment>ISO</Bochs_Deployment>
|
||||
|
|
@ -150,8 +150,8 @@
|
|||
<Bochs_TraceAssemblies>All</Bochs_TraceAssemblies>
|
||||
<Bochs_EnableGDB>False</Bochs_EnableGDB>
|
||||
<Bochs_StartCosmosGDB>False</Bochs_StartCosmosGDB>
|
||||
<EnableBochsDebug>True</EnableBochsDebug>
|
||||
<Bochs_EnableBochsDebug>True</Bochs_EnableBochsDebug>
|
||||
<EnableBochsDebug>False</EnableBochsDebug>
|
||||
<Bochs_EnableBochsDebug>False</Bochs_EnableBochsDebug>
|
||||
<PXE_StackCorruptionDetectionEnabled>False</PXE_StackCorruptionDetectionEnabled>
|
||||
<PXE_EnableBochsDebug>False</PXE_EnableBochsDebug>
|
||||
<VMware_EnableBochsDebug>False</VMware_EnableBochsDebug>
|
||||
|
|
@ -181,23 +181,23 @@
|
|||
<USB_EnableBochsDebug>False</USB_EnableBochsDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<Profile>Bochs</Profile>
|
||||
<Profile>VMware</Profile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<Framework>MicrosoftNET</Framework>
|
||||
<UseInternalAssembler>False</UseInternalAssembler>
|
||||
<EnableGDB>False</EnableGDB>
|
||||
<DebugMode>IL</DebugMode>
|
||||
<DebugMode>Source</DebugMode>
|
||||
<TraceMode>User</TraceMode>
|
||||
<BuildTarget>PXE</BuildTarget>
|
||||
<VMWareFlavor>Player</VMWareFlavor>
|
||||
<StartCosmosGDB>False</StartCosmosGDB>
|
||||
<VMwareEdition>Workstation</VMwareEdition>
|
||||
<VMwareEdition>Player</VMwareEdition>
|
||||
<VMwareDeploy>ISO</VMwareDeploy>
|
||||
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
|
||||
<Deployment>ISO</Deployment>
|
||||
<Launch>Bochs</Launch>
|
||||
<DebugEnabled>False</DebugEnabled>
|
||||
<Launch>VMware</Launch>
|
||||
<DebugEnabled>True</DebugEnabled>
|
||||
<TraceAssemblies>All</TraceAssemblies>
|
||||
<PXE_Deployment>PXE</PXE_Deployment>
|
||||
<PXE_Launch>None</PXE_Launch>
|
||||
|
|
@ -228,13 +228,13 @@
|
|||
<VMware_DebugEnabled>True</VMware_DebugEnabled>
|
||||
<VMware_DebugMode>Source</VMware_DebugMode>
|
||||
<VMware_IgnoreDebugStubAttribute>False</VMware_IgnoreDebugStubAttribute>
|
||||
<VMware_VMwareEdition>Workstation</VMware_VMwareEdition>
|
||||
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
|
||||
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
|
||||
<VMware_Framework>MicrosoftNET</VMware_Framework>
|
||||
<VMware_UseInternalAssembler>False</VMware_UseInternalAssembler>
|
||||
<VMware_TraceAssemblies>All</VMware_TraceAssemblies>
|
||||
<VMware_EnableGDB>True</VMware_EnableGDB>
|
||||
<VMware_StartCosmosGDB>True</VMware_StartCosmosGDB>
|
||||
<VMware_EnableGDB>False</VMware_EnableGDB>
|
||||
<VMware_StartCosmosGDB>False</VMware_StartCosmosGDB>
|
||||
<ISO_Deployment>ISO</ISO_Deployment>
|
||||
<ISO_Launch>None</ISO_Launch>
|
||||
<ISO_DebugEnabled>False</ISO_DebugEnabled>
|
||||
|
|
@ -248,7 +248,7 @@
|
|||
<ISO_EnableGDB>False</ISO_EnableGDB>
|
||||
<ISO_StartCosmosGDB>false</ISO_StartCosmosGDB>
|
||||
<Name>Guess</Name>
|
||||
<Description>Use Bochs emulator to deploy and debug.</Description>
|
||||
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
|
||||
<ISO_Name>User 001</ISO_Name>
|
||||
<ISO_Description>Creates a bootable ISO image which can be burned to a DVD. After running the selected project, an explorer window will open containing the ISO file. The ISO file can then be burned to a CD or DVD and used to boot a physical or virtual system.</ISO_Description>
|
||||
<USB_Name>Guess</USB_Name>
|
||||
|
|
@ -301,8 +301,8 @@
|
|||
<VMware_ShowLaunchConsole>False</VMware_ShowLaunchConsole>
|
||||
<ISO_ShowLaunchConsole>False</ISO_ShowLaunchConsole>
|
||||
<PXE_ShowLaunchConsole>False</PXE_ShowLaunchConsole>
|
||||
<StackCorruptionDetectionEnabled>True</StackCorruptionDetectionEnabled>
|
||||
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
|
||||
<StackCorruptionDetectionEnabled>False</StackCorruptionDetectionEnabled>
|
||||
<VMware_StackCorruptionDetectionEnabled>False</VMware_StackCorruptionDetectionEnabled>
|
||||
<Bochs_Name>Guess</Bochs_Name>
|
||||
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
|
||||
<Bochs_Deployment>ISO</Bochs_Deployment>
|
||||
|
|
@ -322,8 +322,8 @@
|
|||
<Bochs_TraceAssemblies>All</Bochs_TraceAssemblies>
|
||||
<Bochs_EnableGDB>False</Bochs_EnableGDB>
|
||||
<Bochs_StartCosmosGDB>False</Bochs_StartCosmosGDB>
|
||||
<EnableBochsDebug>True</EnableBochsDebug>
|
||||
<Bochs_EnableBochsDebug>True</Bochs_EnableBochsDebug>
|
||||
<EnableBochsDebug>False</EnableBochsDebug>
|
||||
<Bochs_EnableBochsDebug>False</Bochs_EnableBochsDebug>
|
||||
<PXE_StackCorruptionDetectionEnabled>False</PXE_StackCorruptionDetectionEnabled>
|
||||
<PXE_EnableBochsDebug>False</PXE_EnableBochsDebug>
|
||||
<VMware_EnableBochsDebug>False</VMware_EnableBochsDebug>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace GuessKernel
|
|||
public class GuessOS : Sys.Kernel
|
||||
{
|
||||
protected int mCount = 0;
|
||||
|
||||
|
||||
protected int mMagicNo = 22;
|
||||
|
||||
public GuessOS()
|
||||
|
|
@ -18,7 +18,7 @@ namespace GuessKernel
|
|||
// Didnt check if tickcount is working yet.. can change this later
|
||||
//var xRandom = new Random(234243534);
|
||||
//mMagicNo = xRandom.Next(1, 100);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void BeforeRun()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,10 +79,22 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Kernel.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="System\BooleanTest.cs" />
|
||||
<Compile Include="System\ByteTest.cs" />
|
||||
<Compile Include="System\CharTest.cs" />
|
||||
<Compile Include="System\Collections\Generic\ListTest.cs" />
|
||||
<Compile Include="System\Collections\Generic\QueueTest.cs" />
|
||||
<Compile Include="System\DecimalTest.cs" />
|
||||
<Compile Include="System\DelegatesTest.cs" />
|
||||
<Compile Include="System\DoubleTest.cs" />
|
||||
<Compile Include="System\Int16Test.cs" />
|
||||
<Compile Include="System\Int32Test.cs" />
|
||||
<Compile Include="System\Int64Test.cs" />
|
||||
<Compile Include="System\SByteTest.cs" />
|
||||
<Compile Include="System\SingleTest.cs" />
|
||||
<Compile Include="System\StringTest.cs" />
|
||||
<Compile Include="System\UInt16Test.cs" />
|
||||
<Compile Include="System\UInt32Test.cs" />
|
||||
<Compile Include="System\UInt64Test.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<Profile>VMware</Profile>
|
||||
<Profile>Bochs</Profile>
|
||||
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
|
||||
<DebugEnable>true</DebugEnable>
|
||||
-->
|
||||
|
|
@ -22,10 +22,32 @@
|
|||
<VMWareEdition>Player</VMWareEdition>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<Name>Cosmos.Compiler.Tests.BclBoot</Name>
|
||||
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
|
||||
<Description>Use Bochs emulator to deploy and debug.</Description>
|
||||
<Deployment>ISO</Deployment>
|
||||
<Launch>VMware</Launch>
|
||||
<Launch>Bochs</Launch>
|
||||
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
|
||||
<VMware_Name>Cosmos.Compiler.Tests.BclBoot</VMware_Name>
|
||||
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
|
||||
<VMware_Deployment>ISO</VMware_Deployment>
|
||||
<VMware_Launch>VMware</VMware_Launch>
|
||||
<VMware_DebugEnabled>true</VMware_DebugEnabled>
|
||||
<VMware_DebugMode>Source</VMware_DebugMode>
|
||||
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
|
||||
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
|
||||
<VMware_OutputPath>bin\Debug\</VMware_OutputPath>
|
||||
<VMware_EnableGDB>False</VMware_EnableGDB>
|
||||
<VMware_StartCosmosGDB>false</VMware_StartCosmosGDB>
|
||||
<Bochs_Name>Cosmos.Compiler.Tests.BclBoot</Bochs_Name>
|
||||
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
|
||||
<Bochs_Deployment>ISO</Bochs_Deployment>
|
||||
<Bochs_Launch>Bochs</Bochs_Launch>
|
||||
<Bochs_DebugEnabled>true</Bochs_DebugEnabled>
|
||||
<Bochs_DebugMode>Source</Bochs_DebugMode>
|
||||
<Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
|
||||
<Bochs_VMwareEdition>Player</Bochs_VMwareEdition>
|
||||
<Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
|
||||
<Bochs_EnableGDB>False</Bochs_EnableGDB>
|
||||
<Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983" />
|
||||
|
|
|
|||
|
|
@ -1,31 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Cosmos.Debug.Kernel;
|
||||
using Cosmos.TestRunner;
|
||||
using Sys = Cosmos.System;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl
|
||||
{
|
||||
using Cosmos.Compiler.Tests.Bcl.System;
|
||||
|
||||
|
||||
public class Kernel : Sys.Kernel
|
||||
{
|
||||
protected override void BeforeRun()
|
||||
{
|
||||
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
|
||||
Console.WriteLine("Cosmos booted successfully. Starting BCL tests now please wait...");
|
||||
}
|
||||
|
||||
public readonly Debugger mDebugger = new Debugger("User", "Test");
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
char x = 'a';
|
||||
string y = "a";
|
||||
Assert.IsTrue(x.ToString() == y, "x.ToString() == y");
|
||||
System.StringTest.Execute();
|
||||
System.Collections.Generic.ListTest.Execute();
|
||||
System.Collections.Generic.QueueTest.Execute();
|
||||
System.DelegatesTest.Execute();
|
||||
//System.UInt64Test.Execute();
|
||||
TestController.Completed();
|
||||
try
|
||||
{
|
||||
mDebugger.Send("Run");
|
||||
|
||||
StringTest.Execute();
|
||||
ByteTest.Execute();
|
||||
SByteTest.Execute();
|
||||
Int16Test.Execute();
|
||||
UInt16Test.Execute();
|
||||
Int32Test.Execute();
|
||||
UInt32Test.Execute();
|
||||
Int64Test.Execute();
|
||||
UInt64Test.Execute();
|
||||
CharTest.Execute();
|
||||
BooleanTest.Execute();
|
||||
SingleTest.Execute();
|
||||
DoubleTest.Execute();
|
||||
DecimalTest.Execute();
|
||||
System.Collections.Generic.ListTest.Execute();
|
||||
System.Collections.Generic.QueueTest.Execute();
|
||||
System.DelegatesTest.Execute();
|
||||
System.UInt64Test.Execute();
|
||||
TestController.Completed();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Exception occurred");
|
||||
Console.WriteLine(e.Message);
|
||||
mDebugger.Send("Exception occurred: " + e.Message);
|
||||
TestController.Failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Tests/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs
Normal file
50
Tests/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class BooleanTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Boolean value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = true;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "True";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Boolean.ToString doesn't work");
|
||||
|
||||
// Cosmos blocks again and never returns (?)
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The value of the Boolean is " + value;
|
||||
expectedResult = "The value of the Boolean is True";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Boolean) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The value of the Boolean is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Boolean) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of a Bool is 1 for true and 0 for false
|
||||
Assert.IsTrue((resultAsInt == 1), "Boolean.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Tests/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs
Normal file
49
Tests/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class ByteTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
byte value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = Byte.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "255";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Byte.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of a Byte is " + value;
|
||||
expectedResult = "The Maximum value of a Byte is 255";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Byte) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of a Byte is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Byte) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of a Byte is the same value expressed as int
|
||||
Assert.IsTrue((resultAsInt == value), "Byte.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "FF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Byte.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Tests/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs
Normal file
51
Tests/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class CharTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Char value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = 'A';
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "A";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Char.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
// This test is not working in a strange way: Cosmos never returns!
|
||||
result = "The first letter of the Alphabeth is " + value;
|
||||
expectedResult = "The first letter of the Alphabeth is A";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Char) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The first letter of the Alphabeth is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Char) doesn't work");
|
||||
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
// actually the Hash Code of a Char is a strange XOR trick...
|
||||
int expectedResultAsInt = (int)value | ((int)value << 16);
|
||||
|
||||
Assert.IsTrue((resultAsInt == expectedResultAsInt), "Char.GetHashCode() doesn't work");
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
53
Tests/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs
Normal file
53
Tests/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class DecimalTest
|
||||
{
|
||||
// This does not compile:
|
||||
public static void Execute()
|
||||
{
|
||||
#if false
|
||||
Decimal value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = 42.42M; // It exists Single.MaxValue but it is a too big value an can be represented only on Scientific notation but then how to confront with a String?
|
||||
|
||||
// This does not compile: Error: Exception: System.Exception: Native code encountered, plug required. Please see https://github.com/CosmosOS/Cosmos/wiki/Plugs). System.String System.Number.FormatDecimal(System.Decimal, System.String, System.Globalization.NumberFormatInfo
|
||||
result = value.ToString();
|
||||
expectedResult = "42.42";
|
||||
|
||||
// The test fails the conversion returns "Double Underrange"
|
||||
Assert.IsTrue((result == expectedResult), "Decimal.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The value of the Decimal is " + value;
|
||||
expectedResult = "The value of the Decimal is 42.42";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Decimal) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The value of the Decimal is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Decimal) doesn't work");
|
||||
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// TODO What is the hashcode of 42.42?
|
||||
Assert.IsTrue((resultAsInt == value), "Int32.GetHashCode() doesn't work");
|
||||
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs
Normal file
50
Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class DoubleTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Double value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = 42.42; // It exists Single.MaxValue but it is a too big value an can be represented only on Scientific notation but then how to confront with a String?
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "42.42";
|
||||
|
||||
// The test fails the conversion returns "Double Underrange"
|
||||
Assert.IsTrue((result == expectedResult), "Double.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The value of the Double is " + value;
|
||||
expectedResult = "The value of the Double is 42.42";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Double) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The value of the Double is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Double) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of a Int32 is the same value
|
||||
Assert.IsTrue((resultAsInt == value), "Int32.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Tests/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs
Normal file
50
Tests/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class Int16Test
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Int16 value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = Int16.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "32767";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int16.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of an Int16 is " + value;
|
||||
expectedResult = "The Maximum value of an Int16 is 32767";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Int16) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of an Int16 is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Int16) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
// actually the Hash Code of a Int16 is some strange XOR trick
|
||||
int expectedResultAsInt = ((int)((ushort)value) | (((int)value) << 16));
|
||||
|
||||
Assert.IsTrue((resultAsInt == expectedResultAsInt), "Int16.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "7FFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int16.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Tests/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs
Normal file
49
Tests/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class Int32Test
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Int32 value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = Int32.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "2147483647";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of an Int32 is " + value;
|
||||
expectedResult = "The Maximum value of an Int32 is 2147483647";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Int32) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of an Int32 is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Int32) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of an Int32 is the same value
|
||||
Assert.IsTrue((resultAsInt == value), "Int32.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs
Normal file
51
Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Tests/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs
Normal file
50
Tests/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class SByteTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
sbyte value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = SByte.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "127";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "SByte.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of a SByte is " + value;
|
||||
expectedResult = "The Maximum value of a SByte is 127";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (SByte) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of a SByte is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (SByte) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
// The Hash Code of a SByte is not the same value expressed as int but some XOR tricks are done in the value
|
||||
int expectedResultAsInt = ((int)value ^ (int)value << 8);
|
||||
|
||||
Assert.IsTrue((resultAsInt == expectedResultAsInt), "SByte.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "FF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Byte.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs
Normal file
51
Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class SingleTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
#if false
|
||||
// Opps! This trigger CPU 0x0 Exception... System halts!
|
||||
Single value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = 42.42F; // It exists Single.MaxValue but it is a too big value an can be represented only on Scientific notation but then how to confront with a String?
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "42.42";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Single.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The value of the Single is " + value;
|
||||
expectedResult = "The value of the Single is 42.42";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (Single) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The value of the Single is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (Single) doesn't work");
|
||||
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// TODO What is the Hashcode of 42.42?
|
||||
Assert.IsTrue((resultAsInt == value), "Int32.GetHashCode() doesn't work");
|
||||
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,10 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
|||
{
|
||||
Assert.IsTrue(("a" + "b") == "ab", "concatting 2 string using + doesn't work");
|
||||
Assert.IsTrue(("a" + 'b') == "ab", "concatting 1 string and 1 character doesn't work");
|
||||
|
||||
char x = 'a';
|
||||
string y = "a";
|
||||
Assert.IsTrue(x.ToString() == y, "String == operator ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
49
Tests/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs
Normal file
49
Tests/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class UInt16Test
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
UInt16 value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = UInt16.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "65535";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "UInt16.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of an UInt16 is " + value;
|
||||
expectedResult = "The Maximum value of an UInt16 is 65535";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (UInt16) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of an UInt16 is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (UInt16) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of a Byte is the same value expressed as int
|
||||
Assert.IsTrue((resultAsInt == value), "UInt16.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "FFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "UInt16.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Tests/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs
Normal file
49
Tests/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
class UInt32Test
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
UInt32 value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = UInt32.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "4294967295";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "UInt32.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of an UInt32 is " + value;
|
||||
expectedResult = "The Maximum value of an UInt32 is 4294967295";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (UInt32) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of an UInt32 is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (UInt32) doesn't work");
|
||||
|
||||
// Now let's Get the HashCode of a value
|
||||
int resultAsInt = value.GetHashCode();
|
||||
|
||||
// actually the Hash Code of a Int32 is the same value (but expressed as Int32 so could have sign!)
|
||||
Assert.IsTrue((resultAsInt == (int)value), "UInt32.GetHashCode() doesn't work");
|
||||
|
||||
#if false
|
||||
// Now let's try ToString() again but printed in hex (this test fails for now!)
|
||||
result = value.ToString("X2");
|
||||
expectedResult = "0x7FFFFFFF";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "Int32.ToString(X2) doesn't work");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,48 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
|||
{
|
||||
public static void Execute()
|
||||
{
|
||||
UInt64 value;
|
||||
String result;
|
||||
String expectedResult;
|
||||
|
||||
value = UInt64.MaxValue;
|
||||
|
||||
result = value.ToString();
|
||||
expectedResult = "18446744073709551615";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "UInt64.ToString doesn't work");
|
||||
|
||||
// Now let's try to concat to a String using '+' operator
|
||||
result = "The Maximum value of an UInt64 is " + value;
|
||||
expectedResult = "The Maximum value of an UInt64 is 18446744073709551615";
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "String concat (UInt64) doesn't work");
|
||||
|
||||
// Now let's try to use '$ instead of '+'
|
||||
result = $"The Maximum value of an UInt64 is {value}";
|
||||
// Actually 'expectedResult' should be the same so...
|
||||
Assert.IsTrue((result == expectedResult), "String format (UInt64) 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 = ((int)value) ^ (int)(value >> 32);
|
||||
|
||||
Assert.IsTrue((resultAsInt == expectedResultAsInt), "UInt64.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 = "0xFFFFFFFFFFFFFFFF";
|
||||
|
||||
|
||||
Assert.IsTrue((result == expectedResult), "UInt64.ToString(X2) doesn't work");
|
||||
|
||||
|
||||
var xTest = TestMethod(0);
|
||||
Assert.IsTrue(xTest.Length == 0, "UInt64 test failed.");
|
||||
#endif
|
||||
}
|
||||
|
||||
public static ulong[] TestMethod(ulong aParam1, uint aParam2 = 0)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<VMware_Description>Use VMware Player or Workstation to deploy and debug.</VMware_Description>
|
||||
<VMware_Deployment>ISO</VMware_Deployment>
|
||||
<VMware_Launch>VMware</VMware_Launch>
|
||||
<VMware_DebugEnabled>False</VMware_DebugEnabled>
|
||||
<VMware_DebugEnabled>True</VMware_DebugEnabled>
|
||||
<VMware_DebugMode>Source</VMware_DebugMode>
|
||||
<VMware_VisualStudioDebugPort>Pipe: Cosmos\Serial</VMware_VisualStudioDebugPort>
|
||||
<VMware_VMwareEdition>Player</VMware_VMwareEdition>
|
||||
|
|
@ -77,6 +77,7 @@
|
|||
<VMware_StartBochsDebugGui>False</VMware_StartBochsDebugGui>
|
||||
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
|
||||
<Bochs_StackCorruptionDetectionLevel>MethodFooters</Bochs_StackCorruptionDetectionLevel>
|
||||
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\source\Cosmos.Core.Plugs\Cosmos.Core.Plugs.csproj">
|
||||
|
|
|
|||
|
|
@ -843,5 +843,9 @@ namespace Cosmos.Core.Plugs.System
|
|||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
public static int GetHashCode(ref String aThis)
|
||||
{
|
||||
throw new NotImplementedException("String.GetHashCode()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -729,6 +729,14 @@ namespace Cosmos.IL2CPU.ILOpCodes {
|
|||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((StackPopTypes[0] == typeof(int) && StackPopTypes[1] == typeof(sbyte))
|
||||
|| (StackPopTypes[0] == typeof(sbyte) && StackPopTypes[1] == typeof(int)))
|
||||
{
|
||||
StackPushTypes[0] = typeof(int);
|
||||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
if (StackPopTypes[0] == StackPopTypes[1] && StackPopTypes[0].IsPointer)
|
||||
{
|
||||
StackPushTypes[0] = StackPopTypes[0];
|
||||
|
|
@ -749,7 +757,6 @@ namespace Cosmos.IL2CPU.ILOpCodes {
|
|||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (OpCode == Code.Add &&
|
||||
((StackPopTypes[0] == typeof(IntPtr) && (StackPopTypes[1].IsPointer || StackPopTypes[1].IsByRef))
|
||||
|| ((StackPopTypes[0].IsPointer || StackPopTypes[0].IsByRef) && StackPopTypes[1] == typeof(IntPtr))))
|
||||
|
|
@ -870,6 +877,18 @@ namespace Cosmos.IL2CPU.ILOpCodes {
|
|||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
if (xTypeValue == typeof(sbyte) && xTypeShift == typeof(int))
|
||||
{
|
||||
StackPushTypes[0] = typeof(int);
|
||||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
if (xTypeValue == typeof(short) && xTypeShift == typeof(int))
|
||||
{
|
||||
StackPushTypes[0] = typeof(int);
|
||||
aSituationChanged = true;
|
||||
return;
|
||||
}
|
||||
throw new NotImplementedException(String.Format("{0} with types {1} and {2} is not implemented!", OpCode, xTypeValue.FullName, xTypeShift.FullName));
|
||||
case Code.Ldelem_Ref:
|
||||
if (StackPushTypes[0] != null)
|
||||
|
|
|
|||
|
|
@ -61,5 +61,11 @@ namespace Cosmos.IL2CPU.Plugs.System
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int GetHashCode(object aThis)
|
||||
{
|
||||
return (int)aThis;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,9 +88,13 @@
|
|||
<Reference Include="System.Drawing" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="System\DecimalImpl.cs" />
|
||||
<Compile Include="System\ValueTypeImpl.cs" />
|
||||
<Compile Include="System\EnumImpl.cs" />
|
||||
<Compile Include="System\Globalization\CultureInfoImpl.cs" />
|
||||
<Compile Include="System\IO\ErrorImpl.cs" />
|
||||
<Compile Include="System\RuntimeTypeImpl.cs" />
|
||||
<Compile Include="System\Runtime\Compilerservices\runtimehelpersImpl.cs" />
|
||||
<Compile Include="System\Security\SecurityElementImpl.cs" />
|
||||
<Compile Include="System\Security\CodeAccessSecurityEngineImpl.cs" />
|
||||
<Compile Include="System\Security\Cryptography\UtilsImpl.cs" />
|
||||
|
|
@ -135,6 +139,7 @@
|
|||
<Compile Include="System\UInt32Impl.cs" />
|
||||
<Compile Include="System\UInt64Impl.cs" />
|
||||
<Compile Include="System\UIntPtrImpl.cs" />
|
||||
<Compile Include="System\ValueTypeImp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Cosmos.Common\Cosmos.Common.csproj">
|
||||
|
|
@ -170,4 +175,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Cosmos.Common;
|
||||
using System;
|
||||
using Cosmos.Common;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.System.Plugs.System
|
||||
|
|
|
|||
21
source/Cosmos.System.Plugs/System/DecimalImpl.cs
Normal file
21
source/Cosmos.System.Plugs/System/DecimalImpl.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System;
|
||||
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.System.Plugs.System
|
||||
{
|
||||
[Plug(Target = typeof(decimal))]
|
||||
public static class DecimalImpl
|
||||
{
|
||||
public static int GetHashCode(ref decimal aThis)
|
||||
{
|
||||
throw new NotImplementedException("Decimal.GetHashCode()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,5 +24,10 @@ namespace Cosmos.System.Plugs.System
|
|||
return "<Enum.ToString> not implemented";
|
||||
// return UInt32Impl.ToString(ref aThis);
|
||||
}
|
||||
|
||||
public static int GetHashCode(Enum aThis)
|
||||
{
|
||||
throw new NotImplementedException("Enum.GetHashCode()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Cosmos.Common;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.System.Plugs.System.Globalization
|
||||
{
|
||||
[Plug(Target = typeof(global::System.Globalization.CultureInfo))]
|
||||
public static class CultureInfoPlug
|
||||
{
|
||||
public static int GetHashCode(global::System.Globalization.CultureInfo aThis)
|
||||
{
|
||||
throw new NotImplementedException("CultureInfo.GetHashCode()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,5 +13,10 @@ namespace Cosmos.System.Plugs.System
|
|||
return "<IntPtr>";
|
||||
}
|
||||
//}
|
||||
|
||||
public static int GetHashCode(ref IntPtr aThis)
|
||||
{
|
||||
return (int)aThis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using Cosmos.Common;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
|
||||
namespace Cosmos.System.Plugs.System.Runtime.Compilerservices
|
||||
{
|
||||
|
||||
[Plug(Target = typeof(global::System.Runtime.CompilerServices.RuntimeHelpers))]
|
||||
public static class runtimehelpersImpl
|
||||
{
|
||||
public static int GetHashCode(object o)
|
||||
{
|
||||
throw new NotImplementedException("runtimehelpersImpl.GetHashCode()");
|
||||
}
|
||||
}
|
||||
}
|
||||
17
source/Cosmos.System.Plugs/System/RuntimeTypeImpl.cs
Normal file
17
source/Cosmos.System.Plugs/System/RuntimeTypeImpl.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.System.Plugs.System
|
||||
{
|
||||
[Plug(TargetName = "System.RuntimeType")]
|
||||
public static class RuntimeTypePlug
|
||||
{
|
||||
public static string ToString(object aThis)
|
||||
{
|
||||
throw new NotImplementedException("RuntimeTypePlug.ToStrin()");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,5 +13,10 @@ namespace Cosmos.System.Plugs.System
|
|||
return "<UIntPtr>";
|
||||
}
|
||||
//}
|
||||
|
||||
public static int GetHashCode(ref UIntPtr aThis)
|
||||
{
|
||||
return (int)aThis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
source/Cosmos.System.Plugs/System/ValueTypeImp.cs
Normal file
24
source/Cosmos.System.Plugs/System/ValueTypeImp.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using Cosmos.Common;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.System.Plugs.System
|
||||
{
|
||||
[Plug(Target = typeof(ValueType))]
|
||||
public static class ValueTypeImp
|
||||
{
|
||||
public static int GetHashCode(ValueType aThis)
|
||||
{
|
||||
if (aThis is byte)
|
||||
return (int)aThis;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int GetHashCodeOfPtr(IntPtr ptr)
|
||||
{
|
||||
throw new NotImplementedException("ValueType.GetHashCodeOfPtr()");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{D95021E1-A2C9-4829-819E-ED433AF13162}"
|
||||
EndProject
|
||||
|
|
|
|||
Loading…
Reference in a new issue