protocol 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/protocol.gemspec CHANGED
@@ -1,28 +1,38 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  Gem::Specification.new do |s|
3
- s.name = 'protocol'
4
- s.version = '0.9.0'
5
- s.files = ["CHANGES", "COPYING", "Rakefile", "VERSION", "benchmarks", "benchmarks/data", "benchmarks/method_parser.rb", "doc-main.txt", "examples", "examples/comparing.rb", "examples/enumerating.rb", "examples/game.rb", "examples/hello_world_patternitis.rb", "examples/indexing.rb", "examples/locking.rb", "examples/queue.rb", "examples/stack.rb", "install.rb", "lib", "lib/protocol", "lib/protocol.rb", "lib/protocol/core.rb", "lib/protocol/method_parser", "lib/protocol/method_parser/parse_tree.rb", "lib/protocol/method_parser/ruby_parser.rb", "lib/protocol/version.rb", "make_doc.rb", "protocol.gemspec", "tests", "tests/test_protocol.rb", "tests/test_protocol_method_parser.rb"]
6
- s.summary = 'Method Protocols for Ruby Classes'
7
- s.description = <<EOT
8
- This library offers an implementation of protocols against which you can check
9
- the conformity of your classes or instances of your classes. They are a bit
10
- like Java Interfaces, but as mixin modules they can also contain already
11
- implemented methods. Additionaly you can define preconditions/postconditions
12
- for methods specified in a protocol.
13
- EOT
4
+ s.name = "protocol"
5
+ s.version = "1.0.0"
14
6
 
