mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-04-20 21:16:29 +00:00
Make the Fuse test classes more generic, so I can use them again for the Z80 fuse runner.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RegisterState.cs" />
|
||||
<Compile Include="TestRunner.cs" />
|
||||
<Compile Include="TestSuite.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Fuse
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var suite = new TestSuite("fuse-tests\\tests");
|
||||
var suite = new TestSuite<RegisterState>("fuse-tests\\tests");
|
||||
suite.Read();
|
||||
suite.Parse();
|
||||
suite.Run();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// <copyright file="RegisterState.cs" company="Adrian Conlon">
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
namespace Fuse
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
public class RegisterState : AbstractRegisterState, IRegisterState
|
||||
{
|
||||
protected override void ParseInternalState(string[] tokens)
|
||||
{
|
||||
this.Halted = Convert.ToInt32(tokens[0], CultureInfo.InvariantCulture) == 1;
|
||||
this.TStates = Convert.ToInt32(tokens[1], CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,14 @@ namespace Fuse
|
||||
PC,
|
||||
}
|
||||
|
||||
public class TestRunner : EightBit.GameBoy.Bus
|
||||
public class TestRunner<T> : EightBit.GameBoy.Bus
|
||||
where T : Fuse.IRegisterState, new()
|
||||
{
|
||||
private readonly Test test;
|
||||
private readonly Result result;
|
||||
private readonly Test<T> test;
|
||||
private readonly Result<T> result;
|
||||
private readonly EightBit.Ram ram = new EightBit.Ram(0x10000);
|
||||
|
||||
public TestRunner(Test test, Result result)
|
||||
public TestRunner(Test<T> test, Result<T> result)
|
||||
{
|
||||
this.test = test;
|
||||
this.result = result;
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
// </copyright>
|
||||
namespace Fuse
|
||||
{
|
||||
public class TestSuite
|
||||
public class TestSuite<T>
|
||||
where T : Fuse.IRegisterState, new()
|
||||
{
|
||||
private readonly Tests tests;
|
||||
private readonly Results results;
|
||||
private readonly Tests<T> tests;
|
||||
private readonly Results<T> results;
|
||||
|
||||
public TestSuite(string path)
|
||||
{
|
||||
this.tests = new Tests(path + ".in");
|
||||
this.results = new Results(path + ".expected");
|
||||
this.tests = new Tests<T>(path + ".in");
|
||||
this.results = new Results<T>(path + ".expected");
|
||||
}
|
||||
|
||||
public void Read()
|
||||
@@ -37,7 +38,7 @@ namespace Fuse
|
||||
|
||||
var input = test.Value;
|
||||
var result = this.results.Container[key];
|
||||
var runner = new TestRunner(input, result);
|
||||
var runner = new TestRunner<T>(input, result);
|
||||
|
||||
runner.Run();
|
||||
if (runner.Failed)
|
||||
|
||||
Reference in New Issue
Block a user