1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

enable js->ruby type conversion for floats, booleans. Add testcases for null -> nill and undefined -> nil

This commit is contained in:
Charles Lowell 2009-10-16 08:29:23 -05:00
parent 35a15b39d9
commit f240e35b63
2 changed files with 11 additions and 2 deletions

View file

@ -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) {

View file

@ -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