diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.cpp b/M6502/HarteTest_6502/opcode_test_suite_t.cpp index 8c9000c..77944bd 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.cpp +++ b/M6502/HarteTest_6502/opcode_test_suite_t.cpp @@ -4,6 +4,7 @@ opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept : parser_t(path) {} +#ifdef USE_COROUTINES #if __cplusplus >= 202002L EightBit::co_generator_t opcode_test_suite_t::generator() { for (const auto element : *this) @@ -14,4 +15,12 @@ void opcode_test_suite_t::generator(boost::coroutines2::coroutine::push_ for (const auto element : *this) sink(test_t(element)); } +#endif +#else +std::vector opcode_test_suite_t::generate() { + std::vector returned; + for (const auto element : *this) + returned.push_back(test_t(element)); + return returned; +} #endif \ No newline at end of file diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.h b/M6502/HarteTest_6502/opcode_test_suite_t.h index eed3a7a..36c42b1 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.h +++ b/M6502/HarteTest_6502/opcode_test_suite_t.h @@ -2,11 +2,14 @@ #include +#ifdef USE_COROUTINES #if __cplusplus >= 202002L # include #else # include #endif +# include +#endif #include "parser_t.h" #include "test_t.h" @@ -22,9 +25,13 @@ public: [[nodiscard]] auto begin() const noexcept { return array().begin(); } [[nodiscard]] auto end() const noexcept { return array().end(); } +#ifdef USE_COROUTINES #if __cplusplus >= 202002L [[nodiscard]] EightBit::co_generator_t generator(); #else void generator(boost::coroutines2::coroutine::push_type& sink); #endif +#else + std::vector generate(); +#endif }; diff --git a/M6502/HarteTest_6502/processor_test_suite_t.cpp b/M6502/HarteTest_6502/processor_test_suite_t.cpp index 29f6918..bc38c7c 100644 --- a/M6502/HarteTest_6502/processor_test_suite_t.cpp +++ b/M6502/HarteTest_6502/processor_test_suite_t.cpp @@ -7,6 +7,7 @@ processor_test_suite_t::processor_test_suite_t(std::string location) noexcept : m_location(location) { } +#ifdef USE_COROUTINES #if __cplusplus >= 202002L EightBit::co_generator_t processor_test_suite_t::generator() { std::filesystem::path directory = location(); @@ -20,3 +21,12 @@ void processor_test_suite_t::generator(boost::coroutines2::coroutine processor_test_suite_t::generate() { + std::vector returned; + std::filesystem::path directory = location(); + for (const auto& entry : std::filesystem::directory_iterator{ directory }) + returned.push_back(opcode_test_suite_t(entry.path().string())); + return returned; +} +#endif diff --git a/M6502/HarteTest_6502/processor_test_suite_t.h b/M6502/HarteTest_6502/processor_test_suite_t.h index 309388f..3d64cdc 100644 --- a/M6502/HarteTest_6502/processor_test_suite_t.h +++ b/M6502/HarteTest_6502/processor_test_suite_t.h @@ -3,11 +3,15 @@ #include #include +#ifdef USE_COROUTINES #if __cplusplus >= 202002L # include #else # include #endif +#else +# include +#endif #include "opcode_test_suite_t.h" @@ -20,9 +24,13 @@ public: std::string_view location() const noexcept { return m_location; } +#ifdef USE_COROUTINES #if __cplusplus >= 202002L [[nodiscard]] EightBit::co_generator_t generator(); #else void generator(boost::coroutines2::coroutine::push_type& sink); #endif +#else + std::vector generate(); +#endif }; diff --git a/M6502/HarteTest_6502/stdafx.h b/M6502/HarteTest_6502/stdafx.h index a792a1e..98bfa8a 100644 --- a/M6502/HarteTest_6502/stdafx.h +++ b/M6502/HarteTest_6502/stdafx.h @@ -22,11 +22,15 @@ #include #include +#define USE_COROUTINES + +#ifdef USE_COROUTINES #if __cplusplus >= 202002L # include #else # include # include #endif +#endif #include "simdjson/simdjson.h" diff --git a/M6502/HarteTest_6502/tests.cpp b/M6502/HarteTest_6502/tests.cpp index abc3a04..f8c1403 100644 --- a/M6502/HarteTest_6502/tests.cpp +++ b/M6502/HarteTest_6502/tests.cpp @@ -30,6 +30,8 @@ int main() { checker_t checker(runner); checker.initialise(); +#ifdef USE_COROUTINES + #if __cplusplus >= 202002L processor_test_suite_t m6502_tests(directory); @@ -91,6 +93,37 @@ int main() { } } +#endif + +#else + + processor_test_suite_t m6502_tests(directory); + auto opcodes = m6502_tests.generate(); + for (auto& opcode : opcodes) { + + const auto path = std::filesystem::path(opcode.path()); + std::cout << "Processing: " << path.filename() << "\n"; + opcode.load(); + + auto tests = opcode.generate(); + for (auto& test : tests) { + + checker.check(test); + + if (checker.invalid()) { + ++invalid_opcode_count; + if (checker.unimplemented()) + ++unimplemented_opcode_count; + if (checker.undocumented()) + ++undocumented_opcode_count; + std::cout << "** Failed: " << test.name() << "\n"; + for (const auto& message : checker.messages()) + std::cout << "**** " << message << "\n"; + break; + } + } + } + #endif const auto finish_time = std::chrono::steady_clock::now();