Files
hakorune/tests/development/test_diamond_state_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

51 lines
1.4 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 State Problem Test ===")
# カウンター付きStringBox拡張
box CounterString from StringBox {
init { counter }
birth(content) {
from StringBox.birth(content)
me.counter = 0
print("CounterString.birth: counter = " + me.counter)
}
override toString() {
me.counter = me.counter + 1 # ← 呼び出されるたびにカウントアップ
print("CounterString.toString called: counter = " + me.counter)
return "Counter[" + me.counter + "]: " + from StringBox.toString()
}
}
# Diamond Problem - 状態変更が重複する
box DoubleProblem from CounterString, StringBox {
init { prob_data }
birth(content) {
from CounterString.birth(content)
me.prob_data = "problem"
print("DoubleProblem.birth called")
}
override toString() {
print("DoubleProblem.toString called")
# 同じCounterStringのcounterが2回増える
local a = from CounterString.toString() # counter++
local b = from StringBox.toString() # 別のStringBox
return "Double[" + a + " | " + b + "]"
}
}
# テスト実行
print("\n--- Creating instance ---")
local prob = new DoubleProblem("test")
print("\n--- First toString call ---")
print(prob.toString())
print("\n--- Second toString call ---")
print(prob.toString())
print("\n=== Test completed ===")