ruby_ex 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +693 -0
- data/NEWS +74 -0
- data/SPEC.dyn.yml +6 -6
- data/SPEC.gemspec +14 -0
- data/SPEC.yml +4 -4
- data/lib/abstract.rb +2 -4
- data/lib/abstract_node.rb +1 -2
- data/lib/algorithms/simulated_annealing.rb +50 -29
- data/lib/attributed_class.rb +50 -21
- data/lib/auto_object.rb +102 -0
- data/lib/blank_slate.rb +102 -0
- data/lib/cache.rb +1 -2
- data/lib/choose.rb +165 -163
- data/lib/commands.rb +2 -3
- data/lib/commands/command.rb +47 -20
- data/lib/commands/datas.rb +1 -1
- data/lib/commands/datas/composite.rb +5 -1
- data/lib/commands/datas/data.rb +102 -5
- data/lib/commands/datas/factory.rb +13 -6
- data/lib/commands/datas/temp.rb +3 -5
- data/lib/commands/factory.rb +1 -1
- data/lib/commands/helpers.rb +1 -1
- data/lib/commands/pipe.rb +10 -1
- data/lib/commands/runners.rb +1 -1
- data/lib/commands/runners/exec.rb +1 -1
- data/lib/commands/runners/fork.rb +3 -16
- data/lib/commands/runners/mock.rb +67 -0
- data/lib/commands/runners/runner.rb +5 -3
- data/lib/commands/runners/system.rb +1 -1
- data/lib/commands/seq.rb +2 -1
- data/lib/config_file.rb +10 -2
- data/lib/const_regexp.rb +1 -2
- data/lib/{dlogger.rb → d_logger.rb} +1 -2
- data/lib/daemon.rb +1 -2
- data/lib/diff.rb +1 -2
- data/lib/drb/drb_observable.rb +1 -2
- data/lib/drb/drb_observable_pool.rb +2 -2
- data/lib/drb/drb_service.rb +1 -2
- data/lib/drb/drb_undumped_attributes.rb +1 -2
- data/lib/drb/drb_undumped_indexed_object.rb +1 -2
- data/lib/drb/insecure_protected_methods.rb +1 -2
- data/lib/drb_ex.rb +2 -2
- data/lib/file_type.rb +466 -0
- data/lib/generate_id.rb +12 -6
- data/lib/genpasswd.rb +22 -0
- data/lib/hash_eval.rb +83 -0
- data/lib/histogram.rb +1 -2
- data/lib/hookable.rb +3 -4
- data/lib/hooker.rb +1 -3
- data/lib/html_encode.rb +191 -0
- data/lib/indexed_node.rb +0 -1
- data/lib/io_marshal.rb +4 -2
- data/lib/ioo.rb +3 -2
- data/lib/kill_all.rb +46 -0
- data/lib/labeled_node.rb +0 -1
- data/lib/logger_observer.rb +8 -4
- data/lib/md5sum.rb +3 -3
- data/lib/meta_factory.rb +99 -0
- data/lib/method_call.rb +87 -0
- data/lib/mocks.rb +12 -0
- data/lib/mocks/assertions.rb +50 -0
- data/lib/mocks/method_logger.rb +40 -0
- data/lib/mocks/mock.rb +64 -0
- data/lib/mocks/object.rb +47 -0
- data/lib/mocks/observer.rb +38 -0
- data/lib/module/autoload_tree.rb +30 -29
- data/lib/module/hierarchy.rb +176 -171
- data/lib/module/instance_method_visibility.rb +39 -38
- data/lib/node.rb +0 -1
- data/lib/object_monitor.rb +1 -2
- data/lib/object_monitor_activity.rb +1 -2
- data/lib/observable.rb +1 -2
- data/lib/observable_pool.rb +1 -2
- data/lib/{orderedhash.rb → ordered_hash.rb} +41 -5
- data/lib/pp_hierarchy.rb +7 -2
- data/lib/r_path.rb +307 -0
- data/lib/random_generators.rb +7 -20
- data/lib/random_generators/random_generator.rb +2 -4
- data/lib/random_generators/ruby.rb +4 -2
- data/lib/regex_path.rb +124 -0
- data/lib/ruby_ex.rb +28 -98
- data/lib/safe_eval.rb +1 -2
- data/lib/sendmail.rb +14 -17
- data/lib/service_manager.rb +1 -2
- data/lib/shuffle.rb +6 -2
- data/lib/spring.rb +1 -2
- data/lib/spring_set.rb +1 -2
- data/lib/{symtbl.rb → sym_tbl.rb} +90 -5
- data/lib/sym_tbl_gsub.rb +227 -0
- data/lib/{synflow.rb → syn_flow.rb} +1 -2
- data/lib/text.rb +218 -0
- data/lib/timeout_ex.rb +1 -2
- data/lib/trace.rb +9 -8
- data/lib/uri/druby.rb +1 -2
- data/lib/uri/file.rb +1 -1
- data/lib/uri/ftp_ex.rb +1 -1
- data/lib/uri/http_ex.rb +1 -1
- data/lib/uri/mysql.rb +121 -0
- data/lib/uri/pgsql.rb +19 -38
- data/lib/uri/svn.rb +1 -2
- data/lib/uri_ex.rb +45 -3
- data/lib/verbose_object.rb +181 -38
- data/lib/yaml/chop_header.rb +19 -11
- data/lib/yaml/transform.rb +17 -11
- data/lib/yaml/yregexpath.rb +11 -5
- data/test/algorithms/simulated_annealing_test.rb +2 -2
- data/test/resources/foo.tar.gz +0 -0
- data/test/resources/tar.gz.log +49 -0
- data/test/sanity-suite.yml +5 -7
- data/test/sanity/multiple-requires.yml +17 -7
- data/test/sanity/single-requires.yml +38 -20
- data/test/stress-tests/threads_and_exceptions.yml +13 -0
- data/test/test-unit-setup.rb +3 -1
- data/test/unit-suite.yml +7 -8
- metadata +42 -31
- data/lib/algorithms.rb +0 -12
- data/lib/ask.rb +0 -100
- data/lib/checkout.rb +0 -12
- data/lib/dumpable_proc.rb +0 -57
- data/lib/filetype.rb +0 -229
- data/lib/thread_mutex.rb +0 -11
- data/lib/yaml/basenode_ext.rb +0 -63
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: observer.rb 339 2005-09-06 23:27:27Z ertai $
|
5
|
+
|
6
|
+
require 'mocks'
|
7
|
+
|
8
|
+
module Mocks
|
9
|
+
|
10
|
+
class Observer < Mock
|
11
|
+
concrete
|
12
|
+
|
13
|
+
def update ( *args, &block )
|
14
|
+
mock_add MethodCall.new(:update, *args, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
end # class Observer
|
18
|
+
|
19
|
+
test_section __FILE__ do
|
20
|
+
|
21
|
+
class TestObserver < ::Test::Unit::TestCase
|
22
|
+
|
23
|
+
def setup
|
24
|
+
@proc = proc { 43 }
|
25
|
+
@obj = Mocks::Observer.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_simple
|
29
|
+
@obj.update(:foo, :bar, 42, &@proc)
|
30
|
+
@obj.update(:bar)
|
31
|
+
assert_equal([[:foo, :bar, 42], [:bar]], @obj.mock_args)
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class TestObserver
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end # module Mocks
|
data/lib/module/autoload_tree.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
# Copyright
|
2
|
-
# Author
|
3
|
-
# License
|
1
|
+
# Copyright:: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
|
+
# Author:: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: autoload_tree.rb 339 2005-09-06 23:27:27Z ertai $
|
4
5
|
|
5
|
-
# $LastChangedBy: ertai $
|
6
|
-
# $Id: autoload_tree.rb 279 2005-06-05 17:46:53Z ertai $
|
7
6
|
|
8
|
-
|
9
|
-
require 'ruby_ex'
|
10
|
-
|
11
|
-
|
12
|
-
class Module
|
7
|
+
module AutoloadTree
|
13
8
|
|
14
9
|
def autoload_tree(dir, recursive=true, &block)
|
15
10
|
pdir = Pathname.new(dir)
|
@@ -33,33 +28,39 @@ class Module
|
|
33
28
|
end
|
34
29
|
end
|
35
30
|
|
36
|
-
end #
|
31
|
+
end # module AutoloadTree
|
32
|
+
|
33
|
+
class Module
|
37
34
|
|
35
|
+
include AutoloadTree
|
38
36
|
|
39
|
-
|
37
|
+
end # class Module
|
40
38
|
|
41
|
-
|
39
|
+
module AutoloadTree
|
42
40
|
|
43
|
-
|
41
|
+
test_section __FILE__ do
|
44
42
|
|
45
|
-
|
43
|
+
class AutoloadTreeTest < Test::Unit::TestCase
|
46
44
|
|
47
|
-
|
48
|
-
# Test
|
49
|
-
#
|
50
|
-
def test_autoload_tree
|
51
|
-
$: << REPO_DIR
|
52
|
-
AutoloadTree.autoload_tree(REPO_DIR) { |p| p.to_s.sub!(/\.rb$/, '') }
|
53
|
-
["Foo", "B", "A"].each do |x|
|
54
|
-
assert(AutoloadTree.constants.include?(x), "#{x} is missing")
|
55
|
-
end
|
56
|
-
assert_equal(["C"], AutoloadTree::Foo.constants)
|
57
|
-
$:.delete(REPO_DIR)
|
58
|
-
end
|
45
|
+
REPO_DIR = __FILE__.to_path.dirname.parent.parent + 'test/resources/autoload_tree'
|
59
46
|
|
60
|
-
|
47
|
+
module AutoloadTree; end
|
61
48
|
|
49
|
+
#
|
50
|
+
# Test
|
51
|
+
#
|
52
|
+
def test_autoload_tree
|
53
|
+
$: << REPO_DIR
|
54
|
+
AutoloadTree.autoload_tree(REPO_DIR) { |p| p.to_s.sub!(/\.rb$/, '') }
|
55
|
+
["Foo", "B", "A"].each do |x|
|
56
|
+
assert(AutoloadTree.constants.include?(x), "#{x} is missing")
|
57
|
+
end
|
58
|
+
assert_equal(["C"], AutoloadTree::Foo.constants)
|
59
|
+
$:.delete(REPO_DIR)
|
60
|
+
end
|
62
61
|
|
63
|
-
end
|
62
|
+
end # class AutoloadTreeTest
|
64
63
|
|
64
|
+
end
|
65
65
|
|
66
|
+
end # module AutoloadTree
|
data/lib/module/hierarchy.rb
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
5
|
# $LastChangedBy: polrop $
|
6
|
-
# $Id: hierarchy.rb
|
6
|
+
# $Id: hierarchy.rb 339 2005-09-06 23:27:27Z ertai $
|
7
7
|
|
8
|
-
require 'ruby_ex'
|
9
8
|
|
10
9
|
# Extend the Module class with method to manipulate inheritance relation
|
11
10
|
# between constants of a module.
|
12
|
-
|
11
|
+
module Hierarchy
|
13
12
|
|
14
13
|
# Return the list of all sub classes of base_class (including itself).
|
15
14
|
# If force_autoload is false, not yet loaded constants will be ignored.
|
@@ -37,7 +36,7 @@ class Module
|
|
37
36
|
# See sub_classes for a description of the recursive argument.
|
38
37
|
def remove_class(base_class, recursive=false)
|
39
38
|
subs = sub_classes(base_class, true, recursive)
|
40
|
-
re =
|
39
|
+
re = /^#{name}::/
|
41
40
|
result = []
|
42
41
|
subs.each do |sub|
|
43
42
|
sub_name = sub.to_s.sub!(re, '')
|
@@ -118,9 +117,9 @@ class Module
|
|
118
117
|
private
|
119
118
|
def sub_classes_tree_rec(base_classes, csts)
|
120
119
|
result = {}
|
121
|
-
next_csts =
|
120
|
+
next_csts = Set.new
|
122
121
|
base_classes.each do |b|
|
123
|
-
next_base_classes =
|
122
|
+
next_base_classes = Set.new
|
124
123
|
csts.each do |c|
|
125
124
|
c.superclass == b ? next_base_classes << c : next_csts << c;
|
126
125
|
end
|
@@ -136,199 +135,205 @@ class Module
|
|
136
135
|
end
|
137
136
|
end
|
138
137
|
|
138
|
+
end # module Hierarchy
|
139
|
+
|
140
|
+
class Module
|
141
|
+
|
142
|
+
include Hierarchy
|
143
|
+
|
139
144
|
end # class Module
|
140
145
|
|
146
|
+
module Hierarchy
|
141
147
|
|
142
|
-
test_section __FILE__ do
|
148
|
+
test_section __FILE__ do
|
143
149
|
|
144
|
-
require 'diff'
|
150
|
+
require 'diff'
|
145
151
|
|
146
152
|
|
147
|
-
class HierarchyTest < Test::Unit::TestCase
|
153
|
+
class HierarchyTest < Test::Unit::TestCase
|
148
154
|
|
149
|
-
|
155
|
+
module M
|
150
156
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
157
|
+
class A; end
|
158
|
+
class B < A; end
|
159
|
+
class C; end
|
160
|
+
FOO = 42
|
155
161
|
|
156
|
-
|
162
|
+
end
|
157
163
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
164
|
+
def test_sub_classes
|
165
|
+
sub_classes = M.sub_classes(HierarchyTest::M::A)
|
166
|
+
assert_equal(2, sub_classes.size)
|
167
|
+
[HierarchyTest::M::B, HierarchyTest::M::A].each do |x|
|
168
|
+
assert(sub_classes.include?(x))
|
169
|
+
end
|
170
|
+
assert_equal([HierarchyTest::M::C], M.sub_classes(M::C))
|
171
|
+
end
|
166
172
|
|
167
|
-
|
173
|
+
module Mautoload
|
168
174
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
175
|
+
class A; end
|
176
|
+
class B < A; end
|
177
|
+
autoload(:C, '/foo')
|
178
|
+
FOO = 42
|
173
179
|
|
174
|
-
|
180
|
+
end
|
175
181
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
182
|
+
def test_sub_classes_force_autoload
|
183
|
+
sub_classes = Mautoload.sub_classes(Mautoload::A)
|
184
|
+
assert_equal(2, sub_classes.size)
|
185
|
+
[Mautoload::B, Mautoload::A].each do |x|
|
186
|
+
assert(sub_classes.include?(x))
|
187
|
+
end
|
188
|
+
assert_equal(4, Mautoload.constants.size)
|
189
|
+
assert_not_nil(Mautoload.autoload?(:C))
|
190
|
+
assert_raise(MissingSourceFile, LoadError) { Mautoload.sub_classes(Mautoload::A, true) }
|
191
|
+
assert_equal(3, Mautoload.constants.size)
|
192
|
+
assert_nil(Mautoload.autoload?(:C))
|
193
|
+
end
|
188
194
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
195
|
+
module Mrec
|
196
|
+
class A; end
|
197
|
+
class B < A; end
|
198
|
+
module M
|
199
|
+
class C < A; end
|
200
|
+
class D < B; end
|
201
|
+
class E < D; end
|
202
|
+
class Y; end
|
203
|
+
end
|
204
|
+
class Z; end
|
205
|
+
FOO = 42
|
206
|
+
end
|
201
207
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
208
|
+
def test_sub_classes_recursive
|
209
|
+
sub_classes = Mrec.sub_classes(Mrec::A)
|
210
|
+
assert_equal(2, sub_classes.size)
|
211
|
+
[Mrec::B, Mrec::A].each do |x|
|
212
|
+
assert(sub_classes.include?(x))
|
213
|
+
end
|
214
|
+
sub_classes = Mrec.sub_classes(Mrec::A, false, true)
|
215
|
+
assert_equal(5, sub_classes.size)
|
216
|
+
[Mrec::B, Mrec::A, Mrec::M::C, Mrec::M::D, Mrec::M::E].each do |x|
|
217
|
+
assert(sub_classes.include?(x))
|
218
|
+
end
|
219
|
+
r = Mrec.remove_class(Mrec::A, true)
|
220
|
+
assert_equal(5, r.size)
|
221
|
+
['B', 'A', 'M::E', 'M::C', 'M::D'].each do |x|
|
222
|
+
assert(r.include?(x))
|
223
|
+
end
|
224
|
+
assert_equal(3, Mrec.constants.size)
|
225
|
+
['FOO', 'M', 'Z'].each { |x| assert(Mrec.constants.include?(x)) }
|
226
|
+
assert_equal(1, Mrec::M.constants.size)
|
227
|
+
['Y'].each { |x| assert(Mrec::M.constants.include?(x)) }
|
228
|
+
end
|
223
229
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
230
|
+
module Tree
|
231
|
+
|
232
|
+
class A; end
|
233
|
+
class B < A; end
|
234
|
+
class C < B; end
|
235
|
+
class D < B; end
|
236
|
+
class E < A; end
|
237
|
+
module M
|
238
|
+
class F < A; end
|
239
|
+
class G < F; end
|
240
|
+
class H < D; end
|
241
|
+
class I < H; end
|
242
|
+
class J < E; end
|
243
|
+
class Y; end
|
244
|
+
end
|
245
|
+
class Z; end
|
246
|
+
FOO = 42
|
241
247
|
|
242
|
-
|
248
|
+
end
|
243
249
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
250
|
+
def test_sub_classes_tree_rec
|
251
|
+
r = Tree.sub_classes_tree(HierarchyTest::Tree::A, false, true)
|
252
|
+
ref = {
|
253
|
+
HierarchyTest::Tree::A => {
|
254
|
+
HierarchyTest::Tree::M::F => {
|
255
|
+
HierarchyTest::Tree::M::G => {}
|
256
|
+
},
|
257
|
+
HierarchyTest::Tree::B => {
|
258
|
+
HierarchyTest::Tree::C => {},
|
259
|
+
HierarchyTest::Tree::D => {
|
260
|
+
HierarchyTest::Tree::M::H => {
|
261
|
+
HierarchyTest::Tree::M::I=>{}
|
262
|
+
}
|
263
|
+
}
|
264
|
+
},
|
265
|
+
HierarchyTest::Tree::E=> {
|
266
|
+
HierarchyTest::Tree::M::J=>{}
|
256
267
|
}
|
257
268
|
}
|
258
|
-
},
|
259
|
-
HierarchyTest::Tree::E=> {
|
260
|
-
HierarchyTest::Tree::M::J=>{}
|
261
269
|
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
assert_equal({}, d[:missing])
|
268
|
-
end
|
269
|
-
|
270
|
-
def test_sub_classes_tree
|
271
|
-
r = Tree.sub_classes_tree(HierarchyTest::Tree::A)
|
272
|
-
ref = {
|
273
|
-
HierarchyTest::Tree::A => {
|
274
|
-
HierarchyTest::Tree::B => {
|
275
|
-
HierarchyTest::Tree::D => {},
|
276
|
-
HierarchyTest::Tree::C => {}
|
277
|
-
},
|
278
|
-
HierarchyTest::Tree::E => {}
|
279
|
-
}
|
280
|
-
}
|
281
|
-
d = r.diff(ref)
|
282
|
-
assert_equal({}, d[:different])
|
283
|
-
assert_equal({}, d[:additional])
|
284
|
-
assert_equal({}, d[:missing])
|
285
|
-
end
|
286
|
-
|
287
|
-
module Error
|
288
|
-
module M; end
|
289
|
-
end
|
270
|
+
d = r.diff(ref)
|
271
|
+
assert_equal({}, d[:different])
|
272
|
+
assert_equal({}, d[:additional])
|
273
|
+
assert_equal({}, d[:missing])
|
274
|
+
end
|
290
275
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
276
|
+
def test_sub_classes_tree
|
277
|
+
r = Tree.sub_classes_tree(HierarchyTest::Tree::A)
|
278
|
+
ref = {
|
279
|
+
HierarchyTest::Tree::A => {
|
280
|
+
HierarchyTest::Tree::B => {
|
281
|
+
HierarchyTest::Tree::D => {},
|
282
|
+
HierarchyTest::Tree::C => {}
|
283
|
+
},
|
284
|
+
HierarchyTest::Tree::E => {}
|
285
|
+
}
|
286
|
+
}
|
287
|
+
d = r.diff(ref)
|
288
|
+
assert_equal({}, d[:different])
|
289
|
+
assert_equal({}, d[:additional])
|
290
|
+
assert_equal({}, d[:missing])
|
291
|
+
end
|
302
292
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
class B < A; end
|
307
|
-
class C < B; end
|
308
|
-
class D < B; end
|
309
|
-
class E < D; end
|
310
|
-
class F < A; end
|
311
|
-
class Z; end
|
312
|
-
module M
|
313
|
-
class Y; end
|
314
|
-
end
|
315
|
-
BAR = 51
|
293
|
+
module Error
|
294
|
+
module M; end
|
295
|
+
end
|
316
296
|
|
317
|
-
|
297
|
+
def test_sub_classes_error
|
298
|
+
assert_raise(TypeError) do
|
299
|
+
Error.sub_classes_tree(HierarchyTest::Error::M)
|
300
|
+
end
|
301
|
+
assert_raise(TypeError) do
|
302
|
+
Error.sub_classes(HierarchyTest::Error::M)
|
303
|
+
end
|
304
|
+
assert_raise(TypeError) do
|
305
|
+
Error.remove_class(HierarchyTest::Error::M)
|
306
|
+
end
|
307
|
+
end
|
318
308
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
309
|
+
module RemoveClass
|
310
|
+
|
311
|
+
class A; end
|
312
|
+
class B < A; end
|
313
|
+
class C < B; end
|
314
|
+
class D < B; end
|
315
|
+
class E < D; end
|
316
|
+
class F < A; end
|
317
|
+
class Z; end
|
318
|
+
module M
|
319
|
+
class Y; end
|
320
|
+
end
|
321
|
+
BAR = 51
|
328
322
|
|
329
|
-
end
|
323
|
+
end
|
330
324
|
|
325
|
+
def test_remove_class
|
326
|
+
r = RemoveClass.remove_class(HierarchyTest::RemoveClass::B)
|
327
|
+
assert_equal(4, r.size)
|
328
|
+
['B', 'D', 'E', 'C'].each { |x| assert(r.include?(x)) }
|
329
|
+
assert_equal(5, RemoveClass.constants.size)
|
330
|
+
['A', 'F', 'Z', 'M', 'BAR'].each do |x|
|
331
|
+
assert(RemoveClass.constants.include?(x))
|
332
|
+
end
|
333
|
+
end
|
331
334
|
|
332
|
-
end
|
335
|
+
end # class HierarchyTest
|
333
336
|
|
337
|
+
end
|
334
338
|
|
339
|
+
end # module Hierarchy
|