diff --git a/ruby_data.h b/ruby_data.h index 8ccdd55..b450b82 100644 --- a/ruby_data.h +++ b/ruby_data.h @@ -45,11 +45,11 @@ class RubyDest { } VALUE pushDouble(double value, const char* name=0) { - return Qnil; + return rb_float_new(value); } VALUE pushBool(bool value, const char* name=0) { - return Qnil; + return value ? Qtrue : Qfalse; } VALUE pushNull(const char* name=0) { diff --git a/spec/therubyracer_spec.rb b/spec/therubyracer_spec.rb index 5ff7c25..74cc196 100644 --- a/spec/therubyracer_spec.rb +++ b/spec/therubyracer_spec.rb @@ -8,6 +8,15 @@ describe "The Ruby Racer" do describe "Type Conversion from Ruby to Javascript" do + it "can pass nil back to ruby" do + eval("null").should be_nil + end + + it "passes back undefined value as nil" do + pending "This currently causes a segmentation fault..." + eval("this.undefined").should be_nil + end + it "can pass strings back to ruby" do eval("'Hello World'").should == "Hello World" end