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.
This commit is contained in:
47
tests/development/test_array_length_main.nyash
Normal file
47
tests/development/test_array_length_main.nyash
Normal file
@ -0,0 +1,47 @@
|
||||
// 🧪 ArrayBox.length() Bug Fix Test
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Testing ArrayBox.length() Bug Fix")
|
||||
|
||||
// Test 1: Empty array length
|
||||
local empty_array = new ArrayBox()
|
||||
local empty_length = empty_array.length()
|
||||
me.console.log("Empty array length: " + empty_length)
|
||||
|
||||
// Test 2: Add elements and check length
|
||||
local test_array = new ArrayBox()
|
||||
me.console.log("Adding elements...")
|
||||
|
||||
test_array.push("line1")
|
||||
local length1 = test_array.length()
|
||||
me.console.log("After adding 1 element: " + length1)
|
||||
|
||||
test_array.push("line2")
|
||||
local length2 = test_array.length()
|
||||
me.console.log("After adding 2 elements: " + length2)
|
||||
|
||||
test_array.push("line3")
|
||||
local length3 = test_array.length()
|
||||
me.console.log("After adding 3 elements: " + length3)
|
||||
|
||||
// Test 3: Pop and check length consistency
|
||||
local popped = test_array.pop()
|
||||
local length_after_pop = test_array.length()
|
||||
me.console.log("After popping (" + popped + "): " + length_after_pop)
|
||||
|
||||
// Evaluation
|
||||
if empty_length == 0 and length1 == 1 and length2 == 2 and length3 == 3 and length_after_pop == 2 {
|
||||
me.console.log("✅ ArrayBox.length() fix SUCCESSFUL!")
|
||||
} else {
|
||||
me.console.log("❌ ArrayBox.length() fix FAILED!")
|
||||
me.console.log("Expected: 0, 1, 2, 3, 2")
|
||||
me.console.log("Got: " + empty_length + ", " + length1 + ", " + length2 + ", " + length3 + ", " + length_after_pop)
|
||||
}
|
||||
|
||||
return "ArrayBox.length() test complete"
|
||||
}
|
||||
}
|
||||
95
tests/development/test_copilot_fixes_main.nyash
Normal file
95
tests/development/test_copilot_fixes_main.nyash
Normal file
@ -0,0 +1,95 @@
|
||||
// 🎯 Copilot修正版の包括的テスト - Mainエントリーポイント付き
|
||||
|
||||
// テストクラス群
|
||||
static box TestRunner {
|
||||
init { console }
|
||||
|
||||
test_modulo_operator() {
|
||||
me.console.log("📐 Testing % operator (ModuloBox fix)...")
|
||||
|
||||
// Chip-8 style operations
|
||||
local result1 = 4096 % 4096
|
||||
me.console.log("4096 % 4096 = " + result1) // Expected: 0
|
||||
|
||||
local result2 = 256 % 16
|
||||
me.console.log("256 % 16 = " + result2) // Expected: 0
|
||||
|
||||
local result3 = 17 % 5
|
||||
me.console.log("17 % 5 = " + result3) // Expected: 2
|
||||
|
||||
local result4 = 10 % 3
|
||||
me.console.log("10 % 3 = " + result4) // Expected: 1
|
||||
|
||||
if result1 == 0 and result2 == 0 and result3 == 2 and result4 == 1 {
|
||||
me.console.log("✅ % operator fix SUCCESSFUL!")
|
||||
} else {
|
||||
me.console.log("❌ % operator fix FAILED!")
|
||||
}
|
||||
}
|
||||
|
||||
test_null_literals() {
|
||||
me.console.log("🔧 Testing null literal support...")
|
||||
|
||||
// Test null assignment
|
||||
local null_var = null
|
||||
me.console.log("Null variable: " + null_var)
|
||||
|
||||
// Note: null comparison might not work yet
|
||||
me.console.log("✅ Null literal parsing works")
|
||||
}
|
||||
|
||||
test_array_length() {
|
||||
me.console.log("📊 Testing ArrayBox.length() functionality...")
|
||||
|
||||
local test_array = new ArrayBox()
|
||||
local initial_length = test_array.length()
|
||||
me.console.log("Empty array length: " + initial_length)
|
||||
|
||||
// Add elements
|
||||
test_array.push("line1")
|
||||
test_array.push("line2")
|
||||
test_array.push("line3")
|
||||
|
||||
local populated_length = test_array.length()
|
||||
me.console.log("Array with 3 elements length: " + populated_length)
|
||||
|
||||
if populated_length == 3 {
|
||||
me.console.log("✅ ArrayBox.length() fix SUCCESSFUL!")
|
||||
} else {
|
||||
me.console.log("❌ ArrayBox.length() fix FAILED!")
|
||||
}
|
||||
}
|
||||
|
||||
run_all_tests() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Copilot Fixes - Comprehensive Test Suite")
|
||||
me.console.log("===============================================")
|
||||
|
||||
me.test_modulo_operator()
|
||||
me.console.log("")
|
||||
|
||||
me.test_null_literals()
|
||||
me.console.log("")
|
||||
|
||||
me.test_array_length()
|
||||
me.console.log("")
|
||||
|
||||
me.console.log("🎉 All Copilot fix tests completed!")
|
||||
return "Comprehensive test suite finished"
|
||||
}
|
||||
}
|
||||
|
||||
// 🚀 Mainエントリーポイント - Nyashの標準パターン
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🎯 Starting Copilot Fixes Test")
|
||||
|
||||
local result = TestRunner.run_all_tests()
|
||||
|
||||
me.console.log("🏁 Test result: " + result)
|
||||
return "Main execution complete"
|
||||
}
|
||||
}
|
||||
21
tests/development/test_debug_statics.nyash
Normal file
21
tests/development/test_debug_statics.nyash
Normal file
@ -0,0 +1,21 @@
|
||||
// Debug test for statics namespace
|
||||
|
||||
static box TestHelper {
|
||||
greet() {
|
||||
return "Hello from TestHelper"
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("Starting statics debug test")
|
||||
|
||||
// This will fail but show us the debug output
|
||||
local test = TestHelper
|
||||
|
||||
return "Complete"
|
||||
}
|
||||
}
|
||||
48
tests/development/test_diamond_problem.nyash
Normal file
48
tests/development/test_diamond_problem.nyash
Normal file
@ -0,0 +1,48 @@
|
||||
# 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 ===")
|
||||
51
tests/development/test_diamond_state_problem.nyash
Normal file
51
tests/development/test_diamond_state_problem.nyash
Normal file
@ -0,0 +1,51 @@
|
||||
# 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 ===")
|
||||
33
tests/development/test_mathbox_basic.nyash
Normal file
33
tests/development/test_mathbox_basic.nyash
Normal file
@ -0,0 +1,33 @@
|
||||
// 🧮 MathBox基本機能テスト
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧮 MathBox基本機能テスト")
|
||||
|
||||
// MathBox作成
|
||||
local math = new MathBox()
|
||||
me.console.log("✅ MathBox作成成功")
|
||||
|
||||
// 基本計算テスト
|
||||
local result1 = math.abs(-42)
|
||||
me.console.log("🔢 abs(-42) = " + result1)
|
||||
|
||||
local result2 = math.max(10, 25)
|
||||
me.console.log("🔢 max(10, 25) = " + result2)
|
||||
|
||||
local result3 = math.sqrt(16)
|
||||
me.console.log("🔢 sqrt(16) = " + result3)
|
||||
|
||||
// 三角関数テスト
|
||||
local pi = math.getPi()
|
||||
me.console.log("🔢 π = " + pi)
|
||||
|
||||
local sin_result = math.sin(1.5708) // π/2 ≈ 1.5708
|
||||
me.console.log("🔢 sin(π/2) = " + sin_result)
|
||||
|
||||
return "MathBox基本機能テスト完了"
|
||||
}
|
||||
}
|
||||
37
tests/development/test_modulo_simple_main.nyash
Normal file
37
tests/development/test_modulo_simple_main.nyash
Normal file
@ -0,0 +1,37 @@
|
||||
// 🧪 % Modulo Operator Test - Simple functionality verification
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Testing % Modulo Operator")
|
||||
|
||||
// Test 1: Basic modulo operation
|
||||
local result1 = 10 % 3
|
||||
me.console.log("10 % 3 = " + result1)
|
||||
|
||||
// Test 2: Chip-8 style bit masking
|
||||
local result2 = 4096 % 4096
|
||||
me.console.log("4096 % 4096 = " + result2)
|
||||
|
||||
// Test 3: Another typical case
|
||||
local result3 = 256 % 16
|
||||
me.console.log("256 % 16 = " + result3)
|
||||
|
||||
// Test 4: Common modulo pattern
|
||||
local result4 = 17 % 5
|
||||
me.console.log("17 % 5 = " + result4)
|
||||
|
||||
// Check results
|
||||
if result1 == 1 and result2 == 0 and result3 == 0 and result4 == 2 {
|
||||
me.console.log("✅ % Modulo operator test SUCCESSFUL!")
|
||||
} else {
|
||||
me.console.log("❌ % Modulo operator test FAILED!")
|
||||
me.console.log("Expected: 1, 0, 0, 2")
|
||||
me.console.log("Got: " + result1 + ", " + result2 + ", " + result3 + ", " + result4)
|
||||
}
|
||||
|
||||
return "Modulo test complete"
|
||||
}
|
||||
}
|
||||
57
tests/development/test_normal_delegation.nyash
Normal file
57
tests/development/test_normal_delegation.nyash
Normal file
@ -0,0 +1,57 @@
|
||||
// 🔄 通常のデリゲーション(pack使用しない)
|
||||
|
||||
// 親Box
|
||||
box Animal {
|
||||
init { name, species }
|
||||
|
||||
init(animalName, animalSpecies) {
|
||||
me.name = animalName
|
||||
me.species = animalSpecies
|
||||
print("🐾 Animal init: " + animalName + " (" + animalSpecies + ")")
|
||||
}
|
||||
|
||||
speak() {
|
||||
return me.name + " makes a sound"
|
||||
}
|
||||
}
|
||||
|
||||
// 子Box - 通常のデリゲーション(pack使わない)
|
||||
box Dog from Animal {
|
||||
init { breed }
|
||||
|
||||
init(dogName, dogBreed) {
|
||||
from Animal.init(dogName, "Dog")
|
||||
me.breed = dogBreed
|
||||
print("🐕 Dog init: " + dogName + " (breed: " + dogBreed + ")")
|
||||
}
|
||||
|
||||
override speak() {
|
||||
return me.name + " barks!"
|
||||
}
|
||||
|
||||
getBreed() {
|
||||
return me.breed
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🔄 通常のデリゲーションテスト(pack使用なし)")
|
||||
|
||||
// 通常のデリゲーションでDogインスタンス作成
|
||||
local myDog = new Dog("Rex", "German Shepherd")
|
||||
me.console.log("✅ Dog作成成功")
|
||||
|
||||
// メソッド呼び出し
|
||||
local sound = myDog.speak()
|
||||
me.console.log("🔊 " + sound)
|
||||
|
||||
local breed = myDog.getBreed()
|
||||
me.console.log("🐕 犬種: " + breed)
|
||||
|
||||
return "通常デリゲーションテスト成功"
|
||||
}
|
||||
}
|
||||
32
tests/development/test_null_literal_main.nyash
Normal file
32
tests/development/test_null_literal_main.nyash
Normal file
@ -0,0 +1,32 @@
|
||||
// 🧪 Null Literal Support Test
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Testing Null Literal Support")
|
||||
|
||||
// Test 1: Basic null assignment
|
||||
local null_value = null
|
||||
me.console.log("Null value: " + null_value)
|
||||
|
||||
// Test 2: Non-null assignment
|
||||
local non_null_value = "not null"
|
||||
me.console.log("Non-null value: " + non_null_value)
|
||||
|
||||
// Test 3: Null comparison (if supported)
|
||||
me.console.log("Testing null comparison...")
|
||||
|
||||
// Note: Comparison operators might not be fully working yet
|
||||
// Let's try basic null usage
|
||||
me.console.log("Null variable type: " + null_value.type_name())
|
||||
|
||||
// Test 4: Null in string concatenation
|
||||
local concat_test = "Value is: " + null_value
|
||||
me.console.log("Concatenation with null: " + concat_test)
|
||||
|
||||
me.console.log("✅ Null literal parsing works!")
|
||||
return "Null literal test complete"
|
||||
}
|
||||
}
|
||||
25
tests/development/test_null_simple_main.nyash
Normal file
25
tests/development/test_null_simple_main.nyash
Normal file
@ -0,0 +1,25 @@
|
||||
// 🧪 Null Literal Support Test (Simplified)
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Testing Null Literal Support (Simplified)")
|
||||
|
||||
// Test 1: Basic null assignment and display
|
||||
local null_value = null
|
||||
me.console.log("Null value: " + null_value)
|
||||
|
||||
// Test 2: Null in string concatenation
|
||||
local concat_test = "Result: " + null_value + " (end)"
|
||||
me.console.log("Concatenation test: " + concat_test)
|
||||
|
||||
// Test 3: Non-null vs null
|
||||
local non_null_value = "not null"
|
||||
me.console.log("Non-null value: " + non_null_value)
|
||||
|
||||
me.console.log("✅ Null literal basic functionality works!")
|
||||
return "Null literal test complete"
|
||||
}
|
||||
}
|
||||
34
tests/development/test_pack_other_builtin.nyash
Normal file
34
tests/development/test_pack_other_builtin.nyash
Normal file
@ -0,0 +1,34 @@
|
||||
// 🔍 他のビルトインBoxでpack構文テスト
|
||||
|
||||
// P2PBoxでpack構文テスト
|
||||
box MyP2PBox from P2PBox {
|
||||
init { nodeHistory }
|
||||
|
||||
pack(nodeId, world) {
|
||||
from P2PBox.pack(nodeId, world)
|
||||
me.nodeHistory = new ArrayBox()
|
||||
print("✅ MyP2PBox pack成功")
|
||||
}
|
||||
|
||||
getHistory() {
|
||||
return me.nodeHistory
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🔍 P2PBox pack構文テスト")
|
||||
|
||||
// P2PBox継承でpack使用
|
||||
local p2pNode = new MyP2PBox("node1", "tcp")
|
||||
me.console.log("✅ MyP2PBox作成成功")
|
||||
|
||||
local history = p2pNode.getHistory()
|
||||
me.console.log("📚 履歴作成確認")
|
||||
|
||||
return "P2PBox pack構文テスト完了"
|
||||
}
|
||||
}
|
||||
46
tests/development/test_pack_syntax_simple.nyash
Normal file
46
tests/development/test_pack_syntax_simple.nyash
Normal file
@ -0,0 +1,46 @@
|
||||
// 📦 pack構文テスト - ビルトインBox継承専用機能確認
|
||||
|
||||
// ビルトインBoxを継承してpack構文をテスト
|
||||
box MyMathBox from MathBox {
|
||||
init { history } // 追加フィールド
|
||||
|
||||
pack() {
|
||||
from MathBox.pack() // 親のpackを呼び出し
|
||||
me.history = new ArrayBox() // 履歴追加
|
||||
print("✅ MyMathBox pack完了")
|
||||
}
|
||||
|
||||
override sin(x) {
|
||||
local result = from MathBox.sin(x)
|
||||
me.history.push("sin(" + x + ") = " + result)
|
||||
print("📝 履歴追加: sin(" + x + ") = " + result)
|
||||
return result
|
||||
}
|
||||
|
||||
getHistory() {
|
||||
return me.history
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 pack構文テスト開始")
|
||||
|
||||
// packコンストラクタでインスタンス作成
|
||||
local mathCalc = new MyMathBox()
|
||||
me.console.log("✅ MyMathBox作成成功")
|
||||
|
||||
// sin計算テスト
|
||||
local result = mathCalc.sin(1.5708) // π/2 ≈ 90度
|
||||
me.console.log("🔢 sin(π/2) = " + result)
|
||||
|
||||
// 履歴確認
|
||||
local history = mathCalc.getHistory()
|
||||
me.console.log("📚 履歴サイズ: " + history.length())
|
||||
|
||||
return "pack構文テスト完了"
|
||||
}
|
||||
}
|
||||
57
tests/development/test_pack_user_boxes.nyash
Normal file
57
tests/development/test_pack_user_boxes.nyash
Normal file
@ -0,0 +1,57 @@
|
||||
// 📦 ユーザー定義Box間でpack構文テスト
|
||||
|
||||
// 親Box
|
||||
box Animal {
|
||||
init { name, species }
|
||||
|
||||
pack(animalName, animalSpecies) {
|
||||
me.name = animalName
|
||||
me.species = animalSpecies
|
||||
print("🐾 Animal pack: " + animalName + " (" + animalSpecies + ")")
|
||||
}
|
||||
|
||||
speak() {
|
||||
return me.name + " makes a sound"
|
||||
}
|
||||
}
|
||||
|
||||
// 子Box - pack構文でデリゲーション
|
||||
box Dog from Animal {
|
||||
init { breed }
|
||||
|
||||
pack(dogName, dogBreed) {
|
||||
from Animal.pack(dogName, "Dog")
|
||||
me.breed = dogBreed
|
||||
print("🐕 Dog pack: " + dogName + " (breed: " + dogBreed + ")")
|
||||
}
|
||||
|
||||
override speak() {
|
||||
return me.name + " barks!"
|
||||
}
|
||||
|
||||
getBreed() {
|
||||
return me.breed
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("📦 ユーザー定義Box間 pack構文テスト")
|
||||
|
||||
// pack構文でDogインスタンス作成
|
||||
local myDog = new Dog("Buddy", "Golden Retriever")
|
||||
me.console.log("✅ Dog作成成功")
|
||||
|
||||
// メソッド呼び出し
|
||||
local sound = myDog.speak()
|
||||
me.console.log("🔊 " + sound)
|
||||
|
||||
local breed = myDog.getBreed()
|
||||
me.console.log("🐕 犬種: " + breed)
|
||||
|
||||
return "pack構文テスト成功"
|
||||
}
|
||||
}
|
||||
37
tests/development/test_simple_chain_error.nyash
Normal file
37
tests/development/test_simple_chain_error.nyash
Normal file
@ -0,0 +1,37 @@
|
||||
# 簡単な3段階継承チェーンエラー再現
|
||||
|
||||
# 1段階目: ビルトインBox
|
||||
# StringBox (内蔵)
|
||||
|
||||
# 2段階目: ユーザー定義Box
|
||||
box MiddleBox from StringBox {
|
||||
init { middle_data }
|
||||
|
||||
birth(content) {
|
||||
from StringBox.birth(content)
|
||||
me.middle_data = "middle"
|
||||
}
|
||||
|
||||
override toString() {
|
||||
return "Middle: " + from StringBox.toString()
|
||||
}
|
||||
}
|
||||
|
||||
# 3段階目: ユーザー定義Box (ここでエラー!)
|
||||
box TopBox from MiddleBox {
|
||||
init { top_data }
|
||||
|
||||
birth(content) {
|
||||
from MiddleBox.birth(content)
|
||||
me.top_data = "top"
|
||||
}
|
||||
|
||||
override toString() {
|
||||
# ここでエラー: TopBox は StringBox に直接 from していない
|
||||
return "Top: " + from MiddleBox.toString() # この中で StringBox.toString() が呼ばれる
|
||||
}
|
||||
}
|
||||
|
||||
# エラーが出る実行
|
||||
local top = new TopBox("test")
|
||||
print(top.toString()) # ❌ ここでエラー発生!
|
||||
41
tests/development/test_static_scope_problem.nyash
Normal file
41
tests/development/test_static_scope_problem.nyash
Normal file
@ -0,0 +1,41 @@
|
||||
// 🚨 static box → static box スコープ解決問題テスト
|
||||
|
||||
// 呼び出し先のstatic box
|
||||
static box TestHelper {
|
||||
test_method() {
|
||||
return "TestHelper method called successfully"
|
||||
}
|
||||
|
||||
calculate(x, y) {
|
||||
return x + y
|
||||
}
|
||||
}
|
||||
|
||||
// メインのstatic box(呼び出し元)
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🚨 Testing static box → static box scope resolution")
|
||||
|
||||
// Test 1: 直接的な静的メソッド呼び出し
|
||||
me.console.log("Test 1: Direct static method call")
|
||||
local result1 = TestHelper.test_method()
|
||||
me.console.log("Result: " + result1)
|
||||
|
||||
// Test 2: 引数付きの静的メソッド呼び出し
|
||||
me.console.log("Test 2: Static method with arguments")
|
||||
local result2 = TestHelper.calculate(10, 20)
|
||||
me.console.log("10 + 20 = " + result2)
|
||||
|
||||
// Test 3: 変数に格納してから呼び出し
|
||||
me.console.log("Test 3: Method call with variable storage")
|
||||
local helper = TestHelper
|
||||
local result3 = helper.test_method()
|
||||
me.console.log("Via variable: " + result3)
|
||||
|
||||
me.console.log("🏁 Static scope resolution test complete")
|
||||
return "Main execution finished"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user