I’ve made progress porting the PHP ibm_db2 extension to Ruby. If you pick up the latest code and run it, you should now see
102 tests, 107 assertions, 0 failures, 0 errors
Some of the differences between Ruby and PHP (other than syntax):
- array and hash are separate types in Ruby, they are combined in PHP.
- some PHP functions, like
strtoupperare methods in Ruby.
- more automatic coercion in PHP: for example, string concat converts both arguments to string. String interpolation works fine in Ruby.
falseprints as a null string in PHP, and as
falsecan’t be printf’ed using a
%dformat string in Ruby.
- in PHP error messages go to the output. In Ruby, typically exceptions are thrown.
Interesting things found during testing:
- Ruby’s ALLOC doesn’t zero the storage. This means that something that passes when run individually may fail when run as a part of a suite.
- Ruby does garbage collection instead of reference
counting. This means that connections may not be immediately
closed, which can lead to deadlock. For now, I have defined a
teardownmethod that calls
- And my personal favorite: in Ruby,
exitmeans exit. Not only is the test case exited, but also the test suite, and even the entire rake process.