Merge pull request #930 from CosmosOS/vmt-fixes-tests

Added type system tests
This commit is contained in:
jp2masa 2018-05-18 16:55:42 +01:00 committed by GitHub
commit 13b4b8e755
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
}
}