- test_override_validation.nyash: 正常なovveride検証テスト - test_invalid_override.nyash: 無効なoverride検出テスト ✅ 動作確認済み: - 正常なoverride: speak/moveメソッドは問題なく動作 - 無効なoverride: nonExistentMethodで適切にエラー検出 - パース時点での早期エラー検出により安全性向上 🔍 DEBUG: Found override method 'nonExistentMethod' in 'BadDog' extending 'Animal' ❌ Parse error: Unexpected token OVERRIDE, expected 🚨 OVERRIDE ERROR 次のフェーズ: 実際の親Boxメソッド参照システム実装 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1022 B
Plaintext
48 lines
1022 B
Plaintext
// 🔍 override検証テスト - デリゲーションメソッドチェック機能
|
||
|
||
// 1. ✅ 正常なoverride(基本テスト)
|
||
box Animal {
|
||
init { name }
|
||
|
||
pack(animalName) {
|
||
me.name = animalName
|
||
}
|
||
|
||
speak() {
|
||
return me.name + " makes a sound"
|
||
}
|
||
|
||
move() {
|
||
return me.name + " moves"
|
||
}
|
||
}
|
||
|
||
box Dog from Animal {
|
||
init { breed }
|
||
|
||
pack(dogName, dogBreed) {
|
||
from Animal.pack(dogName)
|
||
me.breed = dogBreed
|
||
}
|
||
|
||
// ✅ 正常なoverride - speakメソッドは親に存在
|
||
override speak() {
|
||
return me.name + " (dog) barks: Woof!"
|
||
}
|
||
|
||
// ✅ 正常なoverride - moveメソッドも親に存在
|
||
override move() {
|
||
return me.name + " runs fast"
|
||
}
|
||
}
|
||
|
||
// テスト実行
|
||
print("=== 🔍 Override検証テスト ===")
|
||
|
||
local dog
|
||
dog = new Dog("Buddy", "Labrador")
|
||
print("Dog speak: " + dog.speak())
|
||
print("Dog move: " + dog.move())
|
||
|
||
print("")
|
||
print("✅ 正常なoverrideテスト完了!") |