-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test deserializing Wasm CM name style
LibraryPath
- Loading branch information
Showing
1 changed file
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,7 +557,16 @@ fn validate_component(component: &str) -> Result<(), PathError> { | |
/// Tests | ||
#[cfg(test)] | ||
mod tests { | ||
use vm_core::assert_matches; | ||
use crate::alloc::string::ToString; | ||
use std::sync::Arc; | ||
|
||
use vm_core::{ | ||
assert_matches, | ||
debuginfo::{SourceSpan, Span}, | ||
utils::{Deserializable, Serializable}, | ||
}; | ||
|
||
use crate::{ast::Ident, LibraryNamespace}; | ||
|
||
use super::{super::LibraryNamespaceError, IdentError, LibraryPath, PathError}; | ||
|
||
|
@@ -608,4 +617,18 @@ mod tests { | |
Err(PathError::InvalidNamespace(LibraryNamespaceError::InvalidStart)) | ||
); | ||
} | ||
|
||
#[test] | ||
fn path_serialization_wasm_cm_style_module_name() { | ||
// Tests that Wasm Component Model names are serialized and deserialized correctly | ||
let wasm_cm_style_module_name = "namespace:package/[email protected]"; | ||
let module_id = Ident::new_unchecked(Span::new( | ||
SourceSpan::default(), | ||
Arc::from(wasm_cm_style_module_name.to_string()), | ||
)); | ||
let path = LibraryPath::new_from_components(LibraryNamespace::Anon, [module_id]); | ||
let bytes = path.to_bytes(); | ||
let deserialized = LibraryPath::read_from_bytes(&bytes).unwrap(); | ||
assert_eq!(path, deserialized); | ||
} | ||
} |