diff --git a/Demos/Guess/Guess.Cosmos b/Demos/Guess/Guess.Cosmos
index 0257764af..4c2b1c727 100644
--- a/Demos/Guess/Guess.Cosmos
+++ b/Demos/Guess/Guess.Cosmos
@@ -15,23 +15,23 @@
v4.5
- Bochs
+ VMware
true
bin\Debug\
MicrosoftNET
False
False
- IL
+ Source
User
PXE
Player
False
- Workstation
+ Player
ISO
False
ISO
- Bochs
- False
+ VMware
+ True
All
PXE
None
@@ -62,13 +62,13 @@
True
Source
False
- Workstation
+ Player
bin\Debug\
MicrosoftNET
False
All
- True
- True
+ False
+ False
ISO
None
False
@@ -82,7 +82,7 @@
False
false
Guess
- Use Bochs emulator to deploy and debug.
+ Use VMware Player or Workstation to deploy and debug.
User 001
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.
Guess
@@ -129,8 +129,8 @@
Pipe: Cosmos\Serial
False
Pipe: Cosmos\Serial
- True
- True
+ False
+ False
Guess
Use Bochs emulator to deploy and debug.
ISO
@@ -150,8 +150,8 @@
All
False
False
- True
- True
+ False
+ False
False
False
False
@@ -181,23 +181,23 @@
False
- Bochs
+ VMware
true
bin\Debug\
MicrosoftNET
False
False
- IL
+ Source
User
PXE
Player
False
- Workstation
+ Player
ISO
False
ISO
- Bochs
- False
+ VMware
+ True
All
PXE
None
@@ -228,13 +228,13 @@
True
Source
False
- Workstation
+ Player
bin\Debug\
MicrosoftNET
False
All
- True
- True
+ False
+ False
ISO
None
False
@@ -248,7 +248,7 @@
False
false
Guess
- Use Bochs emulator to deploy and debug.
+ Use VMware Player or Workstation to deploy and debug.
User 001
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.
Guess
@@ -301,8 +301,8 @@
False
False
False
- True
- True
+ False
+ False
Guess
Use Bochs emulator to deploy and debug.
ISO
@@ -322,8 +322,8 @@
All
False
False
- True
- True
+ False
+ False
False
False
False
diff --git a/Demos/Guess/GuessOS.cs b/Demos/Guess/GuessOS.cs
index dd228a1f2..d5771e3d7 100644
--- a/Demos/Guess/GuessOS.cs
+++ b/Demos/Guess/GuessOS.cs
@@ -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()
{
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.Bcl.csproj b/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.Bcl.csproj
index 2abbfe5d0..87b16afcd 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.Bcl.csproj
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.Bcl.csproj
@@ -79,10 +79,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.BclBoot.Cosmos b/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.BclBoot.Cosmos
index 0e5787463..3a7eac137 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.BclBoot.Cosmos
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/Cosmos.Compiler.Tests.BclBoot.Cosmos
@@ -10,7 +10,7 @@
v4.5
- VMware
+ Bochs
@@ -22,10 +22,32 @@
Player
bin\Debug\
Cosmos.Compiler.Tests.BclBoot
- Use VMware Player or Workstation to deploy and debug.
+ Use Bochs emulator to deploy and debug.
ISO
- VMware
+ Bochs
Pipe: Cosmos\Serial
+ Cosmos.Compiler.Tests.BclBoot
+ Use VMware Player or Workstation to deploy and debug.
+ ISO
+ VMware
+ true
+ Source
+ Pipe: Cosmos\Serial
+ Player
+ bin\Debug\
+ False
+ false
+ Cosmos.Compiler.Tests.BclBoot
+ Use Bochs emulator to deploy and debug.
+ ISO
+ Bochs
+ true
+ Source
+ Pipe: Cosmos\Serial
+ Player
+ bin\Debug\
+ False
+ false
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
index 8a1f82f70..7a774cd65 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
@@ -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();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs
new file mode 100644
index 000000000..39bbe68db
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/BooleanTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs
new file mode 100644
index 000000000..e967bf473
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ByteTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs
new file mode 100644
index 000000000..95249df85
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/CharTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs
new file mode 100644
index 000000000..d60958749
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/DecimalTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs
new file mode 100644
index 000000000..b85a6e4a3
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/DoubleTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs
new file mode 100644
index 000000000..67486ffad
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int16Test.cs
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs
new file mode 100644
index 000000000..ccacdbcc9
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int32Test.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs
new file mode 100644
index 000000000..e71c18728
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/Int64Test.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs
new file mode 100644
index 000000000..ca6bc4ea0
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/SByteTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs
new file mode 100644
index 000000000..a91193e70
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/SingleTest.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs
index e36319480..4e7a3e84e 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs
@@ -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 ");
}
}
}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs
new file mode 100644
index 000000000..b367be572
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt16Test.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs
new file mode 100644
index 000000000..bbc20f5fa
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt32Test.cs
@@ -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
+ }
+ }
+}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs
index 3f8326013..65040b55c 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/UInt64Test.cs
@@ -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)
diff --git a/Tests/Cosmos.Kernel.Tests.Fat/Cosmos.Kernel.Tests.FatBoot.Cosmos b/Tests/Cosmos.Kernel.Tests.Fat/Cosmos.Kernel.Tests.FatBoot.Cosmos
index 4b8a97eaf..26baa5ac0 100644
--- a/Tests/Cosmos.Kernel.Tests.Fat/Cosmos.Kernel.Tests.FatBoot.Cosmos
+++ b/Tests/Cosmos.Kernel.Tests.Fat/Cosmos.Kernel.Tests.FatBoot.Cosmos
@@ -30,7 +30,7 @@
Use VMware Player or Workstation to deploy and debug.
ISO
VMware
- False
+ True
Source
Pipe: Cosmos\Serial
Player
@@ -77,6 +77,7 @@
False
MethodFooters
MethodFooters
+ MethodFooters
diff --git a/source/Cosmos.Core.Plugs/System/StringImpl.cs b/source/Cosmos.Core.Plugs/System/StringImpl.cs
index 8714f0db6..5f73963dd 100644
--- a/source/Cosmos.Core.Plugs/System/StringImpl.cs
+++ b/source/Cosmos.Core.Plugs/System/StringImpl.cs
@@ -843,5 +843,9 @@ namespace Cosmos.Core.Plugs.System
throw new ArgumentNullException();
}
+ public static int GetHashCode(ref String aThis)
+ {
+ throw new NotImplementedException("String.GetHashCode()");
+ }
}
}
diff --git a/source/Cosmos.IL2CPU/ILOpCodes/OpNone.cs b/source/Cosmos.IL2CPU/ILOpCodes/OpNone.cs
index e7d7c6657..974167619 100644
--- a/source/Cosmos.IL2CPU/ILOpCodes/OpNone.cs
+++ b/source/Cosmos.IL2CPU/ILOpCodes/OpNone.cs
@@ -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)
diff --git a/source/Cosmos.IL2CPU/Plugs/System/ObjectImpl.cs b/source/Cosmos.IL2CPU/Plugs/System/ObjectImpl.cs
index d829d88de..a1269564b 100644
--- a/source/Cosmos.IL2CPU/Plugs/System/ObjectImpl.cs
+++ b/source/Cosmos.IL2CPU/Plugs/System/ObjectImpl.cs
@@ -61,5 +61,11 @@ namespace Cosmos.IL2CPU.Plugs.System
{
return null;
}
+
+ public static int GetHashCode(object aThis)
+ {
+ return (int)aThis;
+ }
+
}
}
diff --git a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj
index bb55de4f7..f421443ad 100644
--- a/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj
+++ b/source/Cosmos.System.Plugs/Cosmos.System.Plugs.csproj
@@ -88,9 +88,13 @@
+
+
+
+
@@ -135,6 +139,7 @@
+
@@ -170,4 +175,4 @@
-->
-
\ No newline at end of file
+
diff --git a/source/Cosmos.System.Plugs/System/ByteImpl.cs b/source/Cosmos.System.Plugs/System/ByteImpl.cs
index 7f8e846d8..8332cf905 100644
--- a/source/Cosmos.System.Plugs/System/ByteImpl.cs
+++ b/source/Cosmos.System.Plugs/System/ByteImpl.cs
@@ -1,4 +1,5 @@
-using Cosmos.Common;
+using System;
+using Cosmos.Common;
using Cosmos.IL2CPU.Plugs;
namespace Cosmos.System.Plugs.System
diff --git a/source/Cosmos.System.Plugs/System/DecimalImpl.cs b/source/Cosmos.System.Plugs/System/DecimalImpl.cs
new file mode 100644
index 000000000..34c76a70f
--- /dev/null
+++ b/source/Cosmos.System.Plugs/System/DecimalImpl.cs
@@ -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()");
+ }
+ }
+}
diff --git a/source/Cosmos.System.Plugs/System/EnumImpl.cs b/source/Cosmos.System.Plugs/System/EnumImpl.cs
index 6df0aa469..5fa26bd45 100644
--- a/source/Cosmos.System.Plugs/System/EnumImpl.cs
+++ b/source/Cosmos.System.Plugs/System/EnumImpl.cs
@@ -24,5 +24,10 @@ namespace Cosmos.System.Plugs.System
return " not implemented";
// return UInt32Impl.ToString(ref aThis);
}
+
+ public static int GetHashCode(Enum aThis)
+ {
+ throw new NotImplementedException("Enum.GetHashCode()");
+ }
}
}
\ No newline at end of file
diff --git a/source/Cosmos.System.Plugs/System/Globalization/CultureInfoImpl.cs b/source/Cosmos.System.Plugs/System/Globalization/CultureInfoImpl.cs
new file mode 100644
index 000000000..c41a33952
--- /dev/null
+++ b/source/Cosmos.System.Plugs/System/Globalization/CultureInfoImpl.cs
@@ -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()");
+ }
+ }
+}
diff --git a/source/Cosmos.System.Plugs/System/IntPtrImpl.cs b/source/Cosmos.System.Plugs/System/IntPtrImpl.cs
index 813e8bf87..c4bd46a92 100644
--- a/source/Cosmos.System.Plugs/System/IntPtrImpl.cs
+++ b/source/Cosmos.System.Plugs/System/IntPtrImpl.cs
@@ -13,5 +13,10 @@ namespace Cosmos.System.Plugs.System
return "";
}
//}
+
+ public static int GetHashCode(ref IntPtr aThis)
+ {
+ return (int)aThis;
+ }
}
}
\ No newline at end of file
diff --git a/source/Cosmos.System.Plugs/System/Runtime/Compilerservices/runtimehelpersImpl.cs b/source/Cosmos.System.Plugs/System/Runtime/Compilerservices/runtimehelpersImpl.cs
new file mode 100644
index 000000000..e9af397fd
--- /dev/null
+++ b/source/Cosmos.System.Plugs/System/Runtime/Compilerservices/runtimehelpersImpl.cs
@@ -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()");
+ }
+ }
+}
diff --git a/source/Cosmos.System.Plugs/System/RuntimeTypeImpl.cs b/source/Cosmos.System.Plugs/System/RuntimeTypeImpl.cs
new file mode 100644
index 000000000..d16de67a2
--- /dev/null
+++ b/source/Cosmos.System.Plugs/System/RuntimeTypeImpl.cs
@@ -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()");
+ }
+
+ }
+
+}
diff --git a/source/Cosmos.System.Plugs/System/UIntPtrImpl.cs b/source/Cosmos.System.Plugs/System/UIntPtrImpl.cs
index 725b74d1b..9d31dfb2d 100644
--- a/source/Cosmos.System.Plugs/System/UIntPtrImpl.cs
+++ b/source/Cosmos.System.Plugs/System/UIntPtrImpl.cs
@@ -13,5 +13,10 @@ namespace Cosmos.System.Plugs.System
return "";
}
//}
+
+ public static int GetHashCode(ref UIntPtr aThis)
+ {
+ return (int)aThis;
+ }
}
}
diff --git a/source/Cosmos.System.Plugs/System/ValueTypeImp.cs b/source/Cosmos.System.Plugs/System/ValueTypeImp.cs
new file mode 100644
index 000000000..fa58024a7
--- /dev/null
+++ b/source/Cosmos.System.Plugs/System/ValueTypeImp.cs
@@ -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()");
+ }
+
+ }
+}
diff --git a/source/Cosmos.sln b/source/Cosmos.sln
index 92da74abe..90ece9178 100644
--- a/source/Cosmos.sln
+++ b/source/Cosmos.sln
@@ -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