feat(stdlib): format all value types and expose handle identity members

- Add read-only FunctionRef.module/name and PluginHandle.plugin/export
  members; PluginHandle.id stays private (ADR-0029).
- Extend stdlib/format.mq.md to Formula/Code/FunctionRef/PluginHandle/
  Memory/Resource/Unit, with UTF-8 byte length for Code.
- Fix two-digit ordered-list body indentation so arms 10+ stay inside their
  branch (they were previously top-level statements).
- Extend stdlib demo to Formula/Code/FunctionRef and assert all three
  io.写值/打印 pairs match byte-for-byte.
- Add runtime member observation test, ADR-0029, spec/status/changelog/evidence.

Gate: fmt, clippy -D warnings, 416 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 21:57:04 +08:00
1 parent 1377af1601
commit e119727c5d
14 files changed
+334 -15

No files matched your search

@@ -171,6 +171,21 @@ fn ambiguous_ref_resource_is_an_error() {
assert_eq!(error.code(), "ref.ambiguous");
}
#[test]
fn function_ref_and_resource_members_are_readable() {
let source = "## 目标\n\n*1*\n\n## main\n\n### 公式\n\n$$a = 1$$\n\n### 代码\n\n```text\nx\n```\n\n**f = ref(\"#目标\")**\n\n**g = ref(\"#公式\")**\n\n**c = ref(\"#代码\")**\n\n*[f.module, f.name, g.latex, g.display, c.language, c.source]*\n";
let value = run_named(source, "main", &[]).unwrap();
let Value::List(items) = value else {
panic!("expected list");
};
assert!(matches!(&items[0], Value::Text(module) if module.ends_with("index.mq.md")));
assert_eq!(items[1], Value::text("目标"));
assert_eq!(items[2], Value::text("a = 1"));
assert_eq!(items[3], Value::Bool(true));
assert_eq!(items[4], Value::text("text"));
assert_eq!(items[5], Value::text("x\n"));
}
#[test]
fn memory_region_is_shared_by_handle_identity() {
let source = "## f\n\n**m = memory.new(1, 2)**\n\n**n = m**\n\n**`m[3] = 7`**\n\n*[n[3], m == n, memory.size(n)]*\n";