test/test-board.rb in shogi-ruby-0.0.7 vs test/test-board.rb in shogi-ruby-0.0.8

- old
+ new

@@ -5,17 +5,17 @@ def setup @board = Shogi::Board.new end def test_initialize - rows = @board.instance_variable_get(:@position) + rows = @board.instance_variable_get(:@table) assert_equal(9, rows.size) assert_true(rows.all? {|row| row.size == 9 }) end def test_initialize_csa - position = <<-EOT + table = <<-EOT P1 * * * * +HI * * -KE * P2 * * * * * +KA-OU * -KY P3 * * * * * * -FU-FU-FU P4 * * * * +KY * * -GI * P5 * * * * * * * * * @@ -24,12 +24,12 @@ P8 * * * * * * * * * P9 * * * * * * * * * P+00HI00GI00KE P- EOT - @board = Shogi::Board.new(:csa, position) - assert_equal(position, @board.to_csa) + @board = Shogi::Board.new(:csa, table) + assert_equal(table, @board.to_csa) assert_nothing_raised do @board.move("+0031HI") end assert_equal(<<-EOT, @board.to_csa) P1 * * * * +HI * +HI-KE * @@ -45,11 +45,11 @@ P- EOT end def test_to_csa - before_state = @board.instance_variable_get(:@position).dup + before_state = @board.instance_variable_get(:@table).dup assert_equal(<<-EOT, @board.to_csa) P1-KY-KE-GI-KI-OU-KI-GI-KE-KY P2 * -HI * * * * * -KA * P3-FU-FU-FU-FU-FU-FU-FU-FU-FU P4 * * * * * * * * * @@ -59,15 +59,15 @@ P8 * +KA * * * * * +HI * P9+KY+KE+GI+KI+OU+KI+GI+KE+KY P+ P- EOT - assert_equal(before_state, @board.instance_variable_get(:@position)) + assert_equal(before_state, @board.instance_variable_get(:@table)) end def test_show - before_state = @board.instance_variable_get(:@position).dup + before_state = @board.instance_variable_get(:@table).dup s = "" io = StringIO.new(s) $stdout = io @board.default_format = :csa @@ -85,11 +85,11 @@ P8 * +KA * * * * * +HI * P9+KY+KE+GI+KI+OU+KI+GI+KE+KY P+ P- EOT - assert_equal(before_state, @board.instance_variable_get(:@position)) + assert_equal(before_state, @board.instance_variable_get(:@table)) end def test_set_from_csa csa = <<-EOT P1 * * * * +HI * * -KE * @@ -110,43 +110,43 @@ @board.move("+0031HI", :csa) end end def test_to_usi - before_state = @board.instance_variable_get(:@position).dup + before_state = @board.instance_variable_get(:@table).dup assert_equal(<<-EOT, @board.to_usi) lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL EOT - assert_equal(before_state, @board.instance_variable_get(:@position)) + assert_equal(before_state, @board.instance_variable_get(:@table)) end def test_at assert_equal("-KY", @board.at("11")) end def test_move_csa @board.default_format = :csa - assert_raise Shogi::Board::FormatError do + assert_raise Shogi::FormatError do @board.move("+27FU") end - assert_raise Shogi::Board::UndefinedPieceError do + assert_raise Shogi::UndefinedPieceError do @board.move("+2726AA") end - assert_raise Shogi::Board::MoveError do + assert_raise Shogi::MoveError do assert_false(@board.move("+2726HI")) end - assert_raise Shogi::Board::MoveError do + assert_raise Shogi::MoveError do assert_false(@board.move("+2827HI")) end - assert_raise Shogi::Board::MoveError do + assert_raise Shogi::MoveError do assert_false(@board.move("+2625FU")) end - assert_raise Shogi::Board::MovementError do + assert_raise Shogi::MovementError do assert_false(@board.move("+2725FU")) end - assert_raise Shogi::Board::MoveError do + assert_raise Shogi::MoveError do assert_false(@board.move("-4131KI")) end assert_nothing_raised do @board.move("+7776FU") @@ -227,11 +227,11 @@ end def test_move_csa_promote @board.move("+7776FU", :csa) @board.move("-3334FU", :csa) - assert_raise Shogi::Board::MovementError do + assert_raise Shogi::MovementError do assert_false(@board.move("+2726TO", :csa)) end assert_nothing_raised do @board.move("+8822UM", :csa) end @@ -319,11 +319,11 @@ @board.move("+2755FU", :csa) end end def test_move_csa_promote_to_7 - position = <<-EOT + table = <<-EOT P1 * * * * * * * * * P2 * * * * * * * * * P3 * * * * * * * * * P4 * * * * * * * * * P5 * * * * * * * * * @@ -332,18 +332,18 @@ P8 * * * * * * * * * P9 * * * * * * * * * P+ P- EOT - @board = Shogi::Board.new(:csa, position) + @board = Shogi::Board.new(:csa, table) assert_nothing_raised do @board.move("-5657TO", :csa) end end def test_move_csa_promote_from_7 - position = <<-EOT + table = <<-EOT P1 * * * * * * * * * P2 * * * * * * * * * P3 * * * * * * * * * P4 * * * * * * * * * P5 * * * * * * * * * @@ -352,10 +352,10 @@ P8 * * * * * * * * * P9 * * * * * * * * * P+ P- EOT - @board = Shogi::Board.new(:csa, position) + @board = Shogi::Board.new(:csa, table) assert_nothing_raised do @board.move("-5746NG", :csa) end end end