mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +00:00
Merge pull request #930 from CosmosOS/vmt-fixes-tests
Added type system tests
This commit is contained in:
commit
13b4b8e755
1 changed files with 24 additions and 8 deletions
|
|
@ -1,7 +1,10 @@
|
|||
using Cosmos.TestRunner;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sys = Cosmos.System;
|
||||
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.TypeSystem
|
||||
{
|
||||
public class Kernel : Sys.Kernel
|
||||
|
|
@ -17,12 +20,23 @@ namespace Cosmos.Compiler.Tests.TypeSystem
|
|||
{
|
||||
mDebugger.Send("Run");
|
||||
|
||||
string xString = "a";
|
||||
Type xType = xString.GetType();
|
||||
if (xType == typeof(string))
|
||||
{
|
||||
mDebugger.Send("Type is a string.");
|
||||
}
|
||||
object xString = "a";
|
||||
|
||||
Assert.IsTrue(xString.GetType() == typeof(string), "GetType or typeof() isn't working on reference types!");
|
||||
Assert.IsTrue(xString is ICloneable, "isinst isn't working for interfaces on reference types!");
|
||||
Assert.IsTrue(xString is IEnumerable<char>, "isinst isn't working for generic interfaces on reference types!");
|
||||
|
||||
IComparable<int> xNumber = 3;
|
||||
|
||||
Assert.IsTrue(xNumber.GetType() == typeof(int), "GetType or typeof() isn't working on value types!");
|
||||
Assert.IsTrue(xNumber is IConvertible, "isinst isn't working for interfaces on value types!");
|
||||
Assert.IsTrue(xNumber is IEquatable<int>, "isinst isn't working for generic interfaces on value types!");
|
||||
|
||||
IEnumerable<string> xEnumerable = new List<string>();
|
||||
|
||||
Assert.IsTrue(xEnumerable.GetType() == typeof(List<string>), "GetType or typeof() isn't working on generic reference types!");
|
||||
Assert.IsTrue(xEnumerable is IEnumerable, "isinst isn't working for interfaces on generic reference types!");
|
||||
Assert.IsTrue(xEnumerable is IList<string>, "isinst isn't working for generic interfaces on generic reference types!");
|
||||
|
||||
TestController.Completed();
|
||||
}
|
||||
|
|
@ -30,8 +44,10 @@ namespace Cosmos.Compiler.Tests.TypeSystem
|
|||
{
|
||||
mDebugger.Send("Exception occurred: " + e.Message);
|
||||
mDebugger.Send(e.Message);
|
||||
|
||||
Console.WriteLine("Exception occurred");
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
TestController.Failed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue