test: Add comprehensive E2E tests for unified registry system

- Add reserved name guard test to prevent non-builtin factories from hijacking builtin names
- Add Handle TLV encoding/decoding test for FileBox copyFrom method
- Add CounterBox plugin tests for inc/get operations and clone/share behavior
- All unified registry E2E tests passing 

統一レジストリシステムの包括的なE2Eテスト追加
- ビルトイン名保護テスト
- Handle型TLVエンコーディングテスト
- CounterBoxプラグインテスト
- 全テスト成功確認

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-21 16:46:07 +09:00
parent 6551a2935f
commit d6529b477b
10 changed files with 476 additions and 23 deletions

View File

@ -51,10 +51,9 @@ f.close()
match interpreter.execute(ast) {
Ok(result) => {
// close() returns void
// close() returns void (BID-1 tag=9)
let result_str = result.to_string_box().value;
// FileBoxの戻り値は現在 "ok" を返すので、それで確認
assert_eq!(result_str, "ok", "Expected 'ok' result from close()");
assert_eq!(result_str, "void", "Expected 'void' result from close()");
println!("✅ E2E Plugin FileBox Interpreter test passed!");
}
Err(e) => {
@ -122,3 +121,34 @@ f.close()
assert_eq!(result.to_string_box().value, "void");
}
#[test]
fn e2e_interpreter_plugin_filebox_copy_from_handle() {
if !try_init_plugins() { return; }
// Prepare two files and copy contents via plugin Handle argument
let p1 = "./test_out_src.txt";
let p2 = "./test_out_dst.txt";
// Nyash program: open two FileBox, write to src, copy to dst via copyFrom, then read dst
let code = format!(r#"
local a, b, data
a = new FileBox()
b = new FileBox()
a.open("{}", "w")
b.open("{}", "rw")
a.write("HELLO")
b.copyFrom(a)
data = b.read()
data
"#, p1, p2);
let ast = NyashParser::parse_from_string(&code).expect("parse failed");
let mut interpreter = nyash_rust::interpreter::NyashInterpreter::new();
match interpreter.execute(ast) {
Ok(result) => {
assert_eq!(result.to_string_box().value, "HELLO");
}
Err(e) => panic!("Failed to execute copyFrom test: {:?}", e),
}
}