- Added tests for HashTable

- Changed plug in ArrayImpl taking 'this' as pointer with the ObjectPointerAccess attribute (this solves the foreach test in HashTable)
- Corrected Thread plug signature
- Corrected SpinWait plug signature
- Added plug for Decimal.Equal (strangely was not required before)
This commit is contained in:
fanoI 2018-04-30 21:40:53 +02:00
parent b3bd8cbd1e
commit bd6d211f5d
7 changed files with 29 additions and 26 deletions

View file

@ -8,6 +8,7 @@ using Cosmos.Compiler.Tests.Bcl.CSharp;
using Cosmos.Compiler.Tests.Bcl.System;
using Cosmos.Compiler.Tests.Bcl.System.Collections.Generic;
using Cosmos.Compiler.Tests.Bcl.System.Text;
using Cosmos.Compiler.Tests.Bcl.System.Collections;
namespace Cosmos.Compiler.Tests.Bcl
{
@ -57,11 +58,14 @@ namespace Cosmos.Compiler.Tests.Bcl
DelegatesTest.Execute();
RandomTests.Execute();
// System.Collections
HashtableTest.Execute();
// System.Collections.Generic
ListTest.Execute();
QueueTest.Execute();
QueueTest.Execute();
DictionaryTest.Execute();
// System.Text
EncodingTest.Execute();

View file

@ -4,7 +4,7 @@ using Cosmos.TestRunner;
//using Cosmos.Compiler.Tests.Bcl.Helper;
using Cosmos.Debug.Kernel;
namespace Cosmos.Compiler.Tests.Bcl.System.Collections.Not_Generic
namespace Cosmos.Compiler.Tests.Bcl.System.Collections
{
class HashtableTest
{
@ -31,27 +31,19 @@ namespace Cosmos.Compiler.Tests.Bcl.System.Collections.Not_Generic
Assert.IsTrue(h.Count == 2, "Hashtable Count failed: value != 2");
/*
* Got Il2CPU exception:
* System.Exception: Original method argument $this is a reference type. Plug attribute first argument is not an argument type, nor was it marked with ObjectPointerAccessAttribute! Method: SystemObjectSystemArrayGetValueSystemInt32 Parameter: aThis
* at Cosmos.IL2CPU.AppAssembler.GenerateMethodForward(_MethodInfo aFrom, _MethodInfo aTo) in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 1309
* at Cosmos.IL2CPU.ILScanner.Assemble() in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 951
* at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 255
* at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\fano\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 168
* Error invoking 'dotnet'.
*/
#if false
foreach (var k in h.Keys)
{
Assert.IsTrue((string)k == "One" || (string)k == "Two", "Hashtable key collection returns invalid key");
Assert.IsTrue((string)k == "One" || (string)k == "Two", "Hashtable key collection returns invalid keys");
}
#endif
/* This continues to not work: 42 is not a key! Why? */
#if false
Hashtable h2 = new Hashtable();
h2.Add(42, "FortyTwo");
Assert.IsTrue(h2.ContainsKey(42), "h2.ContainsKey() failed: existing key not found");
Assert.IsTrue(h2.ContainsKey((int)42), "h2.ContainsKey() failed: existing key not found");
#endif
}
}
}

View file

@ -36,14 +36,14 @@ namespace Cosmos.Core_Plugs.System
}
[PlugMethod(Signature = "System_Boolean__System_Array_TrySZBinarySearch_System_Array__System_Int32__System_Int32__System_Object___System_Int32_")]
public static unsafe bool TrySZBinarySearch(uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
public static unsafe bool TrySZBinarySearch([ObjectPointerAccess] uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
{
aArray = (uint*) aArray[0];
return TrySZIndexOf(aArray, sourceIndex, count, value, out retVal);
}
[PlugMethod(Signature = "System_Boolean__System_Array_TrySZLastIndexOf_System_Array__System_Int32__System_Int32__System_Object___System_Int32_")]
public static unsafe bool TrySZLastIndexOf(uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
public static unsafe bool TrySZLastIndexOf([ObjectPointerAccess] uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
{
aArray = (uint*) aArray[0];
aArray += 4;
@ -60,7 +60,7 @@ namespace Cosmos.Core_Plugs.System
}
//[PlugMethod(Signature = "System_Boolean__System_Array_TrySZIndexOf_System_Array__System_Int32__System_Int32__System_Object__System_Int32__")]
private static unsafe bool TrySZIndexOf(uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
private static unsafe bool TrySZIndexOf([ObjectPointerAccess] uint* aArray, uint sourceIndex, uint count, uint value, out uint retVal)
{
aArray = (uint*) aArray[0];
aArray += 4;
@ -92,7 +92,7 @@ namespace Cosmos.Core_Plugs.System
}
[PlugMethod(Signature = "System_Object__System_Array_GetValue_System_Int32_")]
public static unsafe uint GetValue(uint* aThis, int aIndex)
public static unsafe uint GetValue([ObjectPointerAccess]uint* aThis, int aIndex)
{
aThis = (uint*) aThis[0];
aThis += 3;
@ -119,7 +119,7 @@ namespace Cosmos.Core_Plugs.System
}
[PlugMethod(Signature = "System_Void__System_Array_SetValue_System_Object__System_Int32_")]
public static unsafe void SetValue(uint* aThis, uint aValue, int aIndex)
public static unsafe void SetValue([ObjectPointerAccess] uint* aThis, uint aValue, int aIndex)
{
aThis = (uint*) aThis[0];
aThis += 3;

View file

@ -3,7 +3,7 @@ using IL2CPU.API.Attribs;
namespace Cosmos.Core_Plugs.System.Threading
{
[Plug(Target = typeof(Thread))]
[Plug("System.Threading.Thread, System.Private.CoreLib")]
public static class ThreadImpl
{
public static Thread GetCurrentThreadNative()

View file

@ -16,5 +16,12 @@ namespace Cosmos.System_Plugs.System
{
throw new NotImplementedException("Decimal.ToString()");
}
public static bool Equals(ref decimal aThis, object value)
{
throw new NotImplementedException("Decimal.Equals()");
}
}
}

View file

@ -4,7 +4,8 @@ using IL2CPU.API.Attribs;
namespace Cosmos.System_Plugs.System.Threading
{
[Plug(Target = typeof(global::System.Threading.SpinWait))]
//[Plug(Target = typeof(global::System.Threading.SpinWait))]
[Plug(Target = typeof(SpinWait))]
public static class SpinWaitImpl
{
public static void SpinOnce(ref SpinWait aThis)

View file

@ -4,8 +4,7 @@ using IL2CPU.API.Attribs;
namespace Cosmos.System_Plugs.System.Threading
{
//[Plug(Target = typeof(Thread))]
[Plug(TargetName = "System.Threading.Thread")]
[Plug("System.Threading.Thread, System.Private.CoreLib")]
public static class ThreadImpl
{
public static void Sleep(TimeSpan timeout)