Files
hakorune/local_tests/test_birth_simple.nyash

27 lines
658 B
Plaintext
Raw Normal View History

# 🌟 birth() テスト - 生命をBoxに与える
box Life {
init { name, energy }
birth(lifeName) { # 生命を誕生させる
me.name = lifeName
me.energy = 100
print("🌟 " + lifeName + " が誕生しました!")
}
introduce() {
print("私の名前は " + me.name + " です。エネルギーは " + me.energy + " です。")
return me.name
}
}
print("=== birth() 構文テスト開始 ===")
# birth()コンストラクタでLife作成
local alice = new Life("Alice")
alice.introduce()
local bob = new Life("Bob")
bob.introduce()
print("=== birth() テスト完了 ===")