79 lines
1.8 KiB
Plaintext
79 lines
1.8 KiB
Plaintext
|
|
// 未使用フィールドテスト
|
||
|
|
|
||
|
|
print("=== Unused Field Test ===")
|
||
|
|
|
||
|
|
// Test 1: 未使用フィールドなし
|
||
|
|
box CleanTargetBox {
|
||
|
|
init { name }
|
||
|
|
|
||
|
|
deliver(a, b, c) {
|
||
|
|
print("CleanTargetBox.deliver: " + a + ", " + b + ", " + c)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
box CleanCallerBox {
|
||
|
|
init { target, nodeId }
|
||
|
|
|
||
|
|
setup(targetRef) {
|
||
|
|
me.target = targetRef
|
||
|
|
me.nodeId = "TestValue"
|
||
|
|
print("CleanCallerBox setup completed")
|
||
|
|
}
|
||
|
|
|
||
|
|
test() {
|
||
|
|
print("Clean test: No unused fields...")
|
||
|
|
me.target.deliver("hello", "data", me.nodeId)
|
||
|
|
print("Clean test completed")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Test 2: 未使用フィールドあり(元のハングパターン)
|
||
|
|
box DirtyTargetBox {
|
||
|
|
init { handlers } // 未使用フィールド!
|
||
|
|
|
||
|
|
deliver(a, b, c) {
|
||
|
|
print("DirtyTargetBox.deliver: " + a + ", " + b + ", " + c)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
box DirtyCallerBox {
|
||
|
|
init { target, nodeId, unusedField } // 一部未使用
|
||
|
|
|
||
|
|
setup(targetRef) {
|
||
|
|
me.target = targetRef
|
||
|
|
me.nodeId = "TestValue"
|
||
|
|
// me.unusedField は設定しない
|
||
|
|
print("DirtyCallerBox setup completed")
|
||
|
|
}
|
||
|
|
|
||
|
|
test() {
|
||
|
|
print("Dirty test: With unused fields...")
|
||
|
|
me.target.deliver("hello", "data", me.nodeId)
|
||
|
|
print("Dirty test completed")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// テスト実行
|
||
|
|
print("Testing clean boxes (no unused fields)...")
|
||
|
|
local cleanTarget
|
||
|
|
cleanTarget = new CleanTargetBox()
|
||
|
|
|
||
|
|
local cleanCaller
|
||
|
|
cleanCaller = new CleanCallerBox()
|
||
|
|
cleanCaller.setup(cleanTarget)
|
||
|
|
cleanCaller.test()
|
||
|
|
|
||
|
|
print("Clean boxes worked!")
|
||
|
|
|
||
|
|
print("Testing dirty boxes (with unused fields)...")
|
||
|
|
local dirtyTarget
|
||
|
|
dirtyTarget = new DirtyTargetBox()
|
||
|
|
|
||
|
|
local dirtyCaller
|
||
|
|
dirtyCaller = new DirtyCallerBox()
|
||
|
|
dirtyCaller.setup(dirtyTarget)
|
||
|
|
dirtyCaller.test()
|
||
|
|
|
||
|
|
print("If you see this, unused fields also worked!")
|
||
|
|
|
||
|
|
print("All unused field tests completed!")
|