mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Add Assembler tests
This commit is contained in:
@@ -3,6 +3,7 @@ using Microsoft.Iris.Asm;
|
||||
using Xunit.Abstractions;
|
||||
using Microsoft.Iris.Markup;
|
||||
using UIX.Test.Fixtures;
|
||||
using Microsoft.Iris;
|
||||
|
||||
namespace UIX.Test;
|
||||
|
||||
@@ -36,6 +37,26 @@ main:
|
||||
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]
|
||||
[InlineData("text.uib")]
|
||||
[InlineData("text.uix")]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.Asm;
|
||||
using Microsoft.Iris.Markup;
|
||||
|
||||
namespace UIX.Test.Fixtures;
|
||||
|
||||
@@ -7,6 +8,7 @@ public class MarkupSystemFixture : IDisposable
|
||||
public MarkupSystemFixture()
|
||||
{
|
||||
MarkupSystem.Startup(true);
|
||||
Assembler.RegisterLoader();
|
||||
}
|
||||
|
||||
public void Dispose() => MarkupSystem.Shutdown();
|
||||
|
||||
@@ -5,23 +5,24 @@ namespace UIX.Test.Helpers;
|
||||
|
||||
internal class TempFile : IDisposable, IAsyncInit
|
||||
{
|
||||
private const string _defaultFileExtension = ".tmp";
|
||||
private readonly Func<Task> _init;
|
||||
|
||||
public TempFile(System.Resources.ResourceManager resourceManager, string resourceName)
|
||||
: this((byte[])resourceManager.GetObject(resourceName)!)
|
||||
public TempFile(System.Resources.ResourceManager resourceManager, string resourceName, string fileExtension = _defaultFileExtension)
|
||||
: 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
|
||||
{
|
||||
// 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);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Generated
+10
@@ -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>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
<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>
|
||||
</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">
|
||||
<value>Resources\testB.uix;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user