Files
hakorune/tests/development/test_diamond_problem.nyash
Moe Charm ef7a0de3b0 feat: Prepare for code modularization and cleanup
- Archive old documentation and test files to `docs/archive/` and `local_tests/`.
- Remove various temporary and old files from the project root.
- Add `nekocode-rust` analysis tool and its output files (`nekocode/`, `.nekocode_sessions/`, `analysis.json`).
- Minor updates to `apps/chip8_nyash/chip8_emulator.nyash` and `local_tests` files.

This commit cleans up the repository and sets the stage for further code modularization efforts, particularly in the `src/interpreter` and `src/parser` modules, based on recent analysis.
2025-08-16 01:30:39 +09:00

48 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Diamond Problem菱形継承問題テスト
print("=== Diamond Problem Test ===")
# 中間層
box Middle from StringBox {
init { middle_data }
birth(content) {
from StringBox.birth(content)
me.middle_data = "middle"
print("Middle.birth called")
}
override toString() {
print("Middle.toString called")
return "Middle[" + from StringBox.toString() + "]"
}
}
# 多重委譲(問題のあるパターン)
box Diamond from Middle, StringBox {
init { diamond_data }
birth(content) {
from Middle.birth(content)
# from StringBox.birth(content) # これも必要?
me.diamond_data = "diamond"
print("Diamond.birth called")
}
override toString() {
print("Diamond.toString called")
# どちらも StringBox.toString() を呼ぶ
local a = from Middle.toString() # Middle -> StringBox
local b = from StringBox.toString() # 直接 StringBox
return "Diamond[" + a + " | " + b + "]"
}
}
# テスト実行
print("\n--- Creating diamond instance ---")
local diamond = new Diamond("test")
print("\n--- Calling toString ---")
print(diamond.toString())
print("\n=== Test completed ===")