Open fdodino opened 3 years ago
mixin Energy { var property energy = 100 method reduceEnergy(amount) { energy = energy - amount } } mixin GetsHurt inherits Energy { method receiveDamage(amount) { // self.energy(self.energy() - amount) self.reduceEnergy(amount) } method energy() method energy(newEnergy) } // más definiciones mixin Attacks { var property power = 10 method attack(other) { other.receiveDamage(power) self.energy(self.energy() - 1) } method energy() method energy(newEnergy) } class Warrior { }
me marca como erróneo self.reduceEnergy pero si ejecutamos este test:
self.reduceEnergy
import example.* test "testX" { const warrior1 = object inherits GetsHurt and Attacks and Warrior {} console.println(warrior1.energy()) assert.equals(100, warrior1.energy()) const warrior2 = object inherits GetsHurt and Attacks and Warrior {} assert.equals(100, warrior2.energy()) warrior1.attack(warrior2) assert.equals(90, warrior2.energy()) assert.equals(99, warrior1.energy()) }
funciona perfectamente en runtime.
me marca como erróneo
self.reduceEnergy
pero si ejecutamos este test:funciona perfectamente en runtime.