#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
use super::*;
use tempfile::TempDir;
#[tokio::test]
async fn test_collect_assemblyscript_files() {
let temp_dir = TempDir::new().unwrap();
let as_file = temp_dir.path().join("test.as");
let ts_file = temp_dir.path().join("assembly.ts");
let other_file = temp_dir.path().join("test.txt");
tokio::fs::write(&as_file, "function test(): i32 { return 42; }")
.await
.unwrap();
tokio::fs::write(&ts_file, "const value: i32 = 42; @global let ptr: usize;")
.await
.unwrap();
tokio::fs::write(&other_file, "not assemblyscript")
.await
.unwrap();
let files = collect_assemblyscript_files(temp_dir.path()).unwrap();
assert_eq!(files.len(), 2);
}
#[tokio::test]
async fn test_collect_wasm_files() {
let temp_dir = TempDir::new().unwrap();
let wasm_file = temp_dir.path().join("test.wasm");
let wat_file = temp_dir.path().join("test.wat");
let other_file = temp_dir.path().join("test.txt");
tokio::fs::write(&wasm_file, b"\0asm\x01\x00\x00\x00")
.await
.unwrap();
tokio::fs::write(&wat_file, "(module)").await.unwrap();
tokio::fs::write(&other_file, "not wasm").await.unwrap();
let files = collect_wasm_files(temp_dir.path(), true, true).unwrap();
assert_eq!(files.len(), 2);
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}