utilrb 2.0.2.b2 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.boring +40 -0
  3. data/.gitignore +13 -0
  4. data/.travis.yml +5 -0
  5. data/CMakeLists.txt +18 -0
  6. data/Gemfile +3 -0
  7. data/Makefile +8 -0
  8. data/Manifest.txt +0 -8
  9. data/{README.rd → README.md} +11 -7
  10. data/Rakefile +16 -63
  11. data/benchmarks/validate_options.rb +79 -0
  12. data/ext/utilrb/extconf.rb +1 -17
  13. data/ext/utilrb/utilrb.cc +0 -23
  14. data/lib/utilrb/column_formatter.rb +8 -5
  15. data/lib/utilrb/common.rb +1 -6
  16. data/lib/utilrb/enumerable/uniq.rb +2 -8
  17. data/lib/utilrb/event_loop.rb +5 -10
  18. data/lib/utilrb/kernel/load_dsl_file.rb +1 -2
  19. data/lib/utilrb/kernel/options.rb +25 -29
  20. data/lib/utilrb/logger/hierarchy.rb +0 -1
  21. data/lib/utilrb/logger/io.rb +3 -3
  22. data/lib/utilrb/logger/root.rb +12 -6
  23. data/lib/utilrb/module/ancestor_p.rb +0 -12
  24. data/lib/utilrb/module/is_singleton.rb +6 -0
  25. data/lib/utilrb/module/singleton_class_p.rb +14 -0
  26. data/lib/utilrb/object/attribute.rb +33 -65
  27. data/lib/utilrb/object/singleton_class.rb +1 -20
  28. data/lib/utilrb/pkgconfig.rb +21 -10
  29. data/lib/utilrb/socket/tcp_server.rb +2 -2
  30. data/lib/utilrb/spawn.rb +1 -1
  31. data/lib/utilrb/test.rb +65 -0
  32. data/lib/utilrb/thread_pool.rb +11 -13
  33. data/lib/utilrb/timepoints.rb +15 -0
  34. data/lib/utilrb/value_set.rb +10 -1
  35. data/lib/utilrb/version.rb +4 -0
  36. data/lib/utilrb/weakref.rb +11 -12
  37. data/lib/utilrb/yard.rb +0 -111
  38. data/lib/utilrb.rb +6 -1
  39. data/lib/yard-utilrb.rb +1 -0
  40. data/manifest.xml +19 -0
  41. data/package.xml +29 -0
  42. data/utilrb.gemspec +27 -0
  43. metadata +56 -107
  44. data/ext/utilrb/proc.c +0 -39
  45. data/ext/utilrb/readline.c +0 -52
  46. data/ext/utilrb/weakref.cc +0 -143
  47. data/lib/utilrb/models/inherited_enumerable.rb +0 -341
  48. data/lib/utilrb/models/registration.rb +0 -115
  49. data/lib/utilrb/module/inherited_enumerable.rb +0 -6
  50. data/lib/utilrb/objectstats.rb +0 -193
  51. data/lib/utilrb/ruby_object_graph.rb +0 -384
  52. data/test/data/test_pkgconfig.pc +0 -9
  53. data/test/data/test_pkgconfig_empty.pc +0 -10
  54. data/test/test_array.rb +0 -15
  55. data/test/test_config.rb +0 -4
  56. data/test/test_dir.rb +0 -22
  57. data/test/test_enumerable.rb +0 -119
  58. data/test/test_event_loop.rb +0 -407
  59. data/test/test_exception.rb +0 -38
  60. data/test/test_gc.rb +0 -34
  61. data/test/test_hash.rb +0 -102
  62. data/test/test_kernel.rb +0 -300
  63. data/test/test_logger.rb +0 -204
  64. data/test/test_misc.rb +0 -42
  65. data/test/test_models.rb +0 -212
  66. data/test/test_module.rb +0 -126
  67. data/test/test_object.rb +0 -77
  68. data/test/test_objectstats.rb +0 -26
  69. data/test/test_pkgconfig.rb +0 -84
  70. data/test/test_proc.rb +0 -31
  71. data/test/test_set.rb +0 -19
  72. data/test/test_thread_pool.rb +0 -409
  73. data/test/test_time.rb +0 -47
  74. data/test/test_unbound_method.rb +0 -23
  75. data/test/test_weakref.rb +0 -81
