Permalink
Browse files

moving nils and false. raising an exception on unknown types

  • Loading branch information...
1 parent 9ba6f82 commit 2a580255bf248d0157d67012686c43d2d292d3aa @tenderlove committed Sep 27, 2009
Showing with 16 additions and 0 deletions.
  1. +6 −0 ext/phuby/phuby_conversions.c
  2. +10 −0 test/test_nil.rb
@@ -13,6 +13,7 @@ zval * Phuby_value_to_zval(VALUE rt, VALUE value)
break;
case T_TRUE:
+ case T_FALSE:
ZVAL_BOOL(php_value, value == Qtrue ? 1 : 0);
break;
@@ -31,6 +32,11 @@ zval * Phuby_value_to_zval(VALUE rt, VALUE value)
rb_hash_aset(map, INT2NUM((int)php_value), value);
}
break;
+ case T_NIL:
+ ZVAL_NULL(php_value);
+ break;
+ default:
+ rb_raise(rb_eRuntimeError, "Can't convert ruby object: %d", TYPE(value));
}
return php_value;
View
@@ -0,0 +1,10 @@
+require 'helper'
+
+class TestNil < Phuby::TestCase
+ def test_nil_moves
+ Phuby::Runtime.php do |rt|
+ rt['foo'] = nil
+ assert_nil rt['foo']
+ end
+ end
+end

0 comments on commit 2a58025

Please sign in to comment.