Skip to content

Commit

Permalink
[cpclib-asm] Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Jul 13, 2024
1 parent e54c716 commit f83a93c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
3 changes: 0 additions & 3 deletions cpclib-asm/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ pub struct Env {
/// Listing of symbols generator
symbols_output: SymbolOutputGenerator,

string_warning_done: bool,
warnings: Vec<AssemblerWarning>,

/// Counter to disable some instruction in rorg stuff
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -551,7 +549,6 @@ impl Default for Env {

crunched_section_state: None,

string_warning_done: false,
warnings: Vec::new(),
nested_rorg: 0,

Expand Down
7 changes: 7 additions & 0 deletions cpclib-asm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions cpclib-basm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions cpclib-basm/tests/asm/good_ld_warning_in_macro.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

macro gen
ld hl, de
endm

gen (void)
gen(void)
gen()
3 changes: 3 additions & 0 deletions cpclib-basm/tests/asm/good_ld_warning_in_repeat.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
repeat 20
ld hl, de
endr

0 comments on commit f83a93c

Please sign in to comment.