mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 08:31:11 +00:00
Refactor to permit newer-chip testing.
This commit is contained in:
parent
83b9fc3318
commit
fd20323c25
@ -15,20 +15,20 @@ using namespace InstructionSet::M68k;
|
|||||||
@interface M68000DecoderTests : XCTestCase
|
@interface M68000DecoderTests : XCTestCase
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation M68000DecoderTests
|
namespace {
|
||||||
|
|
||||||
- (void)testInstructionSpecs {
|
template <Model model> void test(NSString *filename, Class cls) {
|
||||||
NSData *const testData =
|
NSData *const testData =
|
||||||
[NSData dataWithContentsOfURL:
|
[NSData dataWithContentsOfURL:
|
||||||
[[NSBundle bundleForClass:[self class]]
|
[[NSBundle bundleForClass:cls]
|
||||||
URLForResource:@"68000ops"
|
URLForResource:filename
|
||||||
withExtension:@"json"
|
withExtension:@"json"
|
||||||
subdirectory:@"68000 Decoding"]];
|
subdirectory:@"68000 Decoding"]];
|
||||||
|
|
||||||
NSDictionary<NSString *, NSString *> *const decodings = [NSJSONSerialization JSONObjectWithData:testData options:0 error:nil];
|
NSDictionary<NSString *, NSString *> *const decodings = [NSJSONSerialization JSONObjectWithData:testData options:0 error:nil];
|
||||||
XCTAssertNotNil(decodings);
|
XCTAssertNotNil(decodings);
|
||||||
|
|
||||||
Predecoder<Model::M68000> decoder;
|
Predecoder<model> decoder;
|
||||||
for(int instr = 0; instr < 65536; instr++) {
|
for(int instr = 0; instr < 65536; instr++) {
|
||||||
NSString *const instrName = [NSString stringWithFormat:@"%04x", instr];
|
NSString *const instrName = [NSString stringWithFormat:@"%04x", instr];
|
||||||
NSString *const expected = decodings[instrName];
|
NSString *const expected = decodings[instrName];
|
||||||
@ -41,4 +41,26 @@ using namespace InstructionSet::M68k;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@implementation M68000DecoderTests
|
||||||
|
|
||||||
|
- (void)test68000 {
|
||||||
|
test<Model::M68000>(@"68000ops", [self class]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO: generate new reference JSONs for tests below here.
|
||||||
|
For now these are here for manual verification of the diffs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (void)test68010 {
|
||||||
|
test<Model::M68010>(@"68000ops", [self class]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)test68020 {
|
||||||
|
test<Model::M68020>(@"68000ops", [self class]);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user