shape-vm 0.3.1

Stack-based bytecode virtual machine for the Shape programming language
Documentation
//! Integration tests for std::io module.
//!
//! Tests exercise file I/O, path utilities, and process execution
//! through the native module function API.

use shape_runtime::stdlib_io::create_io_module;
use shape_runtime::stdlib_io::file_ops;
use shape_runtime::stdlib_io::path_ops;
use std::sync::Arc;

/// Create a dummy `ModuleContext` for test-only direct function calls.
fn test_ctx() -> shape_runtime::module_exports::ModuleContext<'static> {
    static REGISTRY: std::sync::LazyLock<shape_runtime::type_schema::TypeSchemaRegistry> =
        std::sync::LazyLock::new(shape_runtime::type_schema::TypeSchemaRegistry::new);
    shape_runtime::module_exports::ModuleContext {
        schemas: &REGISTRY,
        invoke_callable: None,
        raw_invoker: None,
        function_hashes: None,
        vm_state: None,
        granted_permissions: None,
        scope_constraints: None,
        set_pending_resume: None,
        set_pending_frame_resume: None,
    }
}

/// Create a unique temp file path for test isolation.
fn temp_path(name: &str) -> String {
    let dir = std::env::temp_dir().join("shape_io_tests");
    let _ = std::fs::create_dir_all(&dir);
    dir.join(name).to_string_lossy().to_string()
}

#[test]
fn test_io_module_has_all_exports() {
    let module = create_io_module();
    assert!(module.has_export("open"));
    assert!(module.has_export("read"));
    assert!(module.has_export("write"));
    assert!(module.has_export("close"));
    assert!(module.has_export("exists"));
    assert!(module.has_export("stat"));
    assert!(module.has_export("mkdir"));
    assert!(module.has_export("remove"));
    assert!(module.has_export("rename"));
    assert!(module.has_export("read_dir"));
    assert!(module.has_export("join"));
    assert!(module.has_export("dirname"));
    assert!(module.has_export("basename"));
    assert!(module.has_export("extension"));
}

#[test]
fn test_io_open_write_read_roundtrip() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_exists_and_stat() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_mkdir_and_read_dir() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_path_join() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_path_dirname() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_path_basename() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_path_extension() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_rename_file() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_is_file() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_handle_close_and_reuse_errors() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}

#[test]
fn test_io_exec_captures_output() {
    todo!("phase-2c — see ADR-006 §2.7.4 (host-tier eval/marshal API rebuild)")
}