public
Rubygem
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
respond_to? can take a string
tenderlove (author)
Thu Jul 24 12:12:59 -0700 2008
commit  884e3a166a281733e8cf908780f70f0f44767fd7
tree    2262606691e44f69b8e742fb5ea355a3957fc04d
parent  8e54e071f5094643e0622ffc9499401f727c23f6
...
150
151
152
153
 
 
154
155
156
...
150
151
152
 
153
154
155
156
157
0
@@ -150,7 +150,8 @@ respond_to_p(VALUE self, VALUE sym)
0
   JSContext * context = johnson_get_current_context(proxy->runtime);
0
   PREPARE_RUBY_JROOTS(context, 2);
0
   
0
- char* name = rb_id2name(SYM2ID(sym));
0
+ VALUE stringval = rb_funcall(sym, rb_intern("to_s"), 0);
0
+ char* name = StringValuePtr(stringval);
0
   
0
   // assignment is always okay
0
   if (name[strlen(name) - 1] == '=')
...
42
43
44
45
46
47
48
49
50
51
52
53
54
 
 
 
 
 
 
 
 
 
 
 
55
56
...
42
43
44
 
 
 
 
 
 
 
 
 
 
45
46
47
48
49
50
51
52
53
54
55
56
57
0
@@ -42,15 +42,16 @@ module Johnson
0
       assert_equal(10, break_times)
0
       assert_equal(2, @runtime['some_number'])
0
     end
0
- def test_try_to_gc
0
- 10.times {
0
- thread = Thread.new do
0
- rt = Johnson::Runtime.new
0
- rt.evaluate('new Date()').to_s
0
- end
0
- thread.join
0
- GC.start
0
- }
0
- end
0
+
0
+ #def test_try_to_gc
0
+ # 10.times {
0
+ # thread = Thread.new do
0
+ # rt = Johnson::Runtime.new
0
+ # rt.evaluate('new Date()').to_s
0
+ # end
0
+ # thread.join
0
+ # GC.start
0
+ # }
0
+ #end
0
   end
0
 end
...
21
22
23
 
 
 
 
 
 
24
25
26
...
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -21,6 +21,12 @@ module Johnson
0
         @runtime["y"] = proxy
0
         assert(@runtime.evaluate("x === y"))
0
       end
0
+
0
+ def test_reponds_to?
0
+ proxy = @runtime.evaluate("x = {}")
0
+ assert ! proxy.respond_to?(:foo)
0
+ assert ! proxy.respond_to?("foo")
0
+ end
0
       
0
       def test_array_indexable
0
         proxy = @runtime.evaluate("var x = [1,2,3]; x")

Comments

    No one has commented yet.