[macruby-changes] [1364] MacRuby/branches/experimental/spec/frozen/language
source_changes at macosforge.org
source_changes at macosforge.org
Sat Apr 4 18:12:06 PDT 2009
Revision: 1364
http://trac.macosforge.org/projects/ruby/changeset/1364
Author: eloy.de.enige at gmail.com
Date: 2009-04-04 18:12:05 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
Refactored class and eigenclass specs to use the variable helper and include_variable matcher.
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/language/class_spec.rb
MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb
Modified: MacRuby/branches/experimental/spec/frozen/language/class_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/class_spec.rb 2009-04-05 01:11:56 UTC (rev 1363)
+++ MacRuby/branches/experimental/spec/frozen/language/class_spec.rb 2009-04-05 01:12:05 UTC (rev 1364)
@@ -12,7 +12,7 @@
ClassSpecs::A.class.should == Class
ClassSpecs::A.new.class.should == ClassSpecs::A
end
-
+
it "has no class variables" do
ClassSpecs::A.class_variables.should == []
end
@@ -45,93 +45,66 @@
end
}.should raise_error(TypeError)
end
-
+
it "allows using self as the superclass if self is a class" do
ClassSpecs::I::J.superclass.should == ClassSpecs::I
-
+
lambda {
class ShouldNotWork < self; end
}.should raise_error(TypeError)
end
-
+
# # I do not think this is a valid spec -- rue
# it "has no class-level instance variables" do
# ClassSpecs::A.instance_variables.should == []
# end
it "allows the declaration of class variables in the body" do
- ruby_version_is "" ... "1.9" do
- ClassSpecs::B.class_variables.should == ["@@cvar"]
- end
- ruby_version_is "1.9" do
- ClassSpecs::B.class_variables.should == [:@@cvar]
- end
+ ClassSpecs::B.class_variables.should == variable("@@cvar")
ClassSpecs::B.send(:class_variable_get, :@@cvar).should == :cvar
end
-
+
it "stores instance variables defined in the class body in the class object" do
- ruby_version_is "" ... "1.9" do
- ClassSpecs::B.instance_variables.include?("@ivar").should == true
- end
- ruby_version_is "1.9" do
- ClassSpecs::B.instance_variables.include?(:@ivar).should == true
- end
+ ClassSpecs::B.instance_variables.should include_variable("@ivar")
ClassSpecs::B.instance_variable_get(:@ivar).should == :ivar
end
it "allows the declaration of class variables in a class method" do
ClassSpecs::C.class_variables.should == []
ClassSpecs::C.make_class_variable
- ruby_version_is "" ... "1.9" do
- ClassSpecs::C.class_variables.should == ["@@cvar"]
- end
- ruby_version_is "1.9" do
- ClassSpecs::C.class_variables.should == [:@@cvar]
- end
+ ClassSpecs::C.class_variables.should == variable("@@cvar")
end
it "allows the definition of class-level instance variables in a class method" do
- ruby_version_is "" ... "1.9" do
- ClassSpecs::C.instance_variables.include?("@civ").should == false
- ClassSpecs::C.make_class_instance_variable
- ClassSpecs::C.instance_variables.include?("@civ").should == true
- end
- ruby_version_is "1.9" do
- ClassSpecs::C.instance_variables.include?(:@civ).should == false
- ClassSpecs::C.make_class_instance_variable
- ClassSpecs::C.instance_variables.include?(:@civ).should == true
- end
+ ClassSpecs::C.instance_variables.should_not include_variable("@civ")
+ ClassSpecs::C.make_class_instance_variable
+ ClassSpecs::C.instance_variables.should include_variable("@civ")
end
-
+
it "allows the declaration of class variables in an instance method" do
ClassSpecs::D.class_variables.should == []
ClassSpecs::D.new.make_class_variable
- ruby_version_is "" ... "1.9" do
- ClassSpecs::D.class_variables.should == ["@@cvar"]
- end
- ruby_version_is "1.9" do
- ClassSpecs::D.class_variables.should == [:@@cvar]
- end
+ ClassSpecs::D.class_variables.should == variable("@@cvar")
end
-
+
it "allows the definition of instance methods" do
ClassSpecs::E.new.meth.should == :meth
end
-
+
it "allows the definition of class methods" do
ClassSpecs::E.cmeth.should == :cmeth
end
-
+
it "allows the definition of class methods using class << self" do
ClassSpecs::E.smeth.should == :smeth
end
-
+
it "allows the definition of Constants" do
Object.const_defined?('CONSTANT').should == false
ClassSpecs::E.const_defined?('CONSTANT').should == true
ClassSpecs::E::CONSTANT.should == :constant!
end
-
+
it "returns the value of the last statement in the body" do
class ClassSpecs::Empty; end.should == nil
class ClassSpecs::Twenty; 20; end.should == 20
@@ -142,12 +115,7 @@
describe "An outer class definition" do
it "contains the inner classes" do
- ruby_version_is "" ... "1.9" do
- ClassSpecs::Container.constants.should include('A', 'B')
- end
- ruby_version_is "1.9" do
- ClassSpecs::Container.constants.should include(:A, :B)
- end
+ ClassSpecs::Container.constants.should include_variables('A', 'B')
end
end
@@ -155,7 +123,7 @@
it "allows adding methods" do
ClassSpecs::O.smeth.should == :smeth
end
-
+
it "raises a TypeError when trying to extend numbers" do
lambda {
eval <<-CODE
@@ -175,11 +143,11 @@
c.meth.should == :meth
c.another.should == :another
end
-
+
it "overwrites existing methods" do
ClassSpecs::G.new.override.should == :override
end
-
+
it "raises a TypeError when superclasses mismatch" do
lambda { class ClassSpecs::A < Array; end }.should raise_error(TypeError)
end
@@ -192,7 +160,7 @@
end
end
ClassSpecs::M.m.should == 1
- end
+ end
end
describe "class provides hooks" do
Modified: MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb 2009-04-05 01:11:56 UTC (rev 1363)
+++ MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb 2009-04-05 01:12:05 UTC (rev 1364)
@@ -148,22 +148,13 @@
end.should raise_error(NameError)
end
- ruby_version_is "" ... "1.9" do
- it "appears in the eigenclass constant list" do
- constants = class << @object; constants; end
- constants.should include("CONST")
- end
+ it "appears in the eigenclass constant list" do
+ constants = class << @object; constants; end
+ constants.should include_variable('CONST')
end
- ruby_version_is "1.9" do
- it "appears in the eigenclass constant list" do
- constants = class << @object; constants; end
- constants.should include(:CONST)
- end
- end
-
it "does not appear in the object's class constant list" do
- @object.class.constants.should_not include(:CONST)
+ @object.class.constants.should_not include_variable('CONST')
end
it "is not preserved when the object is duped" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/d01aa265/attachment.html>
More information about the macruby-changes
mailing list