protocol 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/protocol/core.rb CHANGED
@@ -20,3 +20,27 @@ Enumerating = Protocol do
20
20
 
21
21
  include Enumerable
22
22
  end
23
+
24
+ # Checks if indexing behaviour exists as in Array or Hash.
25
+ Indexing = Protocol do
26
+ understand :[]
27
+
28
+ understand :[]=
29
+ end
30
+
31
+ Synchronizing = Protocol do
32
+ def lock() end
33
+
34
+ def unlock() end
35
+
36
+ implementation
37
+
38
+ def synchronize
39
+ lock
40
+ begin
41
+ yield
42
+ ensure
43
+ unlock
44
+ end
45
+ end
46
+ end
@@ -167,13 +167,6 @@ module Protocol
167
167
  result = __send__('#{inner_name}', #{args} &block)
168
168
  end
169
169
  result
170
- rescue Protocol::CheckError => e
171
- case ObjectSpace._id2ref(#{__id__}).protocol.mode
172
- when :error
173
- raise e
174
- when :warning
175
- warn e
176
- end
177
170
  ensure
178
171
  Thread.current[post_name].pop
179
172
  Thread.current[post_name].empty? and
@@ -3,14 +3,11 @@ module Protocol
3
3
  class ProtocolModule < Module
4
4
  # Creates an new ProtocolModule instance.
5
5
  def initialize(&block)
6
- @descriptor = Descriptor.new(self)
7
- @mode = :error
8
- module_eval(&block)
6
+ @descriptor = Descriptor.new(self)
7
+ @implementation = false
8
+ block and module_eval(&block)
9
9
  end
10
10
 
11
- # The current check mode :none, :warning, or :error (the default).
12
- attr_reader :mode
13
-
14
11
  # Returns all the protocol descriptions to check against as an Array.
15
12
  def descriptors
16
13
  descriptors = []
@@ -30,7 +27,6 @@ module Protocol
30
27
  # generic argument names.
31
28
  def to_ruby(result = '')
32
29
  result << "#{name} = Protocol do"
33
- first = true
34
30
  if messages.empty?
35
31
  result << "\n"
36
32
  else
@@ -129,39 +125,38 @@ module Protocol
129
125
  "#<#{name}: #{messages.map { |m| m.shortcut } * ', '}>"
130
126
  end
131
127
 
132
- # Check the conformity of +object+ recursively. This method returns either
133
- # false OR true, if +mode+ is :none or :warning, or raises an
134
- # CheckFailed, if +mode+ was :error.
135
- def check(object, mode = @mode)
128
+ # Check the conformity of +object+ recursively and raise an exception if it
129
+ # doesn't.
130
+ def check!(object)
136
131
  checked = {}
137
- result = true
138
132
  errors = CheckFailed.new
139
133
  each do |message|
140
134
  begin
141
135
  message.check(object, checked)
142
136
  rescue CheckError => e
143
- case mode
144
- when :error
145
- errors << e
146
- when :warning
147
- warn e.to_s
148
- result = false
149
- when :none
150
- result = false
151
- end
137
+ errors << e
152
138
  end
153
139
  end
154
- raise errors unless errors.empty?
155
- result
140
+ errors.empty? or raise errors
141
+ true
156
142
  end
157
143
 
158
- alias =~ check
144
+ alias =~ check!
145
+
146
+ # Check the conformity of +object+ recursively and return true iff it does.
147
+ def check(object)
148
+ check!(object)
149
+ rescue CheckFailed
150
+ false
151
+ else
152
+ true
153
+ end
159
154
 
160
155
  # Return all messages for whick a check failed.
161
156
  def check_failures(object)
162
- check object
157
+ check!(object)
163
158
  rescue CheckFailed => e
164
- return e.errors.map { |e| e.protocol_message }
159
+ e.errors.map { |e| e.protocol_message }
165
160
  end
166
161
 
167
162
  # This callback is called, when a module, that was extended with Protocol,
@@ -173,32 +168,19 @@ module Protocol
173
168
  # the Protocol
174
169
  # module.
175
170
  def included(modul)
176
- super
177
- if modul.is_a? Class and @mode == :error or @mode == :warning
178
- $DEBUG and warn "#{name} is checking class #{modul}"
179
- check modul
171
+ result = super
172
+ if modul.is_a? Class
173
+ check! modul
180
174
  end
175
+ result
181
176
  end
182
177
 
183
178
  def extend_object(object)
184
179
  result = super
185
- if @mode == :error or @mode == :warning
186
- $DEBUG and warn "#{name} is checking class #{object}"
187
- check object
188
- end
180
+ check! object
189
181
  result
190
182
  end
191
183
 
192
- # Sets the check mode to +id+. +id+ should be one of :none, :warning, or
193
- # :error. The mode to use while doing a conformity check is always the root
194
- # module, that is, the modes of the included modules aren't important for
195
- # the check.
196
- def check_failure(mode)
197
- CHECK_MODES.include?(mode) or
198
- raise ArgumentError, "illegal check mode #{mode}"
199
- @mode = mode
200
- end
201
-
202
184
  # This method defines one of the messages, the protocol in question
203
185
  # consists of: The messages which the class, that conforms to this
204
186
  # protocol, should understand and respond to. An example shows best
@@ -226,12 +208,12 @@ module Protocol
226
208
  end
227
209
  private :parse_instance_method_signature
228
210
 
229
- # Inherit a method signature from an instance method named +methodname+ of
211
+ # Infer a method signature from an instance method named +methodname+ of
230
212
  # +modul+. This means that this protocol should understand these instance
231
213
  # methods with their arity and block expectation. Note that automatic
232
214
  # detection of blocks does not work for Ruby methods defined in C. You can
233
215
  # set the +block_expected+ argument if you want to do this manually.
234
- def inherit(modul, methodname, block_expected = nil)
216
+ def infer(modul, methodname = modul.public_instance_methods(false), block_expected = nil)
235
217
  Module === modul or
236
218
  raise TypeError, "expected Module not #{modul.class} as modul argument"
237
219
  methodnames = methodname.respond_to?(:to_ary) ?
@@ -254,7 +236,7 @@ module Protocol
254
236
  # Return true, if the ProtocolModule is currently in implementation mode.
255
237
  # Otherwise return false.
256
238
  def implementation?
257
- !!@implementation
239
+ @implementation
258
240
  end
259
241
 
260
242
  # Switch to specification mode. Defined methods are added to the protocol
@@ -1,6 +1,6 @@
1
1
  module Protocol
2
2
  # Protocol version
3
- VERSION = '1.0.1'
3
+ VERSION = '2.0.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/lib/protocol/xt.rb CHANGED
@@ -6,17 +6,22 @@ module Protocol
6
6
  # :none or :warning, and conformance of a class to a protocol should be
7
7
  # checked later in runtime.
8
8
  def conform_to?(protocol)
9
- protocol.check(self, :none)
9
+ protocol.check(self)
10
10
  end
11
11
 
12
- def conform_to!(protocol)
12
+ def conform_to(protocol)
13
13
  extend(protocol)
14
14
  end
15
15
 
16
16
  # Define a protocol configured by +block+. Look at the methods of
17
17
  # ProtocolModule to get an idea on how to do that.
18
- def Protocol(&block)
19
- ProtocolModule.new(&block)
18
+ def Protocol(modul = nil, &block)
19
+ pm = ProtocolModule.new(&block)
20
+ if modul
21
+ pm.infer(modul)
22
+ else
23
+ pm
24
+ end
20
25
  end
21
26
 
22
27
  alias protocol Protocol
@@ -35,7 +40,7 @@ module Protocol
35
40
  # :none or :warning, and conformance of a class to a protocol should be
36
41
  # checked later in runtime.
37
42
  def conform_to?(protocol)
38
- protocol.check(self, :none)
43
+ protocol.check(self)
39
44
  end
40
45
  end
41
46
  end
data/protocol.gemspec CHANGED
@@ -1,39 +1,43 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: protocol 2.0.0 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
- s.name = "protocol"
5
- s.version = "1.0.1"
5
+ s.name = "protocol".freeze
6
+ s.version = "2.0.0"
6
7
 
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-19"
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.licenses = ["GPL-2"]
16
- s.rdoc_options = ["--title", "Protocol - Method Protocols for Ruby Classes", "--main", "README.rdoc"]
17
- s.require_paths = ["lib"]
18
- s.rubygems_version = "2.0.4"
19
- s.summary = "Method Protocols for Ruby Classes"
20
- s.test_files = ["tests/protocol_method_parser_test.rb", "tests/protocol_test.rb", "tests/test_helper.rb"]
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib".freeze]
10
+ s.authors = ["Florian Frank".freeze]
11
+ s.date = "2019-11-05"
12
+ 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".freeze
13
+ s.email = "flori@ping.de".freeze
14
+ s.extra_rdoc_files = ["README.rdoc".freeze, "lib/protocol.rb".freeze, "lib/protocol/core.rb".freeze, "lib/protocol/descriptor.rb".freeze, "lib/protocol/errors.rb".freeze, "lib/protocol/message.rb".freeze, "lib/protocol/method_parser/ruby_parser.rb".freeze, "lib/protocol/post_condition.rb".freeze, "lib/protocol/protocol_module.rb".freeze, "lib/protocol/utilities.rb".freeze, "lib/protocol/version.rb".freeze, "lib/protocol/xt.rb".freeze]
15
+ s.files = [".gitignore".freeze, ".travis.yml".freeze, ".utilsrc".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.rdoc".freeze, "Rakefile".freeze, "VERSION".freeze, "benchmarks/data/.keep".freeze, "benchmarks/method_parser.rb".freeze, "examples/assignments.rb".freeze, "examples/comparing.rb".freeze, "examples/enumerating.rb".freeze, "examples/game.rb".freeze, "examples/hello_world_patternitis.rb".freeze, "examples/indexing.rb".freeze, "examples/queue.rb".freeze, "examples/stack.rb".freeze, "examples/synchronizing.rb".freeze, "install.rb".freeze, "lib/protocol.rb".freeze, "lib/protocol/core.rb".freeze, "lib/protocol/descriptor.rb".freeze, "lib/protocol/errors.rb".freeze, "lib/protocol/message.rb".freeze, "lib/protocol/method_parser/ruby_parser.rb".freeze, "lib/protocol/post_condition.rb".freeze, "lib/protocol/protocol_module.rb".freeze, "lib/protocol/utilities.rb".freeze, "lib/protocol/version.rb".freeze, "lib/protocol/xt.rb".freeze, "protocol.gemspec".freeze, "tests/protocol_core_test.rb".freeze, "tests/protocol_method_parser_test.rb".freeze, "tests/protocol_test.rb".freeze, "tests/test_helper.rb".freeze]
16
+ s.homepage = "http://flori.github.com/protocol".freeze
17
+ s.licenses = ["GPL-2".freeze]
18
+ s.rdoc_options = ["--title".freeze, "Protocol - Method Protocols for Ruby Classes".freeze, "--main".freeze, "README.rdoc".freeze]
19
+ s.rubygems_version = "3.0.6".freeze
20
+ s.summary = "Method Protocols for Ruby Classes".freeze
21
+ s.test_files = ["tests/protocol_core_test.rb".freeze, "tests/protocol_method_parser_test.rb".freeze, "tests/protocol_test.rb".freeze, "tests/test_helper.rb".freeze]
21
22
 
22
23
  if s.respond_to? :specification_version then
23
24
  s.specification_version = 4
24
25
 
25
26
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<gem_hadar>, ["~> 0.3.2"])
27
- s.add_development_dependency(%q<simplecov>, [">= 0"])
28
- s.add_runtime_dependency(%q<ruby_parser>, ["~> 3.0"])
27
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
28
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
29
+ s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
30
+ s.add_runtime_dependency(%q<ruby_parser>.freeze, ["~> 3.0"])
29
31
  else
30
- s.add_dependency(%q<gem_hadar>, ["~> 0.3.2"])
31
- s.add_dependency(%q<simplecov>, [">= 0"])
32
- s.add_dependency(%q<ruby_parser>, ["~> 3.0"])
32
+ s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
33
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
34
+ s.add_dependency(%q<test-unit>.freeze, [">= 0"])
35
+ s.add_dependency(%q<ruby_parser>.freeze, ["~> 3.0"])
33
36
  end
34
37
  else
35
- s.add_dependency(%q<gem_hadar>, ["~> 0.3.2"])
36
- s.add_dependency(%q<simplecov>, [">= 0"])
37
- s.add_dependency(%q<ruby_parser>, ["~> 3.0"])
38
+ s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
39
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
40
+ s.add_dependency(%q<test-unit>.freeze, [">= 0"])
41
+ s.add_dependency(%q<ruby_parser>.freeze, ["~> 3.0"])
38
42
  end
39
43
  end
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test_helper'
4
+ require 'protocol/core'
5
+
6
+ class ProtocolCoreTest < Test::Unit::TestCase
7
+ def test_comparing_numeric
8
+ assert Numeric.conform_to?(Comparing)
9
+ end
10
+
11
+ def test_comparing_complex
12
+ assert_false Complex.conform_to?(Comparing)
13
+ end
14
+
15
+ def test_comparing_array
16
+ assert Array.conform_to?(Comparing)
17
+ end
18
+
19
+ def test_comparing_string
20
+ assert String.conform_to?(Comparing)
21
+ end
22
+
23
+ def test_enumerating_array
24
+ assert Array.conform_to?(Enumerating)
25
+ end
26
+
27
+ def test_enumerating_float
28
+ assert_false Float.conform_to?(Enumerating)
29
+ end
30
+
31
+ def test_enumerating_hash
32
+ assert Hash.conform_to?(Enumerating)
33
+ end
34
+
35
+ def test_indexing_array
36
+ assert Array.conform_to?(Indexing)
37
+ end
38
+
39
+ def test_indexing_proc
40
+ assert_false Proc.conform_to?(Indexing)
41
+ end
42
+
43
+ def test_indexing_hash
44
+ assert Hash.conform_to?(Indexing)
45
+ end
46
+
47
+ def test_sychronizing_mutex
48
+ assert Mutex.conform_to?(Synchronizing)
49
+ end
50
+
51
+ def test_sychronizing_hash
52
+ assert_false Hash.conform_to?(Synchronizing)
53
+ end
54
+
55
+ def test_my_synchronizer
56
+ s = Class.new do
57
+ def initialize
58
+ @lock = false
59
+ end
60
+
61
+ def lock
62
+ @lock = true
63
+ end
64
+
65
+ def locked?
66
+ @lock
67
+ end
68
+
69
+ def unlock
70
+ @lock = false
71
+ end
72
+
73
+ conform_to Synchronizing
74
+ end.new
75
+ assert_false s.locked?
76
+ s.synchronize { assert s.locked? }
77
+ assert_false s.locked?
78
+ end
79
+ end
@@ -52,94 +52,95 @@ class ProtocolMethodParserTest < Test::Unit::TestCase
52
52
 
53
53
  def complex_end
54
54
  a = :end
55
- foo { }
55
+ foo() { }
56
+ a
56
57
  end
57
58
 
58
59
  def complex
59
- foo { }
60
+ foo() { }
60
61
  end
61
62
  end
62
63
 
63
64
  def test_args
64
65
  m = :empty; mp = MethodParser.new(A, m)
65
- assert_equal 0, mp.arity, "arity failed for A##{m}"
66
- assert_equal [ ], mp.args, "args failed for A##{m}"
67
- assert_equal [ ], mp.arg_kinds, "args failed for A##{m}"
66
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
67
+ assert_equal([ ], mp.args, "args failed for A##{m}")
68
+ assert_equal([ ], mp.arg_kinds, "args failed for A##{m}")
68
69
  assert !mp.complex?
69
70
  m = :none; mp = MethodParser.new(A, m)
70
- assert_equal 0, mp.arity, "arity failed for A##{m}"
71
- assert_equal [ ], mp.args, "args failed for A##{m}"
72
- assert_equal [ ], mp.arg_kinds, "args failed for A##{m}"
71
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
72
+ assert_equal([ ], mp.args, "args failed for A##{m}")
73
+ assert_equal([ ], mp.arg_kinds, "args failed for A##{m}")
73
74
  assert !mp.complex?
74
75
  m = :one_req; mp = MethodParser.new(A, m)
75
- assert_equal 1, mp.arity, "arity failed for A##{m}"
76
- assert_equal [ :a ], mp.args, "args failed for A##{m}"
77
- assert_equal [ :req ], mp.arg_kinds, "args failed for A##{m}"
76
+ assert_equal(1, mp.arity, "arity failed for A##{m}")
77
+ assert_equal([ :a ], mp.args, "args failed for A##{m}")
78
+ assert_equal([ :req ], mp.arg_kinds, "args failed for A##{m}")
78
79
  assert !mp.complex?
79
80
  m = :two_req; mp = MethodParser.new(A, m)
80
- assert_equal 2, mp.arity, "arity failed for A##{m}"
81
- assert_equal [ :req, :req ], mp.arg_kinds, "args failed for A##{m}"
82
- assert_equal [ :a, :b ], mp.args, "args failed for A##{m}"
81
+ assert_equal(2, mp.arity, "arity failed for A##{m}")
82
+ assert_equal([ :req, :req ], mp.arg_kinds, "args failed for A##{m}")
83
+ assert_equal([ :a, :b ], mp.args, "args failed for A##{m}")
83
84
  assert !mp.complex?
84
85
  m = :one_req_one_opt; mp = MethodParser.new(A, m)
85
- assert_equal -2, mp.arity, "arity failed for A##{m}"
86
- assert_equal [ :a, :b ], mp.args, "args failed for A##{m}"
87
- assert_equal [ :req, :opt ], mp.arg_kinds, "args failed for A##{m}"
86
+ assert_equal(-2, mp.arity, "arity failed for A##{m}")
87
+ assert_equal([ :a, :b ], mp.args, "args failed for A##{m}")
88
+ assert_equal([ :req, :opt ], mp.arg_kinds, "args failed for A##{m}")
88
89
  assert !mp.complex?
89
90
  m = :one_opt; mp = MethodParser.new(A, m)
90
- assert_equal -1, mp.arity, "arity failed for A##{m}"
91
- assert_equal [ :a ], mp.args, "args failed for A##{m}"
92
- assert_equal [ :opt ], mp.arg_kinds, "args failed for A##{m}"
91
+ assert_equal(-1, mp.arity, "arity failed for A##{m}")
92
+ assert_equal([ :a ], mp.args, "args failed for A##{m}")
93
+ assert_equal([ :opt ], mp.arg_kinds, "args failed for A##{m}")
93
94
  assert !mp.complex?
94
95
  m = :two_opt; mp = MethodParser.new(A, m)
95
- assert_equal -1, mp.arity, "arity failed for A##{m}"
96
- assert_equal [ :a, :b ], mp.args, "args failed for A##{m}"
97
- assert_equal [ :opt, :opt ], mp.arg_kinds, "args failed for A##{m}"
96
+ assert_equal(-1, mp.arity, "arity failed for A##{m}")
97
+ assert_equal([ :a, :b ], mp.args, "args failed for A##{m}")
98
+ assert_equal([ :opt, :opt ], mp.arg_kinds, "args failed for A##{m}")
98
99
  assert !mp.complex?
99
100
  m = :one_req_rest; mp = MethodParser.new(A, m)
100
- assert_equal -2, mp.arity, "arity failed for A##{m}"
101
- assert_equal [ :a, :'*b' ], mp.args, "args failed for A##{m}"
102
- assert_equal [ :req, :rest ], mp.arg_kinds, "args failed for A##{m}"
101
+ assert_equal(-2, mp.arity, "arity failed for A##{m}")
102
+ assert_equal([ :a, :'*b' ], mp.args, "args failed for A##{m}")
103
+ assert_equal([ :req, :rest ], mp.arg_kinds, "args failed for A##{m}")
103
104
  assert !mp.complex?
104
105
  m = :one_opt_rest; mp = MethodParser.new(A, m)
105
- assert_equal -1, mp.arity, "arity failed for A##{m}"
106
- assert_equal [ :a, :'*b' ], mp.args, "args failed for A##{m}"
107
- assert_equal [ :opt, :rest ], mp.arg_kinds, "args failed for A##{m}"
106
+ assert_equal(-1, mp.arity, "arity failed for A##{m}")
107
+ assert_equal([ :a, :'*b' ], mp.args, "args failed for A##{m}")
108
+ assert_equal([ :opt, :rest ], mp.arg_kinds, "args failed for A##{m}")
108
109
  assert !mp.complex?
109
110
  m = :block; mp = MethodParser.new(A, m)
110
- assert_equal 0, mp.arity, "arity failed for A##{m}"
111
- assert_equal [ :'&b' ], mp.args, "args failed for A##{m}"
112
- assert_equal [ :block ], mp.arg_kinds, "args failed for A##{m}"
111
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
112
+ assert_equal([ :'&b' ], mp.args, "args failed for A##{m}")
113
+ assert_equal([ :block ], mp.arg_kinds, "args failed for A##{m}")
113
114
  assert !mp.complex?
114
115
  m = :one_req_block; mp = MethodParser.new(A, m)
115
- assert_equal 1, mp.arity, "arity failed for A##{m}"
116
- assert_equal [ :a, :'&b' ], mp.args, "args failed for A##{m}"
117
- assert_equal [ :req, :block ], mp.arg_kinds, "args failed for A##{m}"
116
+ assert_equal(1, mp.arity, "arity failed for A##{m}")
117
+ assert_equal([ :a, :'&b' ], mp.args, "args failed for A##{m}")
118
+ assert_equal([ :req, :block ], mp.arg_kinds, "args failed for A##{m}")
118
119
  assert !mp.complex?
119
120
  m = :one_opt_block; mp = MethodParser.new(A, m)
120
- assert_equal -1, mp.arity, "arity failed for A##{m}"
121
- assert_equal [ :a, :'&b' ], mp.args, "args failed for A##{m}"
122
- assert_equal [ :opt, :block ], mp.arg_kinds, "args failed for A##{m}"
121
+ assert_equal(-1, mp.arity, "arity failed for A##{m}")
122
+ assert_equal([ :a, :'&b' ], mp.args, "args failed for A##{m}")
123
+ assert_equal([ :opt, :block ], mp.arg_kinds, "args failed for A##{m}")
123
124
  assert !mp.complex?
124
125
  m = :yield_block; mp = MethodParser.new(A, m)
125
- assert_equal 0, mp.arity, "arity failed for A##{m}"
126
- assert_equal [ :'&b' ], mp.args, "args failed for A##{m}"
127
- assert_equal [ :block ], mp.arg_kinds, "args failed for A##{m}"
126
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
127
+ assert_equal([ :'&b' ], mp.args, "args failed for A##{m}")
128
+ assert_equal([ :block ], mp.arg_kinds, "args failed for A##{m}")
128
129
  assert !mp.complex?
129
130
  m = :yield; mp = MethodParser.new(A, m)
130
- assert_equal 0, mp.arity, "arity failed for A##{m}"
131
- assert_equal [ :'&block' ], mp.args, "args failed for A##{m}"
132
- assert_equal [ :block ], mp.arg_kinds, "args failed for A##{m}"
131
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
132
+ assert_equal([ :'&block' ], mp.args, "args failed for A##{m}")
133
+ assert_equal([ :block ], mp.arg_kinds, "args failed for A##{m}")
133
134
  assert !mp.complex?
134
135
  m = :complex_end; mp = MethodParser.new(A, m)
135
- assert_equal 0, mp.arity, "arity failed for A##{m}"
136
- assert_equal [ ], mp.args, "args failed for A##{m}"
137
- assert_equal [ ], mp.arg_kinds, "args failed for A##{m}"
136
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
137
+ assert_equal([ ], mp.args, "args failed for A##{m}")
138
+ assert_equal([ ], mp.arg_kinds, "args failed for A##{m}")
138
139
  assert mp.complex?
139
140
  m = :complex; mp = MethodParser.new(A, m)
140
- assert_equal 0, mp.arity, "arity failed for A##{m}"
141
- assert_equal [ ], mp.args, "args failed for A##{m}"
142
- assert_equal [ ], mp.arg_kinds, "args failed for A##{m}"
141
+ assert_equal(0, mp.arity, "arity failed for A##{m}")
142
+ assert_equal([ ], mp.args, "args failed for A##{m}")
143
+ assert_equal([ ], mp.arg_kinds, "args failed for A##{m}")
143
144
  assert mp.complex?
144
145
  end
145
146
  end