From f8bd7ed527c600a5c022b039966c508d3adb0bc2 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 8 Aug 2018 16:55:54 -0700 Subject: 4494 Hacky test. I'm creating a helper to run tests just for this layer. But I won't be able to do this when I want to selectively run just transforms below some level. --- subx/011run.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/subx/011run.cc b/subx/011run.cc index 5d2aab8a..3a57f055 100644 --- a/subx/011run.cc +++ b/subx/011run.cc @@ -206,6 +206,10 @@ void load(const program& p) { const line& l = seg.lines.at(j); for (int k = 0; k < SIZE(l.words); ++k) { const word& w = l.words.at(k); + if (SIZE(w.data) != 2) { + raise << "token '" << w.data << "' is not a hex byte\n" << end(); + return; + } uint8_t val = hex_byte(w.data); if (trace_contains_errors()) return; write_mem_u8(addr, val); @@ -234,6 +238,23 @@ uint8_t hex_byte(const string& s) { return static_cast(result); } +:(scenarios parse_and_load) +:(scenario load_error) +% Hide_errors = true; +== 0x1 +05 cab ++error: token 'cab' is not a hex byte + +//: helper for tests +:(code) +void parse_and_load(const string& text_bytes) { + program p; + istringstream in(text_bytes); + parse(in, p); + if (trace_contains_errors()) return; // if any stage raises errors, stop immediately + load(p); +} + //:: run :(before "End Initialize Op Names(name)") -- cgit 1.4.1-2-gfad0