From f83a93cb4140156c7b308d26cef8f917ec0eb3b7 Mon Sep 17 00:00:00 2001 From: Krusty/Benediction Date: Sat, 13 Jul 2024 11:17:07 +0200 Subject: [PATCH] [cpclib-asm] Add some more tests --- cpclib-asm/src/assembler/mod.rs | 3 --- cpclib-asm/src/error.rs | 7 +++++++ cpclib-basm/src/lib.rs | 3 +-- cpclib-basm/tests/asm/good_ld_warning_in_macro.asm | 9 +++++++++ cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 cpclib-basm/tests/asm/good_ld_warning_in_macro.asm create mode 100644 cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm diff --git a/cpclib-asm/src/assembler/mod.rs b/cpclib-asm/src/assembler/mod.rs index 2b8f254c..9c50bfbc 100644 --- a/cpclib-asm/src/assembler/mod.rs +++ b/cpclib-asm/src/assembler/mod.rs @@ -412,7 +412,6 @@ pub struct Env { /// Listing of symbols generator symbols_output: SymbolOutputGenerator, - string_warning_done: bool, warnings: Vec, /// Counter to disable some instruction in rorg stuff @@ -472,7 +471,6 @@ impl Clone for Env { run_options: self.run_options.clone(), output_trigger: self.output_trigger.clone(), symbols_output: self.symbols_output.clone(), - string_warning_done: self.string_warning_done.clone(), warnings: self.warnings.clone(), nested_rorg: self.nested_rorg.clone(), sections: self.sections.clone(), @@ -551,7 +549,6 @@ impl Default for Env { crunched_section_state: None, - string_warning_done: false, warnings: Vec::new(), nested_rorg: 0, diff --git a/cpclib-asm/src/error.rs b/cpclib-asm/src/error.rs index 4f2e3085..ccc31cfe 100644 --- a/cpclib-asm/src/error.rs +++ b/cpclib-asm/src/error.rs @@ -366,6 +366,13 @@ impl AssemblerError { } } + pub fn render(self) -> Self { + match &self { + Self::AlreadyRenderedError(_) => self, + _ => Self::AlreadyRenderedError(self.to_string()) + } + } + pub fn format(&self, f: &mut std::fmt::Formatter<'_>, complete: bool) -> std::fmt::Result { match self { diff --git a/cpclib-basm/src/lib.rs b/cpclib-basm/src/lib.rs index 0138339c..26a48bc9 100644 --- a/cpclib-basm/src/lib.rs +++ b/cpclib-basm/src/lib.rs @@ -183,8 +183,7 @@ pub fn parse<'arg>( let res = crate::parse_z80_with_context_builder(code, builder) .map_err(|e| { - debug_assert!(e.is_already_rendered()); - BasmError::from(e) + BasmError::from(e.render()) }); if options.show_progress { diff --git a/cpclib-basm/tests/asm/good_ld_warning_in_macro.asm b/cpclib-basm/tests/asm/good_ld_warning_in_macro.asm new file mode 100644 index 00000000..b110531c --- /dev/null +++ b/cpclib-basm/tests/asm/good_ld_warning_in_macro.asm @@ -0,0 +1,9 @@ + + macro gen + ld hl, de + endm + + + gen (void) + gen(void) + gen() \ No newline at end of file diff --git a/cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm b/cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm new file mode 100644 index 00000000..0352fc3d --- /dev/null +++ b/cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm @@ -0,0 +1,3 @@ +repeat 20 + ld hl, de +endr \ No newline at end of file