Skip to content

Commit

Permalink
Merge branch 'master' into dotnet8
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaProductions authored Jan 2, 2024
2 parents 1306c8f + 83ad76c commit 070670e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The following is a non-exhaustive list of features that Cosmos offers:
- A basic network interface
- A basic audio interface

> **Note**
> [!NOTE]
> Use [embeded resources](https://cosmosos.github.io/articles/Kernel/ManifestResouceStream.html) instead of the VFS for now for assets.
## Setting it up
Expand Down
4 changes: 2 additions & 2 deletions Tests/Cosmos.TestRunner.Core/Engine.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ private static string GetCosmosUserkitFolder()

private void MakeIso(string objectFile, string isoFile)
{
IsoMaker.Generate(objectFile, isoFile);
string response = IsoMaker.Generate(objectFile, isoFile);
if (!File.Exists(isoFile))
{
throw new Exception("Error building iso");
throw new Exception($"Error building iso: {response}");
}
}
}
Expand Down
45 changes: 45 additions & 0 deletions Tests/Kernels/Cosmos.Compiler.Tests.TypeSystem/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using IL2CPU.API.Attribs;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Sys = Cosmos.System;

namespace Cosmos.Compiler.Tests.TypeSystem
Expand Down Expand Up @@ -305,6 +306,7 @@ protected override void Run()
Assert.IsTrue(c != null, "Anonymous types are created correctly");
Assert.IsTrue(c.i == 1 && c.n == "Test", "Anonymous types have correct values");

TestPackedStruct();
TestVTablesImpl();
TestGarbageCollectorMethods();
TestGarbageCollector();
Expand Down Expand Up @@ -339,5 +341,48 @@ private static void TestReflection()
Assert.AreEqual("Int32", Type.GetType("System.Int32, System.Private.CoreLib").Name, "GetType works on Int32 with shortened assembly qualified name");
Assert.AreEqual("Int32", Type.GetType("System.Int32").Name, "GetType works on Int32 with shortened assembly qualified name");
}

PackedStruct GetPackedStruct()
{
return new PackedStruct()
{
a = 1,
b = 2,
c = 3,
d = 4,
e = 5,
f = 6
};
}

PackedStruct Re { get; set; }
private void TestPackedStruct()
{
Re = GetPackedStruct();

Assert.AreEqual(1, Re.a, "Correctly returned first field of struct");
Assert.AreEqual("1", Re.a.ToString(), "Correctly returned first field of struct as string");
Assert.AreEqual(2, Re.b, "Correctly returned second field of struct");
Assert.AreEqual("2", Re.b.ToString(), "Correctly returned second field of struct as string");
Assert.AreEqual(3, Re.c, "Correctly returned third field of struct");
Assert.AreEqual("3", Re.c.ToString(), "Correctly returned third field of struct as string");
Assert.AreEqual(4, Re.d, "Correctly returned fourth field of struct");
Assert.AreEqual("4", Re.d.ToString(), "Correctly returned fourth field of struct as string");
Assert.AreEqual(5, Re.e, "Correctly returned fifth field of struct");
Assert.AreEqual("5", Re.e.ToString(), "Correctly returned fifth field of struct as string");
Assert.AreEqual(6, Re.f, "Correctly returned sixth field of struct");
Assert.AreEqual("6", Re.f.ToString(), "Correctly returned sixth field of struct as string");
}
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PackedStruct
{
public ushort a;
public uint b;
public ulong c;
public ushort d;
public ushort e;
public ulong f;
}
}

0 comments on commit 070670e

Please sign in to comment.