From b93f6be60a360a64bedd578a61aac3221a83bf24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Tue, 20 Mar 2018 18:07:55 +0000 Subject: [PATCH] Added type system tests. --- .../Kernel.cs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Tests/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs b/Tests/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs index 140487992..9a984165f 100644 --- a/Tests/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs +++ b/Tests/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs @@ -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, "isinst isn't working for generic interfaces on reference types!"); + + IComparable 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, "isinst isn't working for generic interfaces on value types!"); + + IEnumerable xEnumerable = new List(); + + Assert.IsTrue(xEnumerable.GetType() == typeof(List), "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, "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(); } }