data/test/test_models.rb DELETED
@@ -1,212 +0,0 @@
1
- require './test/test_config'
2
-
3
- require 'flexmock/test_unit'
4
- require 'set'
5
- require 'enumerator'
6
- require 'utilrb/module'
7
-
8
- class TC_Models < Test::Unit::TestCase
9
- def test_inherited_enumerable_module
10
- m = Module.new do
11
- inherited_enumerable(:signature, :signatures) { Array.new }
12
- end
13
- k = Class.new do
14
- include m
15
- inherited_enumerable(:child_attribute) { Array.new }
16
- end
17
-
18
- # Add another attribute *after* k has been defined
19
- m.class_eval do
20
- inherited_enumerable(:mapped, :map, :map => true) { Hash.new }
21
- end
22
- check_inherited_enumerable(m, k)
23
- end
24
-
25
- def test_inherited_enumerable_class
26
- a = Class.new do
27
- inherited_enumerable(:signature, :signatures) { Array.new }
28
- inherited_enumerable(:mapped, :map, :map => true) { Hash.new }
29
- end
30
- b = Class.new(a) do
31
- include Module.new # include an empty module between a and b to check that the module
32
- # is skipped transparently
33
- inherited_enumerable(:child_attribute) { Array.new }
34
- end
35
- check_inherited_enumerable(a, b)
36
-
37
- # Test for singleton class support
38
- object = b.new
39
- assert(object.singleton_class.respond_to?(:signatures))
40
- object.singleton_class.signatures << :in_singleton
41
- assert_equal([:in_singleton], object.singleton_class.signatures)
42
- end
43
-
44
- def check_inherited_enumerable(base, derived)
45
- assert(base.respond_to?(:each_signature))
46
- assert(base.respond_to?(:signatures))
47
- assert(!base.respond_to?(:has_signature?))
48
- assert(!base.respond_to?(:find_signatures))
49
-
50
- assert(base.respond_to?(:each_mapped))
51
- assert(base.respond_to?(:map))
52
- assert(base.respond_to?(:has_mapped?))
53
-
54
- base.signatures << :in_base
55
- base.map[:base] = 10
56
- base.map[:overriden] = 20
57
- assert_equal([:in_base], base.enum_for(:each_signature).to_a)
58
- assert_equal([10].to_set, base.enum_for(:each_mapped, :base, false).to_set)
59
-
60
- assert(!base.respond_to?(:child_attribute))
61
- assert(!base.respond_to?(:each_child_attribute))
62
- assert(derived.respond_to?(:child_attribute))
63
- assert(derived.respond_to?(:each_child_attribute))
64
-
65
- derived.signatures << :in_derived
66
-
67
- derived.map[:overriden] = 15
68
- derived.map[:derived] = 25
69
-
70
- assert_equal([:in_derived, :in_base], derived.enum_for(:each_signature).to_a)
71
- assert_equal([20, 15].to_set, derived.enum_for(:each_mapped, :overriden, false).to_set)
72
- assert_equal([15].to_set, derived.enum_for(:each_mapped, :overriden, true).to_set)
73
- assert_equal([25].to_set, derived.enum_for(:each_mapped, :derived).to_set)
74
- assert_equal([[:base, 10], [:overriden, 20], [:overriden, 15], [:derived, 25]].to_set, derived.enum_for(:each_mapped, nil, false).to_set)
75
- assert_equal([[:base, 10], [:overriden, 15], [:derived, 25]].to_set, derived.enum_for(:each_mapped, nil, true).to_set)
76
- end
77
-
78
- def test_inherited_enumerable_non_mapping_promote
79
- a = Class.new do
80
- def self.promote_value(v)
81
- v
82
- end
83
- inherited_enumerable(:value, :values) { Array.new }
84
- end
85
- b = flexmock(Class.new(a), 'b')
86
- c = flexmock(Class.new(b), 'c')
87
- d = flexmock(Class.new(c), 'd')
88
-
89
- c.should_receive(:promote_value).with(10).and_return("10_b_c").once.ordered
90
- d.should_receive(:promote_value).with("10_b_c").and_return(12).once.ordered
91
- c.should_receive(:promote_value).with(11).and_return("11_b_c").once.ordered
92
- d.should_receive(:promote_value).with("11_b_c").and_return(13).once.ordered
93
- b.should_receive(:promote_value).with(0).and_return("0_b_c").once.ordered
94
- c.should_receive(:promote_value).with("0_b_c").and_return("0_c_d").once.ordered
95
- d.should_receive(:promote_value).with("0_c_d").and_return(2).once.ordered
96
- b.should_receive(:promote_value).with(1).and_return("1_b_c").once.ordered
97
- c.should_receive(:promote_value).with("1_b_c").and_return("1_c_d").once.ordered
98
- d.should_receive(:promote_value).with("1_c_d").and_return(3).once.ordered
99
-
100
- a.values << 0 << 1
101
- b.values << 10 << 11
102
- # Do NOT add anything at the level of C. Its promote_value method should
103
- # still be called, though
104
- d.values << 100 << 110
105
- assert_equal [0, 1], a.each_value.to_a
106
- assert_equal [100, 110, 12, 13, 2, 3], d.each_value.to_a
107
- end
108
-
109
- def test_inherited_enumerable_mapping_promote
110
- a = Class.new do
111
- def self.promote_value(key, v)
112
- end
113
- def self.name; 'A' end
114
- inherited_enumerable(:value, :values, :map => true) { Hash.new }
115
- end
116
- b = Class.new(a)
117
- c = Class.new(b)
118
- d = Class.new(c)
119
-
120
- flexmock(c).should_receive(:promote_value).with('b', 2).and_return("b2_b_c").once.ordered
121
- flexmock(d).should_receive(:promote_value).with('b', "b2_b_c").and_return(15).once.ordered
122
-
123
- flexmock(c).should_receive(:promote_value).with('c', 3).and_return("c3_b_c").once.ordered
124
- flexmock(d).should_receive(:promote_value).with('c', "c3_b_c").and_return(16).once.ordered
125
-
126
- flexmock(b).should_receive(:promote_value).with('a', 0).and_return("a0_a_b").once.ordered
127
- flexmock(c).should_receive(:promote_value).with('a', "a0_a_b").and_return("a0_b_c").once.ordered
128
- flexmock(d).should_receive(:promote_value).with('a', "a0_b_c").and_return(10).once.ordered
129
-
130
- a.values.merge!('a' => 0, 'b' => 1)
131
- b.values.merge!('b' => 2, 'c' => 3, 'd' => 4)
132
- d.values.merge!('d' => 5, 'e' => 6)
133
- assert_equal [['d', 5], ['e', 6], ['b', 15], ['c', 16], ['a', 10]], d.each_value.to_a
134
- end
135
-
136
- def test_inherited_enumerable_mapping_promote_non_uniq
137
- a = Class.new do
138
- def self.promote_value(key, v)
139
- end
140
- inherited_enumerable(:value, :values, :map => true) { Hash.new }
141
- end
142
- b = flexmock(Class.new(a), 'b')
143
- c = flexmock(Class.new(b), 'c')
144
- d = flexmock(Class.new(c), 'd')
145
-
146
- c.should_receive(:promote_value).with('b', 2).and_return("b2_b_c").once.ordered
147
- d.should_receive(:promote_value).with('b', "b2_b_c").and_return(12).once.ordered
148
-
149
- c.should_receive(:promote_value).with('c', 3).and_return("c3_b_c").once.ordered
150
- d.should_receive(:promote_value).with('c', "c3_b_c").and_return(13).once.ordered
151
-
152
- c.should_receive(:promote_value).with('d', 4).and_return("d4_b_c").once.ordered
153
- d.should_receive(:promote_value).with('d', "d4_b_c").and_return(14).once.ordered
154
-
155
- b.should_receive(:promote_value).with('a', 0).and_return("a0_a_b").once.ordered
156
- c.should_receive(:promote_value).with('a', "a0_a_b").and_return("a0_b_c").once.ordered
157
- d.should_receive(:promote_value).with('a', "a0_b_c").and_return(10).once.ordered
158
-
159
- b.should_receive(:promote_value).with('b', 1).and_return("b1_a_b").once.ordered
160
- c.should_receive(:promote_value).with('b', "b1_a_b").and_return("b1_b_c").once.ordered
161
- d.should_receive(:promote_value).with('b', "b1_b_c").and_return(11).once.ordered
162
-
163
- a.values.merge!('a' => 0, 'b' => 1)
164
- b.values.merge!('b' => 2, 'c' => 3, 'd' => 4)
165
- d.values.merge!('d' => 5, 'e' => 6)
166
- assert_equal [['d', 5], ['e', 6], ['b', 12], ['c', 13], ['d', 14], ['a', 10], ['b', 11]], d.each_value(nil, false).to_a
167
- end
168
-
169
- def test_inherited_enumerable_mapping_promote_with_key_uniq
170
- a = Class.new do
171
- def self.promote_value(key, v)
172
- end
173
- inherited_enumerable(:value, :values, :map => true) { Hash.new }
174
- end
175
- b = flexmock(Class.new(a), 'b')
176
- c = flexmock(Class.new(b), 'c')
177
- d = flexmock(Class.new(c), 'd')
178
-
179
- c.should_receive(:promote_value).with('b', 2).and_return("b2_b_c").once.ordered
180
- d.should_receive(:promote_value).with('b', "b2_b_c").and_return(12).once.ordered
181
-
182
- a.values.merge!('a' => 0, 'b' => 1)
183
- b.values.merge!('b' => 2, 'c' => 3, 'd' => 4)
184
- d.values.merge!('d' => 5, 'e' => 6)
185
- assert_equal [12], d.each_value('b', true).to_a
186
- end
187
-
188
- def test_inherited_enumerable_mapping_promote_with_key_non_uniq
189
- a = Class.new do
190
- def self.promote_value(key, v)
191
- end
192
- inherited_enumerable(:value, :values, :map => true) { Hash.new }
193
- end
194
- b = flexmock(Class.new(a), 'b')
195
- c = flexmock(Class.new(b), 'c')
196
- d = flexmock(Class.new(c), 'd')
197
-
198
- c.should_receive(:promote_value).with('b', 2).and_return("b2_b_c").once.ordered
199
- d.should_receive(:promote_value).with('b', "b2_b_c").and_return(12).once.ordered
200
-
201
- b.should_receive(:promote_value).with('b', 1).and_return("b1_a_b").once.ordered
202
- c.should_receive(:promote_value).with('b', "b1_a_b").and_return("b1_b_c").once.ordered
203
- d.should_receive(:promote_value).with('b', "b1_b_c").and_return(11).once.ordered
204
-
205
- a.values.merge!('a' => 0, 'b' => 1)
206
- b.values.merge!('b' => 2, 'c' => 3, 'd' => 4)
207
- d.values.merge!('d' => 5, 'e' => 6)
208
- assert_equal [12, 11], d.each_value('b', false).to_a
209
- end
210
- end
211
-
212
-
data/test/test_module.rb DELETED
@@ -1,126 +0,0 @@
1
- require './test/test_config'
2
-
3
- require 'flexmock/test_unit'
4
- require 'set'
5
- require 'enumerator'
6
- require 'utilrb/module'
7
-
8
- class TC_Module < Test::Unit::TestCase
9
- def test_include
10
- class_extension = Module.new do
11
- def tag; end
12
- end
13
-
14
- m = Module.new do
15
- const_set(:ClassExtension, class_extension)
16
- end
17
-
18
- m2 = Module.new { include m }
19
- assert(m2::ClassExtension.method_defined?(:tag))
20
- k = Class.new do
21
- include m2
22
- end
23
- assert(k.respond_to?(:tag))
24
- end
25
-
26
- Foo = 42
27
-
28
- def test_define_or_reuse
29
- mod = Module.new
30
- klass = Class.new
31
-
32
- new_mod = mod.define_or_reuse(:Foo) { klass.new }
33
- assert_kind_of(klass, new_mod)
34
- assert_equal(new_mod, mod.define_or_reuse(:Foo) { flunk("block called in #define_under") })
35
-
36
- # Now try with a constant that is widely available
37
- new_mod = mod.define_or_reuse('Signal') { klass.new }
38
- assert_kind_of(klass, new_mod)
39
- assert_equal(new_mod, mod.define_or_reuse('Signal') { flunk("block called in #define_under") })
40
- end
41
-
42
- def test_define_method_with_block
43
- FlexMock.use do |mock|
44
- mock.should_receive(:called).once
45
- block_obj = lambda { mock.called }
46
- test_obj = self
47
- method = lambda do |block, a, b|
48
- test_obj.assert_equal(a, 1)
49
- test_obj.assert_equal(b, 2)
50
- test_obj.assert_equal(block, block_obj)
51
- block_obj.call
52
- end
53
-
54
- klass = Class.new do
55
- define_method_with_block(:call, &method)
56
- end
57
- klass.new.call(1, 2, &block_obj)
58
- end
59
- end
60
-
61
- def test_attr_enumerable
62
- klass = Class.new do
63
- attr_enumerable(:mapped, :map) { Hash.new }
64
- end
65
-
66
- obj = klass.new
67
- obj.map[:a] = [10, 20]
68
- obj.map[:b] = 10
69
- assert_equal( [[:a, [10, 20]], [:b, 10]].to_set, obj.enum_for(:each_mapped).to_set )
70
- assert_equal( [10, 20], obj.enum_for(:each_mapped, :a).to_a )
71
- end
72
-
73
- def test_has_ancestor
74
- mod = Module.new
75
- parent = Class.new do
76
- include mod
77
- end
78
- child = Class.new(parent)
79
-
80
- assert(child.has_ancestor?(parent))
81
- assert(child.has_ancestor?(mod))
82
- assert(parent.has_ancestor?(mod))
83
-
84
- assert(!parent.has_ancestor?(child))
85
- end
86
-
87
- def test_dsl_attribute_without_filter
88
- obj = Class.new do
89
- dsl_attribute :value
90
- end.new
91
- assert_same nil, obj.value
92
- assert_same obj, obj.value(10)
93
- assert_equal 10, obj.value
94
- end
95
-
96
- def test_dsl_attribute_with_filter
97
- obj = Class.new do
98
- dsl_attribute :value do |v|
99
- v * 2
100
- end
101
- end.new
102
- assert_same nil, obj.value
103
- assert_same obj, obj.value(10)
104
- assert_equal 20, obj.value
105
- end
106
-
107
- def test_define_inherited_enumerable_usable_on_extended_modules
108
- obj = Array.new
109
- defmod = Module.new do
110
- define_inherited_enumerable(:object, :objects) { obj }
111
- end
112
- mod = Module.new { extend defmod }
113
- assert_same obj, mod.objects
114
- end
115
-
116
- def test_define_inherited_enumerable_usable_through_inclusion
117
- obj = Array.new
118
- defmod = Module.new do
119
- define_inherited_enumerable(:object, :objects) { obj }
120
- end
121
- intermediate = Module.new { include defmod }
122
- mod = Module.new { extend intermediate }
123
- assert_same obj, mod.objects
124
- end
125
- end
126
-
data/test/test_object.rb DELETED
@@ -1,77 +0,0 @@
1
- require './test/test_config'
2
-
3
- require 'utilrb/object'
4
- require 'utilrb/module/attr_predicate'
5
-
6
- class TC_Object < Test::Unit::TestCase
7
- def test_address
8
- assert_equal("2aaaab38b398", Object.address_from_id(0x1555559c59cc).to_s(16))
9
-
10
- foo = Object.new
11
- foo.to_s =~ /#<Object:0x0*([0-9a-f]+)>/
12
- foo_address = $1
13
- assert_equal(foo_address, foo.address.to_s(16), "#{foo} #{foo.address.to_s(16)} #{foo.object_id.to_s(16)}")
14
- end
15
-
16
- def check_attribute(object)
17
- assert(object.respond_to?(:as_hash))
18
- assert(object.respond_to?(:as_hash=))
19
- assert(object.respond_to?(:block))
20
- assert(object.respond_to?(:block=))
21
- hash_attribute = object.as_hash
22
- block_attribute = object.block
23
- assert(Hash === hash_attribute)
24
- assert(Array === block_attribute)
25
-
26
- new_value = Time.now
27
-
28
- assert_same(hash_attribute, object.as_hash)
29
- object.as_hash = new_value
30
- assert_same(new_value, object.as_hash)
31
-
32
- assert_same(block_attribute, object.block)
33
- object.block = new_value
34
- assert_same(object.block, new_value)
35
- end
36
- def test_attribute
37
- klass = Class.new do
38
- attribute :as_hash => Hash.new
39
- attribute(:block) { Array.new }
40
- class_attribute :as_hash => Hash.new # do NOT use :hash here as it would override #hash which is a quite useful method ...
41
- class_attribute(:block) { Array.new }
42
- end
43
-
44
- obj1, obj2 = klass.new, klass.new
45
- check_attribute(obj1)
46
- check_attribute(obj2)
47
-
48
- obj1, obj2 = klass.new, klass.new
49
- assert_same(obj1.as_hash, obj2.as_hash)
50
- obj1.as_hash = Hash.new
51
- assert_not_same(obj1.as_hash, obj2.as_hash)
52
-
53
- assert_not_same(obj1.block, obj2.block)
54
- obj1.block = obj2.block
55
- assert_same(obj1.block, obj2.block)
56
- end
57
-
58
- def test_attr_predicate
59
- klass = Class.new do
60
- attr_predicate :working
61
- attr_predicate :not_working, true
62
- end
63
- assert(klass.method_defined?(:working?))
64
- assert(!klass.method_defined?(:working))
65
- assert(!klass.method_defined?(:working=))
66
- assert(klass.method_defined?(:not_working?))
67
- assert(!klass.method_defined?(:not_working))
68
- assert(klass.method_defined?(:not_working=))
69
-
70
- object = klass.new
71
- object.instance_eval { @working = true }
72
- assert(object.working?)
73
- object.not_working = 5
74
- assert_equal(true, object.not_working?)
75
- end
76
- end
77
-
@@ -1,26 +0,0 @@
1
- require './test/test_config'
2
-
3
- require 'utilrb/objectstats'
4
- require 'utilrb/hash/to_s'
5
-
6
- class TC_ObjectStats < Test::Unit::TestCase
7
- def teardown
8
- GC.enable
9
- end
10
-
11
- def allocate_dead_hash; Hash.new; nil end
12
-
13
- def assert_profile(expected, value, string = nil)
14
- value = value.dup
15
- value.delete(ObjectStats::LIVE_OBJECTS_KEY)
16
- assert_equal(expected, value, (string || "") + " #{value}")
17
- end
18
-
19
- def test_object_stats
20
- assert_profile({}, ObjectStats.profile { ObjectStats.count }, "Object allocation profile changed")
21
- assert_profile({ Hash => 1 }, ObjectStats.profile { ObjectStats.count_by_class }, "Object allocation profile changed")
22
- assert_profile({ Array => 1 }, ObjectStats.profile { test = [] })
23
- assert_profile({ Array => 2, Hash => 1 }, ObjectStats.profile { a, b = [], {} })
24
- end
25
- end
26
-
@@ -1,84 +0,0 @@
1
- require 'test/unit'
2
- require 'set'
3
- require 'utilrb/pkgconfig'
4
-
5
- class TC_PkgConfig < Test::Unit::TestCase
6
- def setup
7
- @old_pkg_config_path = ENV['PKG_CONFIG_PATH']
8
- ENV['PKG_CONFIG_PATH'] = File.join(File.expand_path(File.dirname(__FILE__)), 'data')
9
- end
10
- def teardown
11
- ENV['PKG_CONFIG_PATH'] = @old_pkg_config_path
12
- end
13
-
14
- PkgConfig = Utilrb::PkgConfig
15
- def test_find_package
16
- assert_raises(PkgConfig::NotFound) { PkgConfig.new('does_not_exist') }
17
- assert_nothing_raised { PkgConfig.new('test_pkgconfig') }
18
- end
19
-
20
- def test_load
21
- pkg = PkgConfig.new('test_pkgconfig')
22
- assert_equal('test_pkgconfig', pkg.name)
23
- assert_equal([4, 2], pkg.version)
24
-
25
- assert_equal('a_prefix', pkg.prefix)
26
- assert_equal(%w{-Ia_prefix/include -O3}.to_set, pkg.cflags.split.to_set)
27
- assert_equal('-Ia_prefix/include', pkg.cflags_only_I)
28
- assert_equal('-O3', pkg.cflags_only_other)
29
- assert_equal(['a_prefix/include'], pkg.include_dirs)
30
-
31
- assert_equal(%w{-ltest -lother -La_prefix/lib}.to_set, pkg.libs.split.to_set)
32
- assert_equal('-La_prefix/lib', pkg.libs_only_L)
33
- assert_equal(%w{-ltest -lother}.to_set, pkg.libs_only_l.split.to_set)
34
- assert_equal(['a_prefix/lib'], pkg.library_dirs)
35
-
36
- pkg = PkgConfig.new('test_pkgconfig_empty')
37
- assert_equal('a_prefix', pkg.prefix)
38
- assert_equal("", pkg.cflags)
39
- assert_equal('', pkg.cflags_only_I)
40
- assert_equal('', pkg.cflags_only_other)
41
- assert_equal([], pkg.include_dirs)
42
-
43
- assert_equal('', pkg.libs)
44
- assert_equal('', pkg.libs_only_L)
45
- assert_equal('', pkg.libs_only_l)
46
- assert_equal([], pkg.library_dirs)
47
- end
48
-
49
- def test_comparison_with_cpkgconfig
50
- PkgConfig.each_package do |name|
51
- pkg = begin PkgConfig.new(name)
52
- rescue PkgConfig::NotFound
53
- `pkg-config --cflags #{name}`
54
- if $? == 0
55
- raise
56
- else
57
- puts "can be loaded by neither the ruby nor the C versions"
58
- next
59
- end
60
- end
61
-
62
- failed = false
63
- PkgConfig::ACTIONS.each do |action_name|
64
- method_name = action_name.gsub(/-/, '_')
65
-
66
- pure_ruby = Shellwords.shellsplit(pkg.send(method_name)).to_set
67
- cpkgconfig = Shellwords.shellsplit(pkg.send("pkgconfig_#{method_name}")).to_set
68
- default_paths = Utilrb::PkgConfig.default_search_path.map { |p| Regexp.quote(p.gsub(/\/pkgconfig/, '')) }.join("|")
69
- pure_ruby.delete_if { |f| f=~/-[IL](#{default_paths}|\/lib)$/ }
70
- if pure_ruby != cpkgconfig
71
- failed = true
72
- puts "#{name} #{action_name}"
73
- puts " pure ruby: #{pure_ruby.inspect}"
74
- puts " cpkgconfig: #{cpkgconfig.inspect}"
75
- end
76
- end
77
- if failed
78
- puts "contents:"
79
- puts pkg.file.join("\n")
80
- assert(false, "result from pkg-config and the PkgConfig class differ")
81
- end
82
- end
83
- end
84
- end
data/test/test_proc.rb DELETED
@@ -1,31 +0,0 @@
1
- require './test/test_config'
2
-
3
- require 'utilrb'
4
-
5
- Utilrb.require_ext('TC_Proc') do
6
- if RUBY_VERSION =~ /^1\.8/
7
- class TC_Proc < Test::Unit::TestCase
8
- def block_to_proc_helper(&block); block end
9
- def block_to_proc
10
- [block_to_proc_helper { blo }, block_to_proc_helper { bla }]
11
- end
12
- def test_same_body
13
- a1, a2 = block_to_proc
14
- b1, b2 = block_to_proc
15
- assert(a1.same_body?(b1))
16
- assert(a2.same_body?(b2))
17
- assert(!a1.same_body?(b2))
18
- assert(!a2.same_body?(b1))
19
- end
20
-
21
- def test_line
22
- assert_equal(10, block_to_proc.first.line)
23
- end
24
-
25
- def test_file
26
- assert_equal(File.expand_path(__FILE__), File.expand_path(block_to_proc.first.file))
27
- end
28
- end
29
- end
30
- end
31
-
data/test/test_set.rb DELETED
@@ -1,19 +0,0 @@
1
- require './test/test_config'
2
- require 'utilrb/set'
3
-
4
- class TC_Set < Test::Unit::TestCase
5
- def test_to_s
6
- obj = Set.new
7
- obj << 1
8
- obj << 2
9
- assert(obj.to_s =~ /^\{(.*)\}$/)
10
- values = $1.split(", ")
11
- assert_equal(["1", "2"].to_set, values.to_set)
12
-
13
- obj << obj
14
- assert(obj.to_s =~ /^\{(.*)\}$/)
15
- values = $1.split(", ")
16
- assert_equal(["1", "2", "..."].to_set, values.to_set)
17
- end
18
- end
19
-