It (and usiToCsa.rb) did not work with Ruby 1.9.3. This issue has now been fixed.
Thanks to Hiraoka-san for debugging.
+2014-12-23 Daigo Moriwaki <daigo at debian dot org>
+
+ * [shogi-server]
+ - Addressed Ruby incompatibility on ShogiServer::Usi::alphabetToDan.
+ It (and usiToCsa.rb) did not work with Ruby 1.9.3. This issue
+ has now been fixed.
+ Thanks to Hiraoka-san for debugging.
+
2014-11-24 Daigo Moriwaki <daigo at debian dot org>
* Ruby 2.0:
# i -> 9
def alphabetToDan(s)
if RUBY_VERSION >= "1.9.1"
- return s.bytes[0]-96
+ # String.bytes is incompatible:
+ # - Ruby 1.9.3 String.bytes returns Enumerator
+ # - Ruby 2.1.0 String.bytes returns [Integer]
+ return s.each_byte.next-96
else
return s[0]-96
end
assert_equal(usi_moves, cu.usi_moves)
end
+
+ def test_alphabetToDan
+ assert_equal(1, ShogiServer::Usi::alphabetToDan("axxx"))
+ assert_equal(2, ShogiServer::Usi::alphabetToDan("bxxx"))
+ assert_equal(9, ShogiServer::Usi::alphabetToDan("ixxx"))
+ end
end