Add Assembler tests

This commit is contained in:
Yoshi Askharoun
2024-02-03 20:51:54 -06:00
parent d95fcab104
commit cf3419c435
6 changed files with 55 additions and 6 deletions
+21
View File
@@ -3,6 +3,7 @@ using Microsoft.Iris.Asm;
using Xunit.Abstractions; using Xunit.Abstractions;
using Microsoft.Iris.Markup; using Microsoft.Iris.Markup;
using UIX.Test.Fixtures; using UIX.Test.Fixtures;
using Microsoft.Iris;
namespace UIX.Test; namespace UIX.Test;
@@ -36,6 +37,26 @@ main:
Assert.Equal(9, ast.Body.Count()); Assert.Equal(9, ast.Body.Count());
} }
[Fact]
public async Task Assemble()
{
using TempFile tempFile = new("testA.uixa", ".uixa");
await tempFile.InitAsync();
CompilerInput[] compilerInputs = [
new()
{
SourceFileName = tempFile.Path,
OutputFileName = Path.ChangeExtension(tempFile.Path, ".uib")
}
];
foreach (var compilerInput in compilerInputs)
output.WriteLine(compilerInput.OutputFileName);
MarkupCompiler.Compile(compilerInputs, default);
}
[Theory] [Theory]
[InlineData("text.uib")] [InlineData("text.uib")]
[InlineData("text.uix")] [InlineData("text.uix")]
@@ -1,4 +1,5 @@
using Microsoft.Iris.Markup; using Microsoft.Iris.Asm;
using Microsoft.Iris.Markup;
namespace UIX.Test.Fixtures; namespace UIX.Test.Fixtures;
@@ -7,6 +8,7 @@ public class MarkupSystemFixture : IDisposable
public MarkupSystemFixture() public MarkupSystemFixture()
{ {
MarkupSystem.Startup(true); MarkupSystem.Startup(true);
Assembler.RegisterLoader();
} }
public void Dispose() => MarkupSystem.Shutdown(); public void Dispose() => MarkupSystem.Shutdown();
+6 -5
View File
@@ -5,23 +5,24 @@ namespace UIX.Test.Helpers;
internal class TempFile : IDisposable, IAsyncInit internal class TempFile : IDisposable, IAsyncInit
{ {
private const string _defaultFileExtension = ".tmp";
private readonly Func<Task> _init; private readonly Func<Task> _init;
public TempFile(System.Resources.ResourceManager resourceManager, string resourceName) public TempFile(System.Resources.ResourceManager resourceManager, string resourceName, string fileExtension = _defaultFileExtension)
: this((byte[])resourceManager.GetObject(resourceName)!) : this((byte[])resourceManager.GetObject(resourceName)!, fileExtension)
{ {
} }
public TempFile(string resourceName) : this(TestResources.ResourceManager, resourceName) public TempFile(string resourceName, string fileExtension = _defaultFileExtension) : this(TestResources.ResourceManager, resourceName, fileExtension)
{ {
} }
public TempFile(byte[] data) public TempFile(byte[] data, string fileExtension = _defaultFileExtension)
{ {
_init = async delegate _init = async delegate
{ {
// Copy the test data to a temporary file because Iris can only load from a URI. // Copy the test data to a temporary file because Iris can only load from a URI.
Path = System.IO.Path.GetTempFileName(); Path = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), fileExtension);
await File.WriteAllBytesAsync(Path, data); await File.WriteAllBytesAsync(Path, data);
}; };
} }
+12
View File
@@ -0,0 +1,12 @@
.import-ns Me as me
.import-ns assembly://UIX/Microsoft.Iris as iris
main:
COBJ 2
PSHC 0
PINI 1
PSHC 1
PINI 2
PINI 0
RETV
RETV
+10
View File
@@ -70,6 +70,16 @@ namespace UIX.Test {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] testA_uixa {
get {
object obj = ResourceManager.GetObject("testA.uixa", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Byte[]. /// Looks up a localized resource of type System.Byte[].
/// </summary> /// </summary>
+3
View File
@@ -121,6 +121,9 @@
<data name="testA.uix" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="testA.uix" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\testA.uix;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>Resources\testA.uix;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="testA.uixa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\testA.uixa;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="testB.uix" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="testB.uix" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\testB.uix;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>Resources\testB.uix;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>