1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-18 01:07:58 +00:00

Adds separate entry points for zexall and zexdoc.

This commit is contained in:
Thomas Harte 2020-02-22 12:34:47 -05:00
parent 851cba0b25
commit 825b68e5c4

View File

@ -14,8 +14,8 @@ class ZexallTests: XCTestCase, CSTestMachineTrapHandler {
fileprivate var done = false fileprivate var done = false
fileprivate var output = "" fileprivate var output = ""
func testZexall() { private func runTest(_ name: String) {
if let filename = Bundle(for: type(of: self)).path(forResource: "zexdoc", ofType: "com") { if let filename = Bundle(for: type(of: self)).path(forResource: name, ofType: "com") {
if let testData = try? Data(contentsOf: URL(fileURLWithPath: filename)) { if let testData = try? Data(contentsOf: URL(fileURLWithPath: filename)) {
// install test program, at the usual CP/M place // install test program, at the usual CP/M place
@ -47,10 +47,11 @@ class ZexallTests: XCTestCase, CSTestMachineTrapHandler {
var cyclesToDate: TimeInterval = 0 var cyclesToDate: TimeInterval = 0
let startDate = Date() let startDate = Date()
var printDate = Date() var printDate = Date()
let printMhz = false
while !done { while !done {
machine.runForNumber(ofCycles: cyclesPerIteration) machine.runForNumber(ofCycles: cyclesPerIteration)
cyclesToDate += TimeInterval(cyclesPerIteration) cyclesToDate += TimeInterval(cyclesPerIteration)
if printDate.timeIntervalSinceNow < -5.0 { if printMhz && printDate.timeIntervalSinceNow < -5.0 {
print("\(cyclesToDate / -startDate.timeIntervalSinceNow) Mhz") print("\(cyclesToDate / -startDate.timeIntervalSinceNow) Mhz")
printDate = Date() printDate = Date()
} }
@ -131,6 +132,14 @@ class ZexallTests: XCTestCase, CSTestMachineTrapHandler {
} }
} }
func testZexAll() {
runTest("zexall")
}
func testZexDoc() {
runTest("zexdoc")
}
func testMachine(_ testMachine: CSTestMachine, didTrapAtAddress address: UInt16) { func testMachine(_ testMachine: CSTestMachine, didTrapAtAddress address: UInt16) {
let testMachineZ80 = testMachine as! CSTestMachineZ80 let testMachineZ80 = testMachine as! CSTestMachineZ80
switch address { switch address {