My tests are broken. I generally suck at writing tests, so please bear
require 'test/unit' require '../life.rb' class TestLife < Test::Unit::TestCase def setup @life = Life.new end def test_life_exists assert( @life ) end def test_vivify_vivifies @life.vivify(2,-1) assert( @life.world[-1] ) end def test_murder_kills @life.murder(2,-1) assert( [email protected][-1] ) end end
I seem to be having a scoping issue here, where the changes made in
test_vivify_vivifies are not applying to @life in the general case; they
go away after test_vivify_vivifies ends, so that test_murder_kills
out because @life.world doesn’t exist at all at that point.
I have verified that when I run the code in life.rb using irb, the
@life.vivify actually gives me what I expect, and @life.murder thus
perfectly well there. Actually, I don’t even use the @ for an instance
variable when doing that; I only included it here to avoid scoping
with local variables, but I seem to be having different scoping issues
a result. It so far seems to be only when running tests that there is
I’m probably doing something stupid, but I have not yet seen it.