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

map org.mozilla.javascript.Undefined to ruby nil

This commit is contained in:
Charles Lowell 2009-10-09 18:36:42 -05:00
parent 9276bb69a6
commit f7d0f719b5
2 changed files with 10 additions and 4 deletions

View file

@ -1,9 +1,11 @@
module Rhino
module To
JS_UNDEF = [J::Scriptable::NOT_FOUND, J::Undefined]
def ruby(object)
case object
when J::Scriptable::NOT_FOUND then nil
when *JS_UNDEF then nil
when J::Wrapper then object.unwrap
when J::Scriptable then NativeObject.new(object)
else object

View file

@ -33,6 +33,10 @@ describe Rhino::To do
end
end
end
it "converts javascript undefined into nil" do
To.ruby(J::Undefined.instance).should be_nil
end
end
describe "javascript translation" do