🎯 Phase 9.75D: Implement clone_box() vs share_box() responsibility separation for stateful Box types
Co-authored-by: moe-charm <217100418+moe-charm@users.noreply.github.com>
This commit is contained in:
31
test_state_sharing_validation.nyash
Normal file
31
test_state_sharing_validation.nyash
Normal file
@ -0,0 +1,31 @@
|
||||
// 🎯 Phase B-C 验证测试 - 确认状态共享修复是否有效
|
||||
static box Main {
|
||||
init { array_test, map_test, buffer_test, socket_test }
|
||||
main() {
|
||||
// ArrayBox测试
|
||||
local arr
|
||||
arr = new ArrayBox()
|
||||
arr.push("hello")
|
||||
me.array_test = arr.length() // 期待: 1
|
||||
|
||||
// MapBox测试
|
||||
local map
|
||||
map = new MapBox()
|
||||
map.set("key1", "value1")
|
||||
me.map_test = map.size() // 期待: 1
|
||||
|
||||
// BufferBox测试
|
||||
local buf
|
||||
buf = new BufferBox()
|
||||
buf.write([72, 101, 108, 108, 111]) // "Hello"
|
||||
me.buffer_test = buf.length() // 期待: 5
|
||||
|
||||
// SocketBox测试
|
||||
local sock
|
||||
sock = new SocketBox()
|
||||
sock.bind("127.0.0.1", 8080)
|
||||
me.socket_test = 1 // 暂时设为1,表示创建成功
|
||||
|
||||
return me.array_test
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user