Revision
2776
Author
lsansonetti@apple.com
Date
2009-10-09 17:23:24 -0700 (Fri, 09 Oct 2009)

Log Message

added KVO specs (patch by Matthias Neeracher)

Modified Paths

Added Paths

Diff

Added: MacRuby/trunk/spec/macruby/core/kvo_spec.rb (0 => 2776)


--- MacRuby/trunk/spec/macruby/core/kvo_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/macruby/core/kvo_spec.rb	2009-10-10 00:23:24 UTC (rev 2776)
@@ -0,0 +1,88 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+class Wrapper
+  attr_accessor :whatever
+
+  def initialize(value)
+    super()
+    @wrapped = value
+    @whatever= 'like, whatever'
+  end
+
+  def wrappedValue
+    @wrapped
+  end
+end
+
+class FancyWrapper < NSValue
+  attr_accessor :whatever
+
+  def initialize(value)
+    super()
+    @wrapped = value
+    @whatever= 'like, whatever'
+  end
+
+  def wrappedValue
+    @wrapped
+  end
+end
+
+describe "An Object being observed through NSKeyValueObservation" do
+  it "retains the values for its instance variables" do
+    #
+    # Was <rdar://problem/7210942> 
+    # 
+    w = Wrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    w.wrappedValue.should == 42
+  end
+
+  it "keeps reporting its instance variables through instance_variables" do
+    #
+    # <rdar://problem/7210942> 
+    # 
+    w = Wrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    w.instance_variables.should include(:@wrapped)
+  end
+
+  it "can be inspected" do
+    #
+    # <rdar://problem/7210942> 
+    # 
+    w = Wrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    lambda { w.inspect }.should_not raise_error
+  end
+end
+
+describe "A nontrivially derived Object" do
+  it "retains the values for its instance variables" do
+    w = FancyWrapper.new(42)
+    w.wrappedValue.should == 42
+  end
+end
+
+describe "A nontrivially derived Object being observed through NSKeyValueObservation" do
+  it "retains the values for its instance variables" do
+    #
+    # <rdar://problem/7260995>
+    # 
+    w = FancyWrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    w.wrappedValue.should == 42
+  end
+
+  it "keeps reporting its instance variables through instance_variables" do
+    w = FancyWrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    w.instance_variables.should include(:@wrapped)
+  end
+
+  it "can be inspected" do
+    w = FancyWrapper.new(42)
+    w.addObserver(w, forKeyPath:'whatever', options:0, context:nil)
+    lambda { w.inspect }.should_not raise_error
+  end
+end

Modified: MacRuby/trunk/spec/macruby/core/string_spec.rb (2775 => 2776)


--- MacRuby/trunk/spec/macruby/core/string_spec.rb	2009-10-09 23:39:35 UTC (rev 2775)
+++ MacRuby/trunk/spec/macruby/core/string_spec.rb	2009-10-10 00:23:24 UTC (rev 2776)
@@ -25,7 +25,7 @@
   end
 end
 
-describe "An String object" do
+describe "A String object" do
   it "is an instance of the String/NSMutableString class" do
     ''.class.should == String
     ''.kind_of?(String).should == true
@@ -54,6 +54,11 @@
     a.foo = 42
     a.foo.should == 42
   end
+
+  it "can match() a Regex" do
+    a = 'aaba'
+    a.should match(/a+b./)
+  end
 end
 
 describe "An NSString object" do

Added: MacRuby/trunk/spec/macruby/tags/macruby/core/kvo_tags.txt (0 => 2776)


--- MacRuby/trunk/spec/macruby/tags/macruby/core/kvo_tags.txt	                        (rev 0)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/kvo_tags.txt	2009-10-10 00:23:24 UTC (rev 2776)
@@ -0,0 +1,5 @@
+fails:An Object being observed through NSKeyValueObservation keeps reporting its instance variables through instance_variables
+fails:An Object being observed through NSKeyValueObservation can be inspected
+fails:A nontrivially derived Object being observed through NSKeyValueObservation retains the values for its instance variables
+fails:A nontrivially derived Object being observed through NSKeyValueObservation keeps reporting its instance variables through instance_variables
+fails:A nontrivially derived Object being observed through NSKeyValueObservation can be inspected

Modified: MacRuby/trunk/spec/macruby/tags/macruby/core/string_tags.txt (2775 => 2776)


--- MacRuby/trunk/spec/macruby/tags/macruby/core/string_tags.txt	2009-10-09 23:39:35 UTC (rev 2775)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/string_tags.txt	2009-10-10 00:23:24 UTC (rev 2776)
@@ -1,3 +1,4 @@
 critical:The NSString class can be subclassed and later instantiated
 critical:An NSString object can have a singleton class
-fails:An String object can have a singleton class with an attr_accessor
+fails:A String object can have a singleton class with an attr_accessor
+fails:A String object can match() a Regex