feat(a1): VM core (operands+pointer semantics, handlers, emit-cap) + RECOVER
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
34
engine/Age.Engine.Tests/RecoverTests.cs
Normal file
34
engine/Age.Engine.Tests/RecoverTests.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Age.Engine.Hosting;
|
||||
using Age.Engine.Sys4;
|
||||
using Age.Engine.Vm;
|
||||
using Xunit;
|
||||
|
||||
public class RecoverTests
|
||||
{
|
||||
private static long G(VirtualMachine vm, int k) => vm.Globals.TryGetValue(k, out var v) ? v : 0;
|
||||
|
||||
[Fact]
|
||||
public void RecoverUnitTestPasses()
|
||||
{
|
||||
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
|
||||
var script = Sys4Loader.Load(Path.Combine(Paths.Data1, "RECOVER.BIN"), table);
|
||||
var vm = new VirtualMachine(script, table, new CaptureHost());
|
||||
|
||||
int unit = 0;
|
||||
vm.Globals[0x152616] = unit;
|
||||
int A = 0x4e11b, B = 0x4e085, C = 0x52383, E = 0x52f3b, F = 0x5295f, FL = 0xaacb4;
|
||||
for (int k = 0; k < 3; k++) vm.Globals[A + unit * 14 + (11 + k)] = 100 + k;
|
||||
vm.Globals[C + unit * 30 + 5] = 7; vm.Globals[FL + 5] = 1; vm.Globals[E + unit * 30 + 5] = 42;
|
||||
vm.Globals[C + unit * 30 + 6] = 0; vm.Globals[FL + 6] = 1; vm.Globals[E + unit * 30 + 6] = 99;
|
||||
vm.Globals[C + unit * 30 + 7] = 3; vm.Globals[FL + 7] = 0; vm.Globals[E + unit * 30 + 7] = 88;
|
||||
vm.Run();
|
||||
|
||||
Assert.Equal(100, G(vm, B + unit * 3 + 0));
|
||||
Assert.Equal(101, G(vm, B + unit * 3 + 1));
|
||||
Assert.Equal(102, G(vm, B + unit * 3 + 2));
|
||||
Assert.Equal(42, G(vm, C + unit * 30 + 5));
|
||||
Assert.Equal(-1, G(vm, F + unit * 30 + 5));
|
||||
Assert.Equal(0, G(vm, C + unit * 30 + 6));
|
||||
Assert.Equal(3, G(vm, C + unit * 30 + 7));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user