15
- s.require_path = 'lib'
16
- s.add_dependency 'ParseTree', '~> 3.0'
17
- s.add_dependency 'ruby_parser', '~> 2.0'
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Florian Frank"]
9
+ s.date = "2013-07-18"
10
+ s.description = "This library offers an implementation of protocols against which you can check\nthe conformity of your classes or instances of your classes. They are a bit\nlike Java Interfaces, but as mixin modules they can also contain already\nimplemented methods. Additionaly you can define preconditions/postconditions\nfor methods specified in a protocol.\n"
11
+ s.email = "flori@ping.de"
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/protocol.rb", "lib/protocol/core.rb", "lib/protocol/descriptor.rb", "lib/protocol/errors.rb", "lib/protocol/message.rb", "lib/protocol/method_parser/ruby_parser.rb", "lib/protocol/post_condition.rb", "lib/protocol/protocol_module.rb", "lib/protocol/utilities.rb", "lib/protocol/version.rb", "lib/protocol/xt.rb"]
13
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "benchmarks/data/.keep", "benchmarks/method_parser.rb", "examples/assignments.rb", "examples/comparing.rb", "examples/enumerating.rb", "examples/game.rb", "examples/hello_world_patternitis.rb", "examples/indexing.rb", "examples/locking.rb", "examples/queue.rb", "examples/stack.rb", "install.rb", "lib/protocol.rb", "lib/protocol/core.rb", "lib/protocol/descriptor.rb", "lib/protocol/errors.rb", "lib/protocol/message.rb", "lib/protocol/method_parser/ruby_parser.rb", "lib/protocol/post_condition.rb", "lib/protocol/protocol_module.rb", "lib/protocol/utilities.rb", "lib/protocol/version.rb", "lib/protocol/xt.rb", "protocol.gemspec", "tests/protocol_method_parser_test.rb", "tests/protocol_test.rb", "tests/test_helper.rb"]
14
+ s.homepage = "http://flori.github.com/protocol"
15
+ s.rdoc_options = ["--title", "Protocol - Method Protocols for Ruby Classes", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = "2.0.4"
18
+ s.summary = "Method Protocols for Ruby Classes"
19
+ s.test_files = ["tests/protocol_method_parser_test.rb", "tests/protocol_test.rb", "tests/test_helper.rb"]
18
20
 
19
- s.has_rdoc = true
20
- s.rdoc_options << '--main' << 'doc-main.txt'
21
- s.extra_rdoc_files << 'doc-main.txt'
22
- s.test_files << 'tests/test_protocol.rb'
21
+ if s.respond_to? :specification_version then
22
+ s.specification_version = 4
23
23
 
24
- s.author = "Florian Frank"
25
- s.email = "flori@ping.de"
26
- s.homepage = "http://protocol.rubyforge.org"
27
- s.rubyforge_project = "protocol"
24
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
+ s.add_development_dependency(%q<gem_hadar>, ["~> 0.1.8"])
26
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
27
+ s.add_runtime_dependency(%q<ruby_parser>, ["~> 3.0"])
28
+ else
29
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
30
+ s.add_dependency(%q<simplecov>, [">= 0"])
31
+ s.add_dependency(%q<ruby_parser>, ["~> 3.0"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<gem_hadar>, ["~> 0.1.8"])
35
+ s.add_dependency(%q<simplecov>, [">= 0"])
36
+ s.add_dependency(%q<ruby_parser>, ["~> 3.0"])
28
37
  end
38
+ end
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
4
- require 'protocol'
3
+ require 'test_helper'
5
4
 
6
- class TestProtocolMethodParser < Test::Unit::TestCase
5
+ class ProtocolMethodParserTest < Test::Unit::TestCase
7
6
  include Protocol
8
7
 
9
8
  class A
@@ -1,67 +1,66 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'test/unit'
4
- require 'protocol'
3
+ require 'test_helper'
5
4
 
6
- class TestProtocol < Test::Unit::TestCase
7
- TestProtocol_foo = Protocol do
5
+ class ProtocolTest < Test::Unit::TestCase
6
+ ProtocolTest_foo = Protocol do
8
7
  check_failure :none
9
8
 
10
9
  understand :foo
11
10
  end
12
11
 
13
- TestProtocol_foo_fail = Protocol do
12
+ ProtocolTest_foo_fail = Protocol do
14
13
  understand :foo
15
14
  end
16
15
 
17
- TestProtocol_bar = Protocol do
16
+ ProtocolTest_bar = Protocol do
18
17
  understand :bar
19
18
  end
20
19
 
21
- TestProtocol_foo_bar_1 = Protocol do
22
- include TestProtocol::TestProtocol_foo
20
+ ProtocolTest_foo_bar_1 = Protocol do
21
+ include ProtocolTest::ProtocolTest_foo
23
22
  understand :bar
24
23
  end
25
24
 
26
- TestProtocol_foo_bar_1_fail = Protocol do
27
- include TestProtocol::TestProtocol_foo
25
+ ProtocolTest_foo_bar_1_fail = Protocol do
26
+ include ProtocolTest::ProtocolTest_foo
28
27
  understand :bar
29
28
  end
30
29
 
31
- TestProtocol_foo_bar_2 = Protocol do
32
- include TestProtocol::TestProtocol_foo
33
- include TestProtocol::TestProtocol_bar
30
+ ProtocolTest_foo_bar_2 = Protocol do
31
+ include ProtocolTest::ProtocolTest_foo
32
+ include ProtocolTest::ProtocolTest_bar
34
33
  end
35
34
 
36
- TestProtocol_foo_bar_2_fail = Protocol do
35
+ ProtocolTest_foo_bar_2_fail = Protocol do
37
36
  check_failure :error
38
37
 
39
- include TestProtocol::TestProtocol_foo
40
- include TestProtocol::TestProtocol_bar
38
+ include ProtocolTest::ProtocolTest_foo
39
+ include ProtocolTest::ProtocolTest_bar
41
40
  end
42
41
 
43
- TestProtocolArgs = Protocol do
42
+ ProtocolTestArgs = Protocol do
44
43
  understand :bar, 2
45
44
  understand :baz, 3
46
45
  understand :foo, -1
47
46
  end
48
47
 
49
- TestProtocolArgsOverwritten = Protocol do
50
- include TestProtocol::TestProtocolArgs
48
+ ProtocolTestArgsOverwritten = Protocol do
49
+ include ProtocolTest::ProtocolTestArgs
51
50
 
52
51
  def bar(a, b, c)
53
52
  end
54
-
53
+
55
54
  def foo(a)
56
55
  end
57
56
  end
58
57
 
59
- TestProtocolBlock = Protocol do
58
+ ProtocolTestBlock = Protocol do
60
59
  def foo(x, &block)
61
60
  end
62
61
  end
63
62
 
64
- TestProtocolPartial = Protocol do
63
+ ProtocolTestPartial = Protocol do
65
64
  check_failure :none
66
65
 
67
66
  implementation
@@ -77,7 +76,7 @@ class TestProtocol < Test::Unit::TestCase
77
76
  def each(&block) end
78
77
  end
79
78
 
80
- TestProtocolPartial_fail = Protocol do
79
+ ProtocolTestPartial_fail = Protocol do
81
80
  check_failure :error
82
81
 
83
82
  def each(&block) end
@@ -91,22 +90,22 @@ class TestProtocol < Test::Unit::TestCase
91
90
  end
92
91
  end
93
92
 
94
- TestProtocolWrapMethodPassedFoo = Protocol do
93
+ ProtocolTestWrapMethodPassedFoo = Protocol do
95
94
  def foo(foo, *rest) end
96
95
  end
97
96
 
98
- TestProtocolWrapMethodPassedBar = Protocol do
97
+ ProtocolTestWrapMethodPassedBar = Protocol do
99
98
  def bar() end
100
99
  end
101
100
 
102
- TestProtocolWrapMethod = Protocol do
101
+ ProtocolTestWrapMethod = Protocol do
103
102
  def foo_bar(foo, bar)
104
- ::TestProtocol::TestProtocolWrapMethodPassedFoo =~ foo
105
- ::TestProtocol::TestProtocolWrapMethodPassedBar =~ bar
103
+ ::ProtocolTest::ProtocolTestWrapMethodPassedFoo =~ foo
104
+ ::ProtocolTest::ProtocolTestWrapMethodPassedBar =~ bar
106
105
  end
107
106
  end
108
107
 
109
- TestProtocolPostcondition = Protocol do
108
+ ProtocolTestPostcondition = Protocol do
110
109
  def foo_bar(foo, bar)
111
110
  postcondition { foo + bar == result }
112
111
  end
@@ -116,7 +115,7 @@ class TestProtocol < Test::Unit::TestCase
116
115
  end
117
116
  end
118
117
 
119
- TestProtocolPrecondition = Protocol do
118
+ ProtocolTestPrecondition = Protocol do
120
119
  def foo_bar(foo, bar)
121
120
  precondition { foo == 5 }
122
121
  precondition { bar == 7 }
@@ -127,11 +126,11 @@ class TestProtocol < Test::Unit::TestCase
127
126
  def one_with_block(foo, &block) end
128
127
  end
129
128
 
130
- TestProtocolInheritance = Protocol do
131
- inherit TestProtocol::MyClass, :one_with_block
129
+ ProtocolTestInheritance = Protocol do
130
+ inherit ProtocolTest::MyClass, :one_with_block
132
131
  end
133
132
 
134
- TestProtocolInheritanceC = Protocol do
133
+ ProtocolTestInheritanceC = Protocol do
135
134
  inherit ::Array, :each, true
136
135
  end
137
136
 
@@ -170,46 +169,46 @@ class TestProtocol < Test::Unit::TestCase
170
169
  c1 = Class.new do
171
170
  def foo; end
172
171
 
173
- conform_to TestProtocol_foo
172
+ conform_to ProtocolTest_foo
174
173
  end
175
- assert c1.conform_to?(TestProtocol_foo)
176
- assert c1.new.conform_to?(TestProtocol_foo)
177
- assert !c1.conform_to?(TestProtocol_foo_bar_1)
178
- assert !c1.new.conform_to?(TestProtocol_foo_bar_1)
179
- assert !c1.conform_to?(TestProtocol_bar)
180
- assert !c1.new.conform_to?(TestProtocol_bar)
181
- assert_equal 2, TestProtocol_foo_bar_1.check_failures(Object).size
182
- assert_equal 2, TestProtocol_foo_bar_1.check_failures(Object.new).size
183
- assert_equal 1, TestProtocol_foo_bar_1.check_failures(c1).size
184
- assert_equal 1, TestProtocol_foo_bar_1.check_failures(c1.new).size
174
+ assert c1.conform_to?(ProtocolTest_foo)
175
+ assert c1.new.conform_to?(ProtocolTest_foo)
176
+ assert !c1.conform_to?(ProtocolTest_foo_bar_1)
177
+ assert !c1.new.conform_to?(ProtocolTest_foo_bar_1)
178
+ assert !c1.conform_to?(ProtocolTest_bar)
179
+ assert !c1.new.conform_to?(ProtocolTest_bar)
180
+ assert_equal 2, ProtocolTest_foo_bar_1.check_failures(Object).size
181
+ assert_equal 2, ProtocolTest_foo_bar_1.check_failures(Object.new).size
182
+ assert_equal 1, ProtocolTest_foo_bar_1.check_failures(c1).size
183
+ assert_equal 1, ProtocolTest_foo_bar_1.check_failures(c1.new).size
185
184
 
186
185
  c2 = Class.new do
187
- conform_to TestProtocol_foo
186
+ conform_to ProtocolTest_foo
188
187
  end
189
- assert !c2.conform_to?(TestProtocol_foo)
190
- assert !c2.new.conform_to?(TestProtocol_foo)
191
- assert !c2.conform_to?(TestProtocol_foo_bar_1)
192
- assert !c2.new.conform_to?(TestProtocol_foo_bar_1)
193
- assert !c2.conform_to?(TestProtocol_bar)
194
- assert !c2.new.conform_to?(TestProtocol_bar)
188
+ assert !c2.conform_to?(ProtocolTest_foo)
189
+ assert !c2.new.conform_to?(ProtocolTest_foo)
190
+ assert !c2.conform_to?(ProtocolTest_foo_bar_1)
191
+ assert !c2.new.conform_to?(ProtocolTest_foo_bar_1)
192
+ assert !c2.conform_to?(ProtocolTest_bar)
193
+ assert !c2.new.conform_to?(ProtocolTest_bar)
195
194
  end
196
195
 
197
196
  def test_simple_with_fail
198
197
  c1 = Class.new do
199
198
  def foo; end
200
199
 
201
- conform_to TestProtocol_foo_fail
200
+ conform_to ProtocolTest_foo_fail
202
201
  end
203
- assert c1.conform_to?(TestProtocol_foo_fail)
204
- assert c1.new.conform_to?(TestProtocol_foo_fail)
205
- assert !c1.conform_to?(TestProtocol_foo_bar_1)
206
- assert !c1.new.conform_to?(TestProtocol_foo_bar_1)
207
- assert !c1.conform_to?(TestProtocol_bar)
208
- assert !c1.new.conform_to?(TestProtocol_bar)
202
+ assert c1.conform_to?(ProtocolTest_foo_fail)
203
+ assert c1.new.conform_to?(ProtocolTest_foo_fail)
204
+ assert !c1.conform_to?(ProtocolTest_foo_bar_1)
205
+ assert !c1.new.conform_to?(ProtocolTest_foo_bar_1)
206
+ assert !c1.conform_to?(ProtocolTest_bar)
207
+ assert !c1.new.conform_to?(ProtocolTest_bar)
209
208
 
210
209
  begin
211
210
  c2 = Class.new do
212
- conform_to TestProtocol_foo_fail
211
+ conform_to ProtocolTest_foo_fail
213
212
  end
214
213
  assert(false)
215
214
  rescue Protocol::CheckFailed
@@ -223,7 +222,7 @@ class TestProtocol < Test::Unit::TestCase
223
222
  begin
224
223
  c = Class.new do
225
224
  def bar; end
226
- conform_to TestProtocol_foo_bar_1_fail
225
+ conform_to ProtocolTest_foo_bar_1_fail
227
226
  end
228
227
  assert(false)
229
228
  rescue Protocol::CheckFailed
@@ -237,18 +236,18 @@ class TestProtocol < Test::Unit::TestCase
237
236
  c = Class.new do
238
237
  def foo; end
239
238
  def bar; end
240
- conform_to TestProtocol_foo_bar_1
239
+ conform_to ProtocolTest_foo_bar_1
241
240
  end
242
241
  assert(true)
243
- assert c.conform_to?(TestProtocol_foo_bar_1)
242
+ assert c.conform_to?(ProtocolTest_foo_bar_1)
244
243
  end
245
244
 
246
245
  def test_inclusion3
247
246
  c = Class.new do
248
247
  def bar; end
249
- conform_to TestProtocol_foo_bar_2
248
+ conform_to ProtocolTest_foo_bar_2
250
249
  end
251
- assert !c.conform_to?(TestProtocol_foo_bar_2)
250
+ assert !c.conform_to?(ProtocolTest_foo_bar_2)
252
251
  assert(false)
253
252
  rescue Protocol::CheckFailed
254
253
  assert(true)
@@ -264,10 +263,10 @@ class TestProtocol < Test::Unit::TestCase
264
263
  def foo(*x) x end
265
264
  def baz(x, y, z) Math.sqrt(x * x + y * y + z * z) end
266
265
 
267
- conform_to TestProtocolArgs
266
+ conform_to ProtocolTestArgs
268
267
  end
269
- assert c.conform_to?(TestProtocolArgs)
270
- assert c.new.conform_to?(TestProtocolArgs)
268
+ assert c.conform_to?(ProtocolTestArgs)
269
+ assert c.new.conform_to?(ProtocolTestArgs)
271
270
  rescue
272
271
  assert(false)
273
272
  end
@@ -278,7 +277,7 @@ class TestProtocol < Test::Unit::TestCase
278
277
  def baz(x, y, z) Math.sqrt(x * x + y * y + z * z) end
279
278
  def foo(x) x end
280
279
 
281
- conform_to TestProtocolArgs
280
+ conform_to ProtocolTestArgs
282
281
  end
283
282
  assert(false)
284
283
  rescue Protocol::CheckFailed
@@ -293,7 +292,7 @@ class TestProtocol < Test::Unit::TestCase
293
292
  def baz(x, y, z) Math.sqrt(x * x + y * y + z * z) end
294
293
  def foo(x) x end
295
294
 
296
- conform_to TestProtocolArgs
295
+ conform_to ProtocolTestArgs
297
296
  end
298
297
  rescue Protocol::CheckFailed
299
298
  assert(true)
@@ -306,7 +305,7 @@ class TestProtocol < Test::Unit::TestCase
306
305
  c1 = Class.new do
307
306
  def foo(x) end
308
307
 
309
- conform_to TestProtocolBlock
308
+ conform_to ProtocolTestBlock
310
309
  end
311
310
  rescue Protocol::CheckFailed
312
311
  assert(true)
@@ -316,12 +315,12 @@ class TestProtocol < Test::Unit::TestCase
316
315
  c1b = Class.new do
317
316
  def foo(x) end
318
317
  end
319
- assert !c1b.new.conform_to?(TestProtocolBlock)
318
+ assert !c1b.new.conform_to?(ProtocolTestBlock)
320
319
  begin
321
320
  c2 = Class.new do
322
321
  def foo(x, &block) block[x] end
323
322
 
324
- conform_to TestProtocolBlock
323
+ conform_to ProtocolTestBlock
325
324
  end
326
325
  assert(true)
327
326
  rescue Protocol::CheckFailed
@@ -333,7 +332,7 @@ class TestProtocol < Test::Unit::TestCase
333
332
  c3 = Class.new do
334
333
  def foo(x) yield x end
335
334
 
336
- conform_to TestProtocolBlock
335
+ conform_to ProtocolTestBlock
337
336
  end
338
337
  assert(true)
339
338
  rescue Protocol::CheckFailed
@@ -342,9 +341,9 @@ class TestProtocol < Test::Unit::TestCase
342
341
  assert(false)
343
342
  end
344
343
  obj = Object.new
345
- assert !obj.conform_to?(TestProtocolBlock)
344
+ assert !obj.conform_to?(ProtocolTestBlock)
346
345
  def obj.foo(x, &b) end
347
- assert obj.conform_to?(TestProtocolBlock)
346
+ assert obj.conform_to?(ProtocolTestBlock)
348
347
  end
349
348
 
350
349
  def test_partial_without_fail
@@ -354,19 +353,19 @@ class TestProtocol < Test::Unit::TestCase
354
353
  self
355
354
  end
356
355
 
357
- conform_to TestProtocolPartial
356
+ conform_to ProtocolTestPartial
358
357
  end
359
358
  obj = c1.new
360
- assert c1.conform_to?(TestProtocolPartial)
361
- assert obj.conform_to?(TestProtocolPartial)
359
+ assert c1.conform_to?(ProtocolTestPartial)
360
+ assert obj.conform_to?(ProtocolTestPartial)
362
361
  assert_equal [ 1, 4, 9], obj.map { |x| x * x }
363
362
  assert_equal obj, obj.each { |x| x * x }
364
363
 
365
364
  c2 = Class.new do
366
- conform_to TestProtocolPartial
365
+ conform_to ProtocolTestPartial
367
366
  end
368
- assert !c2.conform_to?(TestProtocolPartial)
369
- assert !c2.new.conform_to?(TestProtocolPartial)
367
+ assert !c2.conform_to?(ProtocolTestPartial)
368
+ assert !c2.new.conform_to?(ProtocolTestPartial)
370
369
  assert_raises(NoMethodError) { c2.new.map { |x| x * x } }
371
370
  assert_equal obj, obj.each { |x| x * x }
372
371
  end
@@ -378,17 +377,17 @@ class TestProtocol < Test::Unit::TestCase
378
377
  self
379
378
  end
380
379
 
381
- conform_to TestProtocolPartial_fail
380
+ conform_to ProtocolTestPartial_fail
382
381
  end
383
382
  obj = c1.new
384
- assert c1.conform_to?(TestProtocolPartial)
385
- assert obj.conform_to?(TestProtocolPartial)
383
+ assert c1.conform_to?(ProtocolTestPartial)
384
+ assert obj.conform_to?(ProtocolTestPartial)
386
385
  assert_equal [ 1, 4, 9], obj.map { |x| x * x }
387
386
  assert_equal obj, obj.each { |x| x * x }
388
387
 
389
388
  begin
390
389
  c2 = Class.new do
391
- conform_to TestProtocolPartial_fail
390
+ conform_to ProtocolTestPartial_fail
392
391
  end
393
392
  assert(false)
394
393
  rescue Protocol::CheckFailed
@@ -404,9 +403,9 @@ class TestProtocol < Test::Unit::TestCase
404
403
  def baz(x, y, z) Math.sqrt(x * x + y * y + z * z) end
405
404
  def foo(x) x end
406
405
 
407
- conform_to TestProtocolArgsOverwritten
406
+ conform_to ProtocolTestArgsOverwritten
408
407
  end
409
- assert c.conform_to?(TestProtocolArgsOverwritten)
408
+ assert c.conform_to?(ProtocolTestArgsOverwritten)
410
409
  rescue Protocol::CheckFailed
411
410
  assert(false)
412
411
  rescue
@@ -414,12 +413,12 @@ class TestProtocol < Test::Unit::TestCase
414
413
  end
415
414
 
416
415
  def test_messages
417
- assert_equal %w[bar baz foo], TestProtocolArgs.messages.map { |x| x.name }
418
- assert_equal [2, 3, -1], TestProtocolArgs.messages.map { |x| x.arity }
419
- assert_equal "TestProtocol::TestProtocolArgs#bar(2), TestProtocol::TestProtocolArgs#baz(3), TestProtocol::TestProtocolArgs#foo(-1)", TestProtocolArgs.to_s
420
- assert_equal %w[bar baz foo], TestProtocolArgsOverwritten.messages.map { |x| x.name }
421
- assert_equal [3, 3, 1], TestProtocolArgsOverwritten.messages.map { |x| x.arity }
422
- assert_equal "TestProtocol::TestProtocolArgsOverwritten#bar(3), TestProtocol::TestProtocolArgs#baz(3), TestProtocol::TestProtocolArgsOverwritten#foo(1)", TestProtocolArgsOverwritten.to_s
416
+ assert_equal %w[bar baz foo], ProtocolTestArgs.messages.map { |x| x.name }
417
+ assert_equal [2, 3, -1], ProtocolTestArgs.messages.map { |x| x.arity }
418
+ assert_equal "ProtocolTest::ProtocolTestArgs#bar(2), ProtocolTest::ProtocolTestArgs#baz(3), ProtocolTest::ProtocolTestArgs#foo(-1)", ProtocolTestArgs.to_s
419
+ assert_equal %w[bar baz foo], ProtocolTestArgsOverwritten.messages.map { |x| x.name }
420
+ assert_equal [3, 3, 1], ProtocolTestArgsOverwritten.messages.map { |x| x.arity }
421
+ assert_equal "ProtocolTest::ProtocolTestArgsOverwritten#bar(3), ProtocolTest::ProtocolTestArgs#baz(3), ProtocolTest::ProtocolTestArgsOverwritten#foo(1)", ProtocolTestArgsOverwritten.to_s
423
422
  end
424
423
 
425
424
  def test_wrapped_method
@@ -427,7 +426,7 @@ class TestProtocol < Test::Unit::TestCase
427
426
  c1 = Class.new do
428
427
  def foo(foo, *rest) foo end
429
428
 
430
- conform_to TestProtocolWrapMethodPassedFoo
429
+ conform_to ProtocolTestWrapMethodPassedFoo
431
430
  end
432
431
  assert(true)
433
432
  rescue Protocol::CheckFailed
@@ -439,7 +438,7 @@ class TestProtocol < Test::Unit::TestCase
439
438
  c2 = Class.new do
440
439
  def bar() :bar end
441
440
 
442
- conform_to TestProtocolWrapMethodPassedBar
441
+ conform_to ProtocolTestWrapMethodPassedBar
443
442
  end
444
443
  assert(true)
445
444
  rescue Protocol::CheckFailed
@@ -453,7 +452,7 @@ class TestProtocol < Test::Unit::TestCase
453
452
  [ foo.foo(:foo, :baz), bar.bar ]
454
453
  end
455
454
 
456
- conform_to TestProtocolWrapMethod
455
+ conform_to ProtocolTestWrapMethod
457
456
  end
458
457
  assert(true)
459
458
  rescue Protocol::CheckFailed
@@ -485,7 +484,7 @@ class TestProtocol < Test::Unit::TestCase
485
484
  foo + bar
486
485
  end
487
486
 
488
- conform_to TestProtocolPrecondition
487
+ conform_to ProtocolTestPrecondition
489
488
  end
490
489
  assert(true)
491
490
  rescue Protocol::CheckFailed
@@ -508,7 +507,7 @@ class TestProtocol < Test::Unit::TestCase
508
507
  bars.unshift foo
509
508
  end
510
509
 
511
- conform_to TestProtocolPostcondition
510
+ conform_to ProtocolTestPostcondition
512
511
  end
513
512
  c2 = Class.new do
514
513
  def foo_bar(foo, bar)
@@ -519,7 +518,7 @@ class TestProtocol < Test::Unit::TestCase
519
518
  bars.unshift foo
520
519
  end
521
520
 
522
- conform_to TestProtocolPostcondition
521
+ conform_to ProtocolTestPostcondition
523
522
  end
524
523
  assert(true)
525
524
  rescue Protocol::CheckFailed
@@ -538,7 +537,7 @@ class TestProtocol < Test::Unit::TestCase
538
537
  def o1.foo_bars(foo, *bars)
539
538
  bars.unshift foo
540
539
  end
541
- assert TestProtocolPostcondition =~ o1
540
+ assert ProtocolTestPostcondition =~ o1
542
541
  assert_equal [5, 7], o1.foo_bars(5, 7)
543
542
  assert_equal 5 + 7, o1.foo_bar(5, 7)
544
543
  o2 = Object.new
@@ -548,7 +547,7 @@ class TestProtocol < Test::Unit::TestCase
548
547
  def o2.foo_bars(foo, *bars)
549
548
  bars.unshift foo
550
549
  end
551
- assert TestProtocolPostcondition =~ o2
550
+ assert ProtocolTestPostcondition =~ o2
552
551
  assert_equal [5, 7], o2.foo_bars(5, 7)
553
552
  assert_raises(Protocol::PostconditionCheckError) { o2.foo_bar(5, 7) }
554
553
  end
@@ -556,7 +555,7 @@ class TestProtocol < Test::Unit::TestCase
556
555
  def test_inheritance
557
556
  begin
558
557
  c1 = Class.new do
559
- conform_to TestProtocolInheritance
558
+ conform_to ProtocolTestInheritance
560
559
  end
561
560
  rescue Protocol::CheckFailed
562
561
  assert(true)
@@ -566,7 +565,7 @@ class TestProtocol < Test::Unit::TestCase
566
565
  begin
567
566
  c2 = Class.new do
568
567
  def one_with_block() end
569
- conform_to TestProtocolInheritance
568
+ conform_to ProtocolTestInheritance
570
569
  end
571
570
  rescue Protocol::CheckFailed
572
571
  assert(true)
@@ -576,7 +575,7 @@ class TestProtocol < Test::Unit::TestCase
576
575
  begin
577
576
  c3 = Class.new do
578
577
  def one_with_block(foo) end
579
- conform_to TestProtocolInheritance
578
+ conform_to ProtocolTestInheritance
580
579
  end
581
580
  rescue Protocol::CheckFailed
582
581
  assert(true)
@@ -586,7 +585,7 @@ class TestProtocol < Test::Unit::TestCase
586
585
  begin
587
586
  c4 = Class.new do
588
587
  def one_with_block(foo, &block) end
589
- conform_to TestProtocolInheritance
588
+ conform_to ProtocolTestInheritance
590
589
  end
591
590
  assert(true)
592
591
  rescue Protocol::CheckFailed
@@ -597,7 +596,7 @@ class TestProtocol < Test::Unit::TestCase
597
596
  begin
598
597
  c5 = Class.new do
599
598
  def each() end
600
- conform_to TestProtocolInheritanceC
599
+ conform_to ProtocolTestInheritanceC
601
600
  end
602
601
  rescue Protocol::CheckFailed
603
602
  assert(true)
@@ -607,7 +606,7 @@ class TestProtocol < Test::Unit::TestCase
607
606
  begin
608
607
  c6 = Class.new do
609
608
  def each(&block) end
610
- conform_to TestProtocolInheritanceC
609
+ conform_to ProtocolTestInheritanceC
611
610
  end
612
611
  assert(true)
613
612
  rescue Protocol::CheckFailed
@@ -0,0 +1,8 @@
1
+ if ENV['START_SIMPLECOV'].to_i == 1
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter "#{File.basename(File.dirname(__FILE__))}/"
5
+ end
6
+ end
7
+ require 'test/unit'
8
+ require 'protocol'