blockenspiel 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Blockenspiel.rdoc +48 -42
- data/History.rdoc +14 -0
- data/README.rdoc +20 -19
- data/Version +1 -1
- data/lib/blockenspiel.rb +2 -2
- data/lib/blockenspiel/builder.rb +1 -1
- data/lib/blockenspiel/dsl_setup.rb +1 -1
- data/lib/blockenspiel/errors.rb +1 -1
- data/lib/blockenspiel/impl.rb +60 -48
- data/lib/blockenspiel/unmixer_rubinius.rb +18 -3
- data/lib/blockenspiel/unmixer_unimplemented.rb +4 -1
- data/lib/blockenspiel/version.rb +1 -1
- data/lib/blockenspiel/versionomy.rb +1 -1
- data/lib/blockenspiel_unmixer_jruby.jar +0 -0
- data/test/tc_basic.rb +9 -8
- data/test/tc_behaviors.rb +9 -9
- data/test/tc_dsl_attrs.rb +2 -2
- data/test/tc_dsl_methods.rb +10 -10
- data/test/tc_dynamic.rb +5 -5
- data/test/tc_embedded_block.rb +2 -2
- data/test/tc_mixins.rb +40 -22
- data/test/tc_modules.rb +3 -3
- data/test/tc_version.rb +3 -3
- metadata +17 -21
- data/ext/unmixer_mri/extconf.rb +0 -47
- data/ext/unmixer_mri/unmixer_mri.c +0 -103
@@ -71,10 +71,25 @@ module Blockenspiel
|
|
71
71
|
end
|
72
72
|
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
if ::Rubinius::VM.method(:reset_method_cache).arity == 1
|
75
|
+
|
76
|
+
# Older versions of Rubinius
|
77
|
+
def self._reset_method_cache(obj_) # :nodoc:
|
78
|
+
obj_.methods.each do |name_|
|
79
|
+
::Rubinius::VM.reset_method_cache(name_.to_sym)
|
80
|
+
end
|
77
81
|
end
|
82
|
+
|
83
|
+
else
|
84
|
+
|
85
|
+
# Newer versions of Rubinius
|
86
|
+
def self._reset_method_cache(obj_) # :nodoc:
|
87
|
+
klass_ = obj_.class
|
88
|
+
obj_.methods.each do |name_|
|
89
|
+
::Rubinius::VM.reset_method_cache(klass_, name_.to_sym)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
78
93
|
end
|
79
94
|
|
80
95
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Blockenspiel unmixer module when unmixer is not implemented
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010
|
6
|
+
# Copyright 2010 Daniel Azuma
|
7
7
|
#
|
8
8
|
# All rights reserved.
|
9
9
|
#
|
@@ -42,6 +42,9 @@ module Blockenspiel
|
|
42
42
|
module Unmixer
|
43
43
|
|
44
44
|
|
45
|
+
UNIMPLEMENTED = true
|
46
|
+
|
47
|
+
|
45
48
|
# Unmixer stub.
|
46
49
|
# This throws an exception indicating the unmixer is not implemented.
|
47
50
|
|
data/lib/blockenspiel/version.rb
CHANGED
Binary file
|
data/test/tc_basic.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# This file contains tests for the simple use cases.
|
6
6
|
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
|
-
# Copyright 2008
|
8
|
+
# Copyright 2008 Daniel Azuma
|
9
9
|
#
|
10
10
|
# All rights reserved.
|
11
11
|
#
|
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestBasic < ::Test
|
46
|
+
class TestBasic < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
class SimpleTarget < ::Blockenspiel::Base
|
@@ -87,16 +87,17 @@ module Blockenspiel
|
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
|
-
# Test basic usage with a
|
90
|
+
# Test basic usage with a delegator.
|
91
91
|
#
|
92
|
-
# * Asserts that
|
93
|
-
# * Asserts that methods
|
94
|
-
# * Asserts that
|
92
|
+
# * Asserts that the specified target object receives the messages.
|
93
|
+
# * Asserts that methods from the surrounding context are also available.
|
94
|
+
# * Asserts that methods are not present in self afterward.
|
95
95
|
|
96
|
-
def
|
96
|
+
def test_basic_parameterless
|
97
97
|
block_ = ::Proc.new do
|
98
98
|
set_value(:a, 1)
|
99
99
|
set_value_by_block(:b){ 2 }
|
100
|
+
assert(true)
|
100
101
|
end
|
101
102
|
target_ = SimpleTarget.new
|
102
103
|
::Blockenspiel.invoke(block_, target_)
|
data/test/tc_behaviors.rb
CHANGED
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestBehaviors < ::Test
|
46
|
+
class TestBehaviors < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
class Target1 < ::Blockenspiel::Base
|
@@ -93,8 +93,8 @@ module Blockenspiel
|
|
93
93
|
set_value1('a', 1)
|
94
94
|
set_value2('b'){ 2 }
|
95
95
|
set_value3('c', 3)
|
96
|
-
context_self_.
|
97
|
-
context_self_.
|
96
|
+
context_self_.assert_raises(::NoMethodError){ set_value3_dslversion('d', 4) }
|
97
|
+
context_self_.assert_raises(::NoMethodError){ helper_method() }
|
98
98
|
context_self_.assert(!instance_variable_defined?(:@my_instance_variable_test))
|
99
99
|
context_self_.assert_instance_of(::Blockenspiel::Tests::TestBehaviors::Target1, self)
|
100
100
|
end
|
@@ -120,11 +120,11 @@ module Blockenspiel
|
|
120
120
|
set_value1('a', 1)
|
121
121
|
set_value2('b'){ 2 }
|
122
122
|
set_value3_dslversion('c', 3)
|
123
|
-
context_self_.
|
123
|
+
context_self_.assert_raises(::NoMethodError){ set_value3('d', 4) }
|
124
124
|
context_self_.assert(helper_method())
|
125
125
|
context_self_.assert(!instance_variable_defined?(:@my_instance_variable_test))
|
126
126
|
context_self_.assert(!self.kind_of?(::Blockenspiel::Tests::TestBehaviors::Target1))
|
127
|
-
context_self_.
|
127
|
+
context_self_.refute_equal(context_self_, self)
|
128
128
|
end
|
129
129
|
::Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :proxy)
|
130
130
|
assert_equal(1, hash_['a1'])
|
@@ -149,11 +149,11 @@ module Blockenspiel
|
|
149
149
|
block3_ = ::Proc.new do
|
150
150
|
set_value1('c', 3)
|
151
151
|
end
|
152
|
-
|
152
|
+
assert_raises(::Blockenspiel::BlockParameterError) do
|
153
153
|
::Blockenspiel.invoke(block1_, Target1.new(hash_), :parameterless => false)
|
154
154
|
end
|
155
155
|
::Blockenspiel.invoke(block2_, Target1.new(hash_), :parameterless => false)
|
156
|
-
|
156
|
+
assert_raises(::Blockenspiel::BlockParameterError) do
|
157
157
|
::Blockenspiel.invoke(block3_, Target1.new(hash_), :parameterless => false)
|
158
158
|
end
|
159
159
|
assert_equal(2, hash_['b1'])
|
@@ -177,7 +177,7 @@ module Blockenspiel
|
|
177
177
|
set_value1('c', 3)
|
178
178
|
end
|
179
179
|
::Blockenspiel.invoke(block1_, Target1.new(hash_), :parameter => false)
|
180
|
-
|
180
|
+
assert_raises(::Blockenspiel::BlockParameterError) do
|
181
181
|
::Blockenspiel.invoke(block2_, Target1.new(hash_), :parameter => false)
|
182
182
|
end
|
183
183
|
::Blockenspiel.invoke(block3_, Target1.new(hash_), :parameter => false)
|
data/test/tc_dsl_attrs.rb
CHANGED
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestDSLAttrs < ::Test
|
46
|
+
class TestDSLAttrs < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
class WriterTarget < ::Blockenspiel::Base
|
data/test/tc_dsl_methods.rb
CHANGED
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestDSLMethods < ::Test
|
46
|
+
class TestDSLMethods < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
class Target1 < ::Blockenspiel::Base
|
@@ -206,7 +206,7 @@ module Blockenspiel
|
|
206
206
|
block_ = ::Proc.new do
|
207
207
|
set_value1('a', 1)
|
208
208
|
set_value2('b'){ 2 }
|
209
|
-
|
209
|
+
assert_raises(::NoMethodError){ _set_value3('c', 3) }
|
210
210
|
end
|
211
211
|
::Blockenspiel.invoke(block_, Target1.new(hash_))
|
212
212
|
assert_equal(1, hash_['a1'])
|
@@ -224,7 +224,7 @@ module Blockenspiel
|
|
224
224
|
def test_onoff_switching
|
225
225
|
hash_ = ::Hash.new
|
226
226
|
block_ = ::Proc.new do
|
227
|
-
|
227
|
+
assert_raises(::NoMethodError){ _set_value1('a', 1) }
|
228
228
|
set_value2('b'){ 2 }
|
229
229
|
_set_value3('c', 3)
|
230
230
|
end
|
@@ -244,7 +244,7 @@ module Blockenspiel
|
|
244
244
|
hash_ = ::Hash.new
|
245
245
|
block_ = ::Proc.new do
|
246
246
|
set_value1('a', 1)
|
247
|
-
|
247
|
+
assert_raises(::NoMethodError){ set_value2('b'){ 2 } }
|
248
248
|
renamed_set_value2('c'){ 3 }
|
249
249
|
another_set_value2('d'){ 4 }
|
250
250
|
end
|
@@ -264,8 +264,8 @@ module Blockenspiel
|
|
264
264
|
def test_explicit_removing
|
265
265
|
hash_ = ::Hash.new
|
266
266
|
block_ = ::Proc.new do
|
267
|
-
|
268
|
-
|
267
|
+
assert_raises(::NoMethodError){ set_value1('a', 1) }
|
268
|
+
assert_raises(::NoMethodError){ set_value2('b'){ 2 } }
|
269
269
|
renamed_set_value2('c'){ 3 }
|
270
270
|
end
|
271
271
|
::Blockenspiel.invoke(block_, Target4.new(hash_))
|
@@ -285,8 +285,8 @@ module Blockenspiel
|
|
285
285
|
block_ = ::Proc.new do
|
286
286
|
set_value1('a', 1)
|
287
287
|
set_value2('b'){ 2 }
|
288
|
-
|
289
|
-
|
288
|
+
assert_raises(::NoMethodError){ set_value3('c', 3) }
|
289
|
+
assert_raises(::NoMethodError){ set_value4('d', 4) }
|
290
290
|
renamed_set_value4('e', 5)
|
291
291
|
set_value5('f', 6)
|
292
292
|
end
|
@@ -310,7 +310,7 @@ module Blockenspiel
|
|
310
310
|
block_ = ::Proc.new do
|
311
311
|
set_value1('a', 1)
|
312
312
|
renamed_set_value2('b'){ 2 }
|
313
|
-
|
313
|
+
assert_raises(::NoMethodError){ set_value2('c', 3) }
|
314
314
|
end
|
315
315
|
::Blockenspiel.invoke(block_, Target6.new(hash_))
|
316
316
|
assert_equal(1, hash_['a1'])
|
data/test/tc_dynamic.rb
CHANGED
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestDynamic < ::Test
|
46
|
+
class TestDynamic < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
# Test the simple case.
|
@@ -78,12 +78,12 @@ module Blockenspiel
|
|
78
78
|
end
|
79
79
|
block1_ = ::Proc.new do
|
80
80
|
renamed_set_value(:a, 1)
|
81
|
-
|
81
|
+
assert_raises(::NoMethodError){ set_value(:b, 2) }
|
82
82
|
end
|
83
83
|
::Blockenspiel.invoke(block1_, &dsl_definition_)
|
84
84
|
block2_ = ::Proc.new do |dsl_|
|
85
85
|
dsl_.set_value(:c, 3)
|
86
|
-
|
86
|
+
assert_raises(::NoMethodError){ renamed_set_value(:d, 4) }
|
87
87
|
end
|
88
88
|
::Blockenspiel.invoke(block2_, &dsl_definition_)
|
89
89
|
assert_equal(1, hash_[:a])
|
@@ -200,7 +200,7 @@ module Blockenspiel
|
|
200
200
|
set_value(:a, 1)
|
201
201
|
end
|
202
202
|
hash_ = ::Hash.new
|
203
|
-
|
203
|
+
assert_raises(::Blockenspiel::BlockParameterError) do
|
204
204
|
::Blockenspiel.invoke(block_, :parameterless => false) do
|
205
205
|
add_method(:set_value) do |key_, value_|
|
206
206
|
hash_[key_] = value_
|
data/test/tc_embedded_block.rb
CHANGED
@@ -36,14 +36,14 @@
|
|
36
36
|
;
|
37
37
|
|
38
38
|
|
39
|
-
require '
|
39
|
+
require 'minitest/autorun'
|
40
40
|
require 'blockenspiel'
|
41
41
|
|
42
42
|
|
43
43
|
module Blockenspiel
|
44
44
|
module Tests # :nodoc:
|
45
45
|
|
46
|
-
class TestEmbeddedBlock < ::Test
|
46
|
+
class TestEmbeddedBlock < ::Minitest::Test # :nodoc:
|
47
47
|
|
48
48
|
|
49
49
|
class Target1 < ::Blockenspiel::Base
|
data/test/tc_mixins.rb
CHANGED
@@ -37,14 +37,14 @@
|
|
37
37
|
;
|
38
38
|
|
39
39
|
|
40
|
-
require '
|
40
|
+
require 'minitest/autorun'
|
41
41
|
require 'blockenspiel'
|
42
42
|
|
43
43
|
|
44
44
|
module Blockenspiel
|
45
45
|
module Tests # :nodoc:
|
46
46
|
|
47
|
-
class TestMixins < ::Test
|
47
|
+
class TestMixins < ::Minitest::Test # :nodoc:
|
48
48
|
|
49
49
|
|
50
50
|
class Target1 < ::Blockenspiel::Base
|
@@ -124,6 +124,8 @@ module Blockenspiel
|
|
124
124
|
# * Asserts that self doesn't change, and instance variables are preserved.
|
125
125
|
|
126
126
|
def test_basic_mixin
|
127
|
+
skip unless ::Blockenspiel.mixin_available?
|
128
|
+
|
127
129
|
hash_ = ::Hash.new
|
128
130
|
saved_object_id_ = self.object_id
|
129
131
|
@my_instance_variable_test = :hello
|
@@ -135,7 +137,7 @@ module Blockenspiel
|
|
135
137
|
assert_equal(:hello, @my_instance_variable_test)
|
136
138
|
assert_equal(saved_object_id_, self.object_id)
|
137
139
|
end
|
138
|
-
::Blockenspiel.invoke(block_, Target1.new(hash_))
|
140
|
+
::Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :mixin)
|
139
141
|
assert(!self.respond_to?(:set_value))
|
140
142
|
assert(!self.respond_to?(:set_value2))
|
141
143
|
assert_equal(1, hash_['a1'])
|
@@ -149,6 +151,8 @@ module Blockenspiel
|
|
149
151
|
# * Asserts that the methods properly delegate to the target object.
|
150
152
|
|
151
153
|
def test_mixin_with_renaming
|
154
|
+
skip unless ::Blockenspiel.mixin_available?
|
155
|
+
|
152
156
|
hash_ = ::Hash.new
|
153
157
|
assert(!self.respond_to?(:set_value))
|
154
158
|
assert(!self.respond_to?(:set_value2))
|
@@ -158,7 +162,7 @@ module Blockenspiel
|
|
158
162
|
set_value2_inmixin('b'){ 2 }
|
159
163
|
assert(!self.respond_to?(:set_value2))
|
160
164
|
end
|
161
|
-
::Blockenspiel.invoke(block_, Target2.new(hash_))
|
165
|
+
::Blockenspiel.invoke(block_, Target2.new(hash_), :parameterless => :mixin)
|
162
166
|
assert(!self.respond_to?(:set_value))
|
163
167
|
assert(!self.respond_to?(:set_value2))
|
164
168
|
assert(!self.respond_to?(:set_value2_inmixin))
|
@@ -174,6 +178,8 @@ module Blockenspiel
|
|
174
178
|
# multiple mixins add the same method name
|
175
179
|
|
176
180
|
def test_nested_different
|
181
|
+
skip unless ::Blockenspiel.mixin_available?
|
182
|
+
|
177
183
|
hash_ = ::Hash.new
|
178
184
|
assert(!self.respond_to?(:set_value))
|
179
185
|
assert(!self.respond_to?(:set_value2))
|
@@ -185,11 +191,11 @@ module Blockenspiel
|
|
185
191
|
::Blockenspiel.invoke(::Proc.new do
|
186
192
|
set_value('c', 1)
|
187
193
|
set_value2_inmixin('d'){ 2 }
|
188
|
-
end, Target2.new(hash_))
|
194
|
+
end, Target2.new(hash_), :parameterless => :mixin)
|
189
195
|
assert(!self.respond_to?(:set_value2_inmixin))
|
190
196
|
set_value('e', 1)
|
191
197
|
set_value2('f'){ 2 }
|
192
|
-
end, Target1.new(hash_))
|
198
|
+
end, Target1.new(hash_), :parameterless => :mixin)
|
193
199
|
assert(!self.respond_to?(:set_value))
|
194
200
|
assert(!self.respond_to?(:set_value2))
|
195
201
|
assert(!self.respond_to?(:set_value2_inmixin))
|
@@ -207,6 +213,8 @@ module Blockenspiel
|
|
207
213
|
# * Asserts that the methods are added and removed at the right time.
|
208
214
|
|
209
215
|
def test_nested_same
|
216
|
+
skip unless ::Blockenspiel.mixin_available?
|
217
|
+
|
210
218
|
hash_ = ::Hash.new
|
211
219
|
assert(!self.respond_to?(:set_value))
|
212
220
|
assert(!self.respond_to?(:set_value2))
|
@@ -218,10 +226,10 @@ module Blockenspiel
|
|
218
226
|
set_value('c', 1)
|
219
227
|
set_value2_inmixin('d'){ 2 }
|
220
228
|
assert(!self.respond_to?(:set_value2))
|
221
|
-
end, Target2.new(hash_))
|
229
|
+
end, Target2.new(hash_), :parameterless => :mixin)
|
222
230
|
set_value('e', 1)
|
223
231
|
set_value2_inmixin('f'){ 2 }
|
224
|
-
end, Target2.new(hash_))
|
232
|
+
end, Target2.new(hash_), :parameterless => :mixin)
|
225
233
|
assert(!self.respond_to?(:set_value))
|
226
234
|
assert(!self.respond_to?(:set_value2))
|
227
235
|
assert(!self.respond_to?(:set_value2_inmixin))
|
@@ -239,6 +247,8 @@ module Blockenspiel
|
|
239
247
|
# * Asserts that the mixin is removed only after the second thread is done.
|
240
248
|
|
241
249
|
def test_threads_same_mixin
|
250
|
+
skip unless ::Blockenspiel.mixin_available?
|
251
|
+
|
242
252
|
hash_ = ::Hash.new
|
243
253
|
block1_ = ::Proc.new do
|
244
254
|
set_value('a', 1)
|
@@ -252,10 +262,10 @@ module Blockenspiel
|
|
252
262
|
end
|
253
263
|
target_ = Target1.new(hash_)
|
254
264
|
thread1_ = ::Thread.new do
|
255
|
-
::Blockenspiel.invoke(block1_, target_)
|
265
|
+
::Blockenspiel.invoke(block1_, target_, :parameterless => :mixin)
|
256
266
|
end
|
257
267
|
thread2_ = ::Thread.new do
|
258
|
-
::Blockenspiel.invoke(block2_, target_)
|
268
|
+
::Blockenspiel.invoke(block2_, target_, :parameterless => :mixin)
|
259
269
|
end
|
260
270
|
thread1_.join
|
261
271
|
thread2_.join
|
@@ -267,6 +277,8 @@ module Blockenspiel
|
|
267
277
|
|
268
278
|
|
269
279
|
def test_two_threads_different_mixin
|
280
|
+
skip unless ::Blockenspiel.mixin_available?
|
281
|
+
|
270
282
|
hash_ = {}
|
271
283
|
target1_ = Target1.new(hash_)
|
272
284
|
target2_ = Target2.new(hash_)
|
@@ -279,7 +291,7 @@ module Blockenspiel
|
|
279
291
|
set_value('a', 1)
|
280
292
|
sleep(0.1)
|
281
293
|
set_value('e', 5)
|
282
|
-
end, target1_)
|
294
|
+
end, target1_, :parameterless => :mixin)
|
283
295
|
end
|
284
296
|
t2_ = ::Thread.new do
|
285
297
|
::Blockenspiel.invoke(::Proc.new do
|
@@ -287,7 +299,7 @@ module Blockenspiel
|
|
287
299
|
set_value('A', 11)
|
288
300
|
sleep(0.1)
|
289
301
|
set_value('E', 15)
|
290
|
-
end, target2_)
|
302
|
+
end, target2_, :parameterless => :mixin)
|
291
303
|
end
|
292
304
|
t1_.join
|
293
305
|
t2_.join
|
@@ -310,6 +322,8 @@ module Blockenspiel
|
|
310
322
|
# threads.
|
311
323
|
|
312
324
|
def test_nested_two_threads
|
325
|
+
skip unless ::Blockenspiel.mixin_available?
|
326
|
+
|
313
327
|
hash_ = {}
|
314
328
|
target1_ = Target1.new(hash_)
|
315
329
|
target2_ = Target2.new(hash_)
|
@@ -325,11 +339,11 @@ module Blockenspiel
|
|
325
339
|
sleep(0.1)
|
326
340
|
set_value('c', 3)
|
327
341
|
set_value2_inmixin('d'){ 4 }
|
328
|
-
end, target2_)
|
342
|
+
end, target2_, :parameterless => :mixin)
|
329
343
|
sleep(0.1)
|
330
344
|
set_value('e', 5)
|
331
345
|
set_value2('f'){ 6 }
|
332
|
-
end, target1_)
|
346
|
+
end, target1_, :parameterless => :mixin)
|
333
347
|
end
|
334
348
|
t2_ = ::Thread.new do
|
335
349
|
::Blockenspiel.invoke(::Proc.new do
|
@@ -340,11 +354,11 @@ module Blockenspiel
|
|
340
354
|
sleep(0.1)
|
341
355
|
set_value('C', 13)
|
342
356
|
set_value2('D'){ 14 }
|
343
|
-
end, target1_)
|
357
|
+
end, target1_, :parameterless => :mixin)
|
344
358
|
sleep(0.1)
|
345
359
|
set_value('E', 15)
|
346
360
|
set_value2_inmixin('F'){ 16 }
|
347
|
-
end, target2_)
|
361
|
+
end, target2_, :parameterless => :mixin)
|
348
362
|
end
|
349
363
|
t1_.join
|
350
364
|
t2_.join
|
@@ -377,6 +391,8 @@ module Blockenspiel
|
|
377
391
|
if defined?(::Fiber)
|
378
392
|
|
379
393
|
def test_nested_two_fibers
|
394
|
+
skip unless ::Blockenspiel.mixin_available?
|
395
|
+
|
380
396
|
hash_ = {}
|
381
397
|
target1_ = Target1.new(hash_)
|
382
398
|
target2_ = Target2.new(hash_)
|
@@ -392,11 +408,11 @@ module Blockenspiel
|
|
392
408
|
::Fiber.yield
|
393
409
|
set_value('c', 3)
|
394
410
|
set_value2_inmixin('d'){ 4 }
|
395
|
-
end, target2_)
|
411
|
+
end, target2_, :parameterless => :mixin)
|
396
412
|
::Fiber.yield
|
397
413
|
set_value('e', 5)
|
398
414
|
set_value2('f'){ 6 }
|
399
|
-
end, target1_)
|
415
|
+
end, target1_, :parameterless => :mixin)
|
400
416
|
end
|
401
417
|
f2_ = ::Fiber.new do
|
402
418
|
::Blockenspiel.invoke(::Proc.new do
|
@@ -407,11 +423,11 @@ module Blockenspiel
|
|
407
423
|
::Fiber.yield
|
408
424
|
set_value('C', 13)
|
409
425
|
set_value2('D'){ 14 }
|
410
|
-
end, target1_)
|
426
|
+
end, target1_, :parameterless => :mixin)
|
411
427
|
::Fiber.yield
|
412
428
|
set_value('E', 15)
|
413
429
|
set_value2_inmixin('F'){ 16 }
|
414
|
-
end, target2_)
|
430
|
+
end, target2_, :parameterless => :mixin)
|
415
431
|
end
|
416
432
|
f1_.resume
|
417
433
|
f2_.resume
|
@@ -447,17 +463,19 @@ module Blockenspiel
|
|
447
463
|
# * Asserts that methods that are turned off after the fact cannot be called.
|
448
464
|
|
449
465
|
def test_omissions
|
466
|
+
skip unless ::Blockenspiel.mixin_available?
|
467
|
+
|
450
468
|
hash_ = ::Hash.new
|
451
469
|
block_ = ::Proc.new do
|
452
470
|
set_value(:a, 1)
|
453
471
|
assert(!self.respond_to?(:_helper_method))
|
454
472
|
assert_equal(:helper, get_value(:a))
|
455
|
-
|
473
|
+
assert_raises(::NoMethodError) do
|
456
474
|
get_value2(:a)
|
457
475
|
end
|
458
476
|
end
|
459
477
|
target_ = Target3.new(hash_)
|
460
|
-
::Blockenspiel.invoke(block_, target_)
|
478
|
+
::Blockenspiel.invoke(block_, target_, :parameterless => :mixin)
|
461
479
|
assert(!self.respond_to?(:set_value))
|
462
480
|
assert_equal(1, target_.get_value(:a))
|
463
481
|
end
|