From: Chad Perrin Date: 2011-06-19T09:30:14+09:00 Subject: test scope issue --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable My tests are broken. I generally suck at writing tests, so please bear with me. require 'test/unit' require '../life.rb' =20 class TestLife < Test::Unit::TestCase def setup @life =3D Life.new end =20 def test_life_exists assert( @life ) end =20 def test_vivify_vivifies @life.vivify(2,-1) assert( @life.world[2][-1] ) end =20 def test_murder_kills @life.murder(2,-1) assert( !@life.world[2][-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 errors out because @life.world[2] 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 works 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 issues with local variables, but I seem to be having different scoping issues as a result. It so far seems to be only when running tests that there is an error. I'm probably doing something stupid, but I have not yet seen it. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --pf9I7BMVVzbSWLtt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk39P38ACgkQ9mn/Pj01uKUcxwCgrutb6hGm2X7AOz3+tFpGphMZ PwsAoNaNqS5ICFZieLZYyA4XJNk9ch99 =CJ3C -----END PGP SIGNATURE----- --pf9I7BMVVzbSWLtt--