From ec7c642f5fe60afc857aa64f1a9b4c2be56f9d70 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 22:37:55 +0100 Subject: removes unused method Class#subclasses --- activesupport/test/core_ext/class_test.rb | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb index bb4eb3c7d5..58b745a8b2 100644 --- a/activesupport/test/core_ext/class_test.rb +++ b/activesupport/test/core_ext/class_test.rb @@ -34,14 +34,4 @@ class ClassTest < Test::Unit::TestCase Class.remove_class(Y::Z::C) assert_raise(NameError) { Y::Z::C.is_a?(Class) } end - - def test_retrieving_subclasses - @parent = eval("class D; end; D") - @sub = eval("class E < D; end; E") - @subofsub = eval("class F < E; end; F") - assert_equal 2, @parent.subclasses.size - assert_equal [@subofsub.to_s], @sub.subclasses - assert_equal [], @subofsub.subclasses - assert_equal [@sub.to_s, @subofsub.to_s].sort, @parent.subclasses.sort - end end -- cgit v1.2.3 From 1b2ac25a2fe12d636f90bce1c510667d7accf407 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 22:42:56 +0100 Subject: removes unused Class#remove_subclasses --- .../test/core_ext/object_and_class_ext_test.rb | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index e6fbdb637b..4305114f22 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -41,27 +41,6 @@ class Foo end class ClassExtTest < Test::Unit::TestCase - def test_methods - assert defined?(ClassB) - assert defined?(ClassC) - assert defined?(ClassD) - - ClassA.remove_subclasses - - assert !defined?(ClassB) - assert !defined?(ClassC) - assert !defined?(ClassD) - end - - def test_subclasses_of - cj = ClassJ - assert_equal [ClassJ], Object.subclasses_of(ClassI) - ClassI.remove_subclasses - assert_equal [], Object.subclasses_of(ClassI) - ensure - Object.const_set :ClassJ, cj - end - def test_subclasses_of_should_find_nested_classes assert Object.subclasses_of(ClassK).include?(Nested::ClassL) end -- cgit v1.2.3 From 245bfafe335ff883f7a096eab95ac22fe2848679 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 22:46:47 +0100 Subject: removes unused Object#subclasses_of --- .../test/core_ext/object_and_class_ext_test.rb | 49 ---------------------- 1 file changed, 49 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 4305114f22..375273d680 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -40,55 +40,6 @@ class Foo include Bar end -class ClassExtTest < Test::Unit::TestCase - def test_subclasses_of_should_find_nested_classes - assert Object.subclasses_of(ClassK).include?(Nested::ClassL) - end - - def test_subclasses_of_should_not_return_removed_classes - # First create the removed class - old_class = Nested.class_eval { remove_const :ClassL } - new_class = Class.new(ClassK) - Nested.const_set :ClassL, new_class - assert_equal "Nested::ClassL", new_class.name # Sanity check - - subclasses = Object.subclasses_of(ClassK) - assert subclasses.include?(new_class) - assert ! subclasses.include?(old_class) - ensure - Nested.const_set :ClassL, old_class unless defined?(Nested::ClassL) - end - - def test_subclasses_of_should_not_trigger_const_missing - const_missing = false - Nested.on_const_missing { const_missing = true } - - subclasses = Object.subclasses_of ClassK - assert !const_missing - assert_equal [ Nested::ClassL ], subclasses - - removed = Nested.class_eval { remove_const :ClassL } # keep it in memory - subclasses = Object.subclasses_of ClassK - assert !const_missing - assert subclasses.empty? - ensure - Nested.const_set :ClassL, removed unless defined?(Nested::ClassL) - end - - def test_subclasses_of_with_multiple_roots - classes = Object.subclasses_of(ClassI, ClassK) - assert_equal %w(ClassJ Nested::ClassL), classes.collect(&:to_s).sort - end - - def test_subclasses_of_doesnt_find_anonymous_classes - assert_equal [], Object.subclasses_of(Foo) - bar = Class.new(Foo) - assert_nothing_raised do - assert_equal [bar], Object.subclasses_of(Foo) - end - end -end - class ObjectTests < Test::Unit::TestCase def test_extended_by foo = Foo.new -- cgit v1.2.3 From 44afd785c8e390f47bc5b80e5d94309b6b56a13c Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 22:51:44 +0100 Subject: removes unused method Class#remove_class --- activesupport/test/core_ext/class_test.rb | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb index 58b745a8b2..a082beb26a 100644 --- a/activesupport/test/core_ext/class_test.rb +++ b/activesupport/test/core_ext/class_test.rb @@ -17,21 +17,4 @@ module Y end class ClassTest < Test::Unit::TestCase - def test_removing_class_in_root_namespace - assert A.is_a?(Class) - Class.remove_class(A) - assert_raise(NameError) { A.is_a?(Class) } - end - - def test_removing_class_in_one_level_namespace - assert X::B.is_a?(Class) - Class.remove_class(X::B) - assert_raise(NameError) { X::B.is_a?(Class) } - end - - def test_removing_class_in_two_level_namespace - assert Y::Z::C.is_a?(Class) - Class.remove_class(Y::Z::C) - assert_raise(NameError) { Y::Z::C.is_a?(Class) } - end end -- cgit v1.2.3 From 7d312e54bad9c39634c137caec07dfc8df471650 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 22:57:27 +0100 Subject: deletes no void files removal.rb and class_test.rb --- activesupport/test/core_ext/class_test.rb | 20 -------------------- .../test/core_ext/object_and_class_ext_test.rb | 1 - 2 files changed, 21 deletions(-) delete mode 100644 activesupport/test/core_ext/class_test.rb (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb deleted file mode 100644 index a082beb26a..0000000000 --- a/activesupport/test/core_ext/class_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'abstract_unit' -require 'active_support/core_ext/class' - -class A -end - -module X - class B - end -end - -module Y - module Z - class C - end - end -end - -class ClassTest < Test::Unit::TestCase -end diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 375273d680..33a321db36 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -1,7 +1,6 @@ require 'abstract_unit' require 'active_support/time' require 'active_support/core_ext/object' -require 'active_support/core_ext/class/removal' class ClassA; end class ClassB < ClassA; end -- cgit v1.2.3 From ccec730d7f2ccf5e44d3ac2b4b05c7c57af1cfb4 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 23:01:51 +0100 Subject: removes unused method Object#extend_with_included_modules_from --- activesupport/test/core_ext/object_and_class_ext_test.rb | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 33a321db36..7046d0e3f4 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -47,21 +47,6 @@ class ObjectTests < Test::Unit::TestCase assert(([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}") end - def test_extend_with_included_modules_from - foo, object = Foo.new, Object.new - assert !object.respond_to?(:bar) - assert !object.respond_to?(:baz) - - object.extend_with_included_modules_from(foo) - assert object.respond_to?(:bar) - assert !object.respond_to?(:baz) - - foo.extend(Baz) - object.extend_with_included_modules_from(foo) - assert object.respond_to?(:bar) - assert object.respond_to?(:baz) - end - class DuckTime def acts_like_time? true -- cgit v1.2.3 From c25ac0deeefe55837ba8fd2b2dc860924a507e63 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 26 Jan 2010 23:03:58 +0100 Subject: removes Object#extended_by --- activesupport/test/core_ext/object_and_class_ext_test.rb | 7 ------- 1 file changed, 7 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb index 7046d0e3f4..0b2a9c418e 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -40,13 +40,6 @@ class Foo end class ObjectTests < Test::Unit::TestCase - def test_extended_by - foo = Foo.new - assert foo.extended_by.include?(Bar) - foo.extend(Baz) - assert(([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}") - end - class DuckTime def acts_like_time? true -- cgit v1.2.3