Revision
3111
Author
ernest.prabhakar@gmail.com
Date
2009-12-14 11:30:09 -0800 (Mon, 14 Dec 2009)

Log Message

Added block_spec to verify local copy vs. instance refs

Added Paths

Diff

Added: MacRuby/trunk/spec/macruby/core/gcd/block_spec.rb (0 => 3111)


--- MacRuby/trunk/spec/macruby/core/gcd/block_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/macruby/core/gcd/block_spec.rb	2009-12-14 19:30:09 UTC (rev 3111)
@@ -0,0 +1,23 @@
+require File.dirname(__FILE__) + "/../../spec_helper"
+
+if MACOSX_VERSION >= 10.6  
+
+  describe "Dispatch blocks" do
+    before :each do
+      @q = Dispatch::Queue.new('org.macruby.gcd_spec.blocks')
+    end
+
+    it "should create const copies of dynamic (local) variables" do
+      i = 42
+      @q.sync {i = 1}
+      i.should == 42
+    end
+
+    it "should have read-write references to instance (__block) variables" do
+      @i = 42
+      @q.sync {@i = 1}
+      @i.should == 1
+    end
+  end
+
+end