[macruby-changes] [2742] MacRuby/trunk/spec/macruby

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 6 16:56:01 PDT 2009


Revision: 2742
          http://trac.macosforge.org/projects/ruby/changeset/2742
Author:   lsansonetti at apple.com
Date:     2009-10-06 16:56:01 -0700 (Tue, 06 Oct 2009)
Log Message:
-----------
added a spec to test sel_of_type

Modified Paths:
--------------
    MacRuby/trunk/spec/macruby/fixtures/method.bridgesupport
    MacRuby/trunk/spec/macruby/fixtures/method.m
    MacRuby/trunk/spec/macruby/language/objc_method_spec.rb

Modified: MacRuby/trunk/spec/macruby/fixtures/method.bridgesupport
===================================================================
--- MacRuby/trunk/spec/macruby/fixtures/method.bridgesupport	2009-10-06 23:55:43 UTC (rev 2741)
+++ MacRuby/trunk/spec/macruby/fixtures/method.bridgesupport	2009-10-06 23:56:01 UTC (rev 2742)
@@ -20,6 +20,9 @@
     <method selector='methodAcceptingFalseBOOL:'>
       <arg index='0' type='B'/>
     </method>
+    <method selector='methodAcceptingSEL:target:'>
+      <arg index='0' sel_of_type='v@:iBf'/>
+    </method>
   </class>
   <informal_protocol name='Foo'>
     <method type="i@:i" selector="informalProtocolMethod1:"/>

Modified: MacRuby/trunk/spec/macruby/fixtures/method.m
===================================================================
--- MacRuby/trunk/spec/macruby/fixtures/method.m	2009-10-06 23:55:43 UTC (rev 2741)
+++ MacRuby/trunk/spec/macruby/fixtures/method.m	2009-10-06 23:56:01 UTC (rev 2742)
@@ -694,6 +694,14 @@
     return ptr == NULL;
 }
 
+extern id objc_msgSend(id self, SEL op, ...);
+
+- (void)methodAcceptingSEL:(SEL)sel target:(id)target
+{
+    void (*func)(id, SEL, int, BOOL, float) = (void (*)(id, SEL, int, BOOL, float))objc_msgSend;
+    (*func)(target, sel, 42, true, 42.0);
+}
+
 + (BOOL)testInformalProtocolMethod1:(id)o
 {
     return [o informalProtocolMethod1:41] == 42;

Modified: MacRuby/trunk/spec/macruby/language/objc_method_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/language/objc_method_spec.rb	2009-10-06 23:55:43 UTC (rev 2741)
+++ MacRuby/trunk/spec/macruby/language/objc_method_spec.rb	2009-10-06 23:56:01 UTC (rev 2742)
@@ -398,6 +398,16 @@
 
     lambda { @o.methodAcceptingNSRectPtr2(Pointer.new(NSPoint.type)) }.should raise_error(TypeError)
   end
+
+  it "accepting a 'SEL' tagged with the 'sel_of_type' attribute will re-type the target method at runtime" do
+    o = Object.new
+    def o.foo(i, arg1: b, arg2: f)
+      i.should == 42
+      b.should == true
+      f.should == 42.0
+    end
+    @o.methodAcceptingSEL('foo:arg1:arg2:', target:o)
+  end
 end
 
 describe "A pure MacRuby method" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091006/a9d5612d/attachment-0001.html>


More information about the macruby-changes mailing list