Created
March 20, 2026 20:41
-
-
Save huitseeker/eec0b7b58d041998f4f17f4006fc5312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git i/crates/mast-package/src/package/mod.rs w/crates/mast-package/src/package/mod.rs | |
| index 8420ddc8e..0deeb3436 100644 | |
| --- i/crates/mast-package/src/package/mod.rs | |
| +++ w/crates/mast-package/src/package/mod.rs | |
| @@ -90,6 +90,110 @@ impl Package { | |
| } | |
| } | |
| +#[cfg(test)] | |
| +mod tests { | |
| + use alloc::{collections::BTreeMap, sync::Arc, vec}; | |
| + use std::panic::{AssertUnwindSafe, catch_unwind}; | |
| + | |
| + use miden_assembly_syntax::{ | |
| + Library, Path as MasmPath, | |
| + ast::{self, PathBuf}, | |
| + library::{LibraryExport, ProcedureExport as LibraryProcedureExport}, | |
| + }; | |
| + use miden_core::mast::{BasicBlockNodeBuilder, MastForest, MastForestContributor}; | |
| + use miden_core::operations::Operation; | |
| + | |
| + use super::*; | |
| + | |
| + #[test] | |
| + fn malformed_executable_package_try_into_program_panics() { | |
| + let mut forest = MastForest::new(); | |
| + let node_id = BasicBlockNodeBuilder::new(vec![Operation::Add], Vec::new()) | |
| + .add_to_forest(&mut forest) | |
| + .expect("failed to build basic block"); | |
| + forest.make_root(node_id); | |
| + let path = Arc::from( | |
| + PathBuf::new("test::proc") | |
| + .expect("invalid path") | |
| + .as_path() | |
| + .to_absolute() | |
| + .into_owned() | |
| + .into_boxed_path(), | |
| + ); | |
| + let export = LibraryProcedureExport::new(node_id, Arc::clone(&path)); | |
| + | |
| + let package = Package { | |
| + name: PackageId::from("broken"), | |
| + version: crate::Version::new(0, 0, 0), | |
| + description: None, | |
| + kind: TargetType::Executable, | |
| + mast: Arc::new( | |
| + Library::new( | |
| + Arc::new(forest), | |
| + BTreeMap::from_iter([(path, LibraryExport::Procedure(export))]), | |
| + ) | |
| + .unwrap(), | |
| + ), | |
| + manifest: PackageManifest::default(), | |
| + sections: Vec::new(), | |
| + }; | |
| + | |
| + let result = catch_unwind(AssertUnwindSafe(|| package.try_into_program())); | |
| + assert!(result.is_err(), "expected malformed executable package to panic"); | |
| + } | |
| + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment