#include "builder.hpp" #include "exec.hpp" #include namespace bast { struct test_builder { bast::builder::program builder; }; struct test_exec : test_builder { using state_t = bast::exec_state; using eval_t = bast::eval< exec_tag, exec_state, brq::unit_t >; using exec_t = bast::exec< eval_t >; using block_t = bast::builder::block; state_t exec( const block_t &start, const block_t &end ) { brq::unit_t heap; auto p = builder.build(); TRACE( "exec", std::hex, p.code ); exec_t exec( p, heap ); exec.start( start.label() ); while ( exec.queue.next().v != end.label().v && exec.step() ); ASSERT( !exec.queue.empty() ); return exec.queue.todo.top().first; } void check( const block_t &start, const block_t &end, std::initializer_list< word > args ) { state_t result = exec( start, end ); state_t expect( args ); ASSERT_EQ( result, expect ); } }; }