Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jul 24, 2024
1 parent caa4705 commit ba92522
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion assembly/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
diagnostics::Report,
regex, source_file,
testing::{Pattern, TestContext},
Assembler, Library, LibraryNamespace, LibraryPath, MaslLibrary, Version,
Assembler, Library, LibraryNamespace, LibraryPath, MaslLibrary, ModuleParser, Version,
};

type TestResult = Result<(), Report>;
Expand Down Expand Up @@ -2363,6 +2363,53 @@ fn invalid_while() -> TestResult {
Ok(())
}

#[test]
fn test_compiled_library() {
let mut mod_parser = ModuleParser::new(ModuleKind::Library);
let mod1 = {
let source = source_file!(
"
proc.internal
push.5
end
export.foo
push.1
drop
end
export.bar
exec.internal
drop
end
"
);
mod_parser.parse(LibraryPath::new("mylib::mod1").unwrap(), source).unwrap()
};

let mod2 = {
let source = source_file!(
"
export.foo
push.7
add.5
end
# Same definition as mod1::foo
export.bar
push.1
drop
end
"
);
mod_parser.parse(LibraryPath::new("mylib::mod2").unwrap(), source).unwrap()
};

let compiled_library = {
let assembler = Assembler::new();
assembler.assemble_library(vec![mod1, mod2].into_iter()).unwrap()
};

assert_eq!(compiled_library.exports().len(), 4);
}

// DUMMY LIBRARY
// ================================================================================================

Expand Down

0 comments on commit ba92522

Please sign in to comment.