use super::*;
#[test]
fn test_create_state_module_exports() {
let module = create_state_module();
assert_eq!(module.name, "std::core::state");
assert!(module.has_export("hash"));
assert!(module.has_export("fn_hash"));
assert!(module.has_export("schema_hash"));
assert!(module.has_export("serialize"));
assert!(module.has_export("deserialize"));
assert!(module.has_export("diff"));
assert!(module.has_export("patch"));
assert!(module.has_export("capture"));
assert!(module.has_export("capture_all"));
assert!(module.has_export("capture_module"));
assert!(module.has_export("capture_call"));
assert!(module.has_export("resume"));
assert!(module.has_export("resume_frame"));
assert!(module.has_export("caller"));
assert!(module.has_export("args"));
assert!(module.has_export("locals"));
assert!(module.has_export("snapshot"));
}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_hash_deterministic() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_hash_different_values() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_hash_returns_hex_string() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_fn_hash_with_function() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_fn_hash_non_function() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_serialize_deserialize_roundtrip_number() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_serialize_deserialize_roundtrip_string() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_serialize_deserialize_roundtrip_bool() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_serialize_deserialize_roundtrip_array() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_serialize_deserialize_none() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_diff_identical() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_diff_changed() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_patch_root_replacement_legacy_array() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_diff_patch_roundtrip() {}
#[test]
fn test_w17_state_bodies_return_structured_errors() {
use crate::executor::state_builtins::core::{
state_deserialize, state_diff, state_fn_hash, state_hash, state_patch,
state_schema_hash, state_serialize,
};
use crate::executor::state_builtins::introspection::{
state_args_stub, state_caller_stub, state_capture_all_stub, state_capture_call_stub,
state_capture_module_stub, state_capture_stub, state_locals_stub,
state_resume_frame_stub, state_resume_stub,
};
use shape_runtime::module_exports::ModuleContext;
use shape_runtime::type_schema::TypeSchemaRegistry;
let schemas = TypeSchemaRegistry::default();
let ctx = ModuleContext {
schemas: &schemas,
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,
};
let empty_args: &[shape_value::KindedSlot] = &[];
let fixtures: &[(
&str,
fn(
&[shape_value::KindedSlot],
&ModuleContext,
) -> Result<
shape_runtime::typed_module_exports::TypedReturn,
String,
>,
)] = &[
("state.capture", state_capture_stub),
("state.capture_all", state_capture_all_stub),
("state.capture_module", state_capture_module_stub),
("state.capture_call", state_capture_call_stub),
("state.resume", state_resume_stub),
("state.resume_frame", state_resume_frame_stub),
("state.caller", state_caller_stub),
("state.args", state_args_stub),
("state.locals", state_locals_stub),
("state.hash", state_hash),
("state.fn_hash", state_fn_hash),
("state.schema_hash", state_schema_hash),
("state.serialize", state_serialize),
("state.deserialize", state_deserialize),
("state.diff", state_diff),
("state.patch", state_patch),
];
for (name, body) in fixtures {
let result = body(empty_args, &ctx);
let err = result.as_ref().err().unwrap_or_else(|| {
panic!(
"{name}: expected Err(...) surface, got Ok(...) — W17 \
surface-and-stop expects every state.* body to return \
a structured error until Phase-2c rebuild lands"
)
});
assert!(
err.contains("W17-snapshot-resume surface"),
"{name}: error message missing W17 surface marker; got: {err}"
);
assert!(
err.contains("§2.7.4"),
"{name}: error message missing ADR-006 §2.7.4 cite; got: {err}"
);
}
}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_capture_stubs_return_errors() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_args_returns_captured_args() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_locals_returns_name_value_pairs() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_caller_returns_caller_frame() {}
#[test]
#[ignore = "phase-2c — state-snapshot rebuild — see ADR-006 §2.7.4"]
fn test_state_caller_returns_none_when_no_caller() {}