iba 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa34cf98d021bff67ebed44e9b62e2445c34793422660c0e221b06ca641c722d
4
- data.tar.gz: c23f48c6e815351c9181efb572c98e0849e87d3c35a8b922fad6581e87090157
3
+ metadata.gz: bc9ef58cc2d18bc4e74c789ebed62265cee83bfaf45ee7a7c5e21d2d73c216ca
4
+ data.tar.gz: cbae41b9fae66df4aa717008627d1478d54e4cc61a90d48371460a23357d4dee
5
5
  SHA512:
6
- metadata.gz: 992248f06af84ad50da540697617ce9980acc400adbf8fe1df08965d54345bd335a98c8071ec8e32920fb1454ae0820dbe74b7b32322125b8769a3d611c93b82
7
- data.tar.gz: 4ae83722fa833dd949a6b0ec254f395afbe2bed6fcd26d92cb919932f2c5f8bb101dcce3bcf9082df188a5019e97ceb7348dd4f956bc9e36076983e6970b43e6
6
+ metadata.gz: 7ba511885b585a67f8a8dec3b0792c2fd4bc63fd2e575580d22f9b1dab158b7f6e87ea32244ddb5461d2a36d3fcc8eb362c5944b28990728295e52f5ea192797
7
+ data.tar.gz: 9ef4e73638d5fe567b0ae77a0ac031b3772c71353287aa5fea8a6d3cfd960fb1a1d5b18ca36dd6d8547abeeeaf0b2037b1357b4556c2d55adf4329702910a295
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Iba
4
+ VERSION = "0.0.6"
5
+ end
data/lib/iba.rb CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "iba/version"
4
+
1
5
  module Iba
2
6
  class Combinator
3
- def initialize &blk
7
+ def initialize(&blk)
4
8
  @block = blk
5
9
  end
6
10
 
@@ -17,38 +21,24 @@ module Iba
17
21
  end
18
22
 
19
23
  def analyse
20
- str = "#{self} is #{call.inspect}"
21
- if expression.class == MethodCallExpression && expression._method == :==
22
- lft = expression._reciever
23
- rgt = expression._args.first
24
- exprs = [lft, rgt].map { |e| display_subexpression e }.compact
25
- str << "\n"
26
- str << exprs.join(', ')
27
- end
24
+ str = +"#{self} is #{call.inspect}"
25
+ sub = expression._display_subexpressions(@block.binding)
26
+ str << "\n#{sub}" if sub
28
27
  str
29
28
  end
30
-
31
- private
32
-
33
- def display_subexpression expr
34
- if expr.class == LiteralExpression
35
- nil
36
- else
37
- str = expr._to_s
38
- value = expr._evaluate(@block.binding).inspect
39
- "#{str} is #{value}"
40
- end
41
- end
42
29
  end
43
30
 
44
31
  class BaseExpression
45
- def method_missing method, *args
46
- super if method.to_s =~ /^_/
32
+ def method_missing(method, *args)
33
+ # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
34
+ super if method.to_s.start_with? "_"
47
35
  MethodCallExpression.new self, method, args
48
36
  end
49
37
 
50
- def respond_to_missing? method
51
- return false if method.to_s =~ /^_/
38
+ def respond_to_missing?(method)
39
+ # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
40
+ return super if method.to_s.start_with? "_"
41
+
52
42
  true
53
43
  end
54
44
 
@@ -56,11 +46,15 @@ module Iba
56
46
  method_missing :to_s
57
47
  end
58
48
 
59
- def == other
49
+ def ==(other)
60
50
  method_missing :==, other
61
51
  end
62
52
 
63
- def _wrap arg
53
+ def !=(other)
54
+ method_missing :!=, other
55
+ end
56
+
57
+ def _wrap(arg)
64
58
  if arg.is_a? BaseExpression
65
59
  arg
66
60
  else
@@ -68,13 +62,22 @@ module Iba
68
62
  end
69
63
  end
70
64
 
71
- def coerce other
65
+ def _display(_bnd)
66
+ nil
67
+ end
68
+
69
+ def _display_subexpressions(_bnd)
70
+ nil
71
+ end
72
+
73
+ # Handle numeric operator coersion
74
+ def coerce(other)
72
75
  [_wrap(other), self]
73
76
  end
74
77
  end
75
78
 
76
79
  class EmptyExpression < BaseExpression
77
- def _parse &blk
80
+ def _parse(&blk)
78
81
  bnd = blk.binding
79
82
 
80
83
  vars = bnd.local_variables
@@ -92,35 +95,42 @@ module Iba
92
95
  result
93
96
  end
94
97
 
95
- def _override_instance_variables vars
98
+ def _override_instance_variables(vars)
96
99
  vars.each do |v|
97
- next if v =~ /^@_/
100
+ # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
101
+ next if v.to_s.start_with? "@_"
102
+
98
103
  instance_variable_set v, Iba::InstanceVariableExpression.new(v.to_sym)
99
104
  end
100
105
  end
101
106
 
102
- def _override_local_variables vars, bnd
107
+ def _override_local_variables(vars, bnd)
103
108
  vars.each do |v|
104
- next if v =~ /^_/
109
+ # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
110
+ next if v.to_s.start_with? "_"
111
+
105
112
  bnd.local_variable_set "_#{v}", bnd.local_variable_get(v)
106
113
  bnd.local_variable_set v, LocalVariableExpression.new(v.to_sym)
107
114
  end
108
115
  end
109
116
 
110
- def _restore_local_variables vars, bnd
117
+ def _restore_local_variables(vars, bnd)
111
118
  vars.each do |v|
112
- next if v =~ /^_/
119
+ # FIXME: Remove to_s once support for Ruby < 2.7 is dropped
120
+ next if v.to_s.start_with? "_"
121
+
113
122
  bnd.local_variable_set v, bnd.local_variable_get("_#{v}")
114
123
  end
115
124
  end
116
125
 
117
126
  def _to_s
118
- ''
127
+ ""
119
128
  end
120
129
  end
121
130
 
122
131
  class LiteralExpression < BaseExpression
123
- def initialize val
132
+ def initialize(val)
133
+ super()
124
134
  @value = val
125
135
  end
126
136
 
@@ -128,13 +138,22 @@ module Iba
128
138
  @value.inspect
129
139
  end
130
140
 
131
- def _evaluate _bnd
141
+ def _evaluate(_bnd)
132
142
  @value
133
143
  end
134
144
  end
135
145
 
136
- class InstanceVariableExpression < BaseExpression
137
- def initialize ivar_name
146
+ class DisplayableExpression < BaseExpression
147
+ def _display(bnd)
148
+ str = _to_s
149
+ value = _evaluate(bnd).inspect
150
+ "#{str} is #{value}"
151
+ end
152
+ end
153
+
154
+ class InstanceVariableExpression < DisplayableExpression
155
+ def initialize(ivar_name)
156
+ super()
138
157
  @_ivar_name = ivar_name
139
158
  end
140
159
 
@@ -142,13 +161,14 @@ module Iba
142
161
  @_ivar_name.to_s
143
162
  end
144
163
 
145
- def _evaluate bnd
164
+ def _evaluate(bnd)
146
165
  bnd.receiver.instance_variable_get @_ivar_name
147
166
  end
148
167
  end
149
168
 
150
- class LocalVariableExpression < BaseExpression
151
- def initialize lvar_name
169
+ class LocalVariableExpression < DisplayableExpression
170
+ def initialize(lvar_name)
171
+ super()
152
172
  @_lvar_name = lvar_name
153
173
  end
154
174
 
@@ -156,64 +176,89 @@ module Iba
156
176
  @_lvar_name.to_s
157
177
  end
158
178
 
159
- def _evaluate bnd
179
+ def _evaluate(bnd)
160
180
  bnd.local_variable_get @_lvar_name
161
181
  end
162
182
  end
163
183
 
164
- class MethodCallExpression < BaseExpression
184
+ class MethodCallExpression < DisplayableExpression
165
185
  attr_reader :_method, :_reciever, :_args
166
186
 
167
- def initialize reciever, methodname, args
187
+ def initialize(reciever, methodname, args)
188
+ super()
168
189
  @_reciever = reciever
169
190
  @_method = methodname
170
191
  @_args = args.map { |a| _wrap(a) }
171
192
  end
172
193
 
173
194
  def _to_s
174
- rcv = @_reciever._to_s
175
- args = @_args.map { |a| a.respond_to?(:_to_s) ? a._to_s : a.to_s }
176
-
177
195
  if @_method == :[]
178
- "#{rcv}[#{args[0]}]"
196
+ _index_to_s
179
197
  elsif _method_is_operator?
180
- case @_args.length
181
- when 0
182
- "#{@_method.to_s.sub(/@$/, '')}#{rcv}"
183
- when 1
184
- "(#{rcv} #{@_method} #{args.first})"
185
- else
186
- raise NotImplementedError
187
- end
198
+ _operator_to_s
188
199
  else
189
- str = rcv == '' ? '' : "#{rcv}."
190
- str << @_method.to_s
191
- str << "(#{args.join(', ')})" unless @_args.empty?
192
- str
200
+ _regular_method_to_s
193
201
  end
194
202
  end
195
203
 
196
- def _evaluate bnd
204
+ def _evaluate(bnd)
197
205
  rcv = @_reciever._evaluate(bnd)
198
206
  args = @_args.map { |arg| arg._evaluate(bnd) }
199
207
  rcv.send @_method, *args
200
208
  end
201
209
 
210
+ def _display_subexpressions(bnd)
211
+ rcv = @_reciever._display(bnd)
212
+ args = @_args.map { |arg| arg._display(bnd) }
213
+ [rcv, *args].compact.join(", ")
214
+ end
215
+
202
216
  private
203
217
 
218
+ def _receiver_s
219
+ @_reciever._to_s
220
+ end
221
+
222
+ def _args_s
223
+ @_args.map { |a| a.respond_to?(:_to_s) ? a._to_s : a.to_s }
224
+ end
225
+
226
+ def _index_to_s
227
+ "#{_receiver_s}[#{_args_s[0]}]"
228
+ end
229
+
230
+ def _operator_to_s
231
+ case @_args.length
232
+ when 0
233
+ "#{@_method.to_s.sub(/@$/, '')}#{_receiver_s}"
234
+ when 1
235
+ "(#{_receiver_s} #{@_method} #{_args_s.first})"
236
+ else
237
+ raise NotImplementedError
238
+ end
239
+ end
240
+
241
+ def _regular_method_to_s
242
+ rcv = _receiver_s
243
+ str = rcv == "" ? +"" : +"#{rcv}."
244
+ str << @_method.to_s
245
+ str << "(#{_args_s.join(', ')})" unless @_args.empty?
246
+ str
247
+ end
248
+
204
249
  def _method_is_operator?
205
250
  @_method.to_s !~ /^[a-z]/
206
251
  end
207
252
  end
208
253
 
209
254
  module BlockAssertion
210
- def assert *args
211
- if block_given?
255
+ def assert(*args, &block)
256
+ if block
212
257
  if yield
213
- assert_block('true') { true }
258
+ assert_block("true") { true }
214
259
  else
215
- msg = args.empty? ? '' : "#{args.first}.\n"
216
- ana = Combinator.new(&Proc.new).analyse
260
+ msg = args.empty? ? "" : "#{args.first}.\n"
261
+ ana = Combinator.new(&block).analyse
217
262
  assert_block("#{msg}#{ana}.") { false }
218
263
  end
219
264
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,14 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '12.0'
19
+ version: '13.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '12.0'
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-manifest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.25.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.25.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-packaging
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.5.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.13.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.13.0
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: test-unit
29
85
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +94,9 @@ dependencies:
38
94
  - - "~>"
39
95
  - !ruby/object:Gem::Version
40
96
  version: '3.1'
41
- description: Asserts blocks, prints introspective failure messages.
97
+ description: 'Asserts blocks, prints introspective failure messages.
98
+
99
+ '
42
100
  email:
43
101
  - matijs@matijs.net
44
102
  executables: []
@@ -51,19 +109,16 @@ files:
51
109
  - COPYING.LESSER
52
110
  - LICENSE
53
111
  - README.rdoc
54
- - Rakefile
55
112
  - lib/iba.rb
56
- - test/.rubocop.yml
57
- - test/analyse_test.rb
58
- - test/assert_test.rb
59
- - test/call_test.rb
60
- - test/display_test.rb
61
- - test/test_helper.rb
113
+ - lib/iba/version.rb
62
114
  homepage: http://www.github.com/mvz/iba
63
115
  licenses:
64
- - LGPL-3
65
- metadata: {}
66
- post_install_message:
116
+ - LGPL-3.0+
117
+ metadata:
118
+ homepage_uri: http://www.github.com/mvz/iba
119
+ source_code_uri: https://github.com/mvz/iba
120
+ rubygems_mfa_required: 'true'
121
+ post_install_message:
67
122
  rdoc_options:
68
123
  - "--main"
69
124
  - README.rdoc
@@ -73,22 +128,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
128
  requirements:
74
129
  - - ">="
75
130
  - !ruby/object:Gem::Version
76
- version: 2.2.0
131
+ version: 2.6.0
77
132
  required_rubygems_version: !ruby/object:Gem::Requirement
78
133
  requirements:
79
134
  - - ">="
80
135
  - !ruby/object:Gem::Version
81
136
  version: '0'
82
137
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.7.6
85
- signing_key:
138
+ rubygems_version: 3.3.3
139
+ signing_key:
86
140
  specification_version: 4
87
141
  summary: Introspective Block Assertions
88
- test_files:
89
- - test/.rubocop.yml
90
- - test/analyse_test.rb
91
- - test/assert_test.rb
92
- - test/call_test.rb
93
- - test/display_test.rb
94
- - test/test_helper.rb
142
+ test_files: []
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require 'rake/clean'
2
- require 'bundler/gem_tasks'
3
- require 'rake/testtask'
4
-
5
- namespace :test do
6
- Rake::TestTask.new(:run) do |t|
7
- t.libs = ['lib']
8
- t.test_files = FileList['test/**/*_test.rb']
9
- t.ruby_opts += ['-w']
10
- end
11
- end
12
-
13
- desc 'Alias to test:run'
14
- task test: 'test:run'
15
-
16
- task default: 'test:run'
data/test/.rubocop.yml DELETED
@@ -1,10 +0,0 @@
1
- inherit_from: ../.rubocop.yml
2
-
3
- # We need to rescue Exception to test exceptions thrown by assert
4
- # TODO: Remove once support for Ruby 1.8 is dropped.
5
- Lint/RescueException:
6
- Enabled: false
7
-
8
- # Allow compact syntax when adding to Test::Unit::TestCase
9
- Style/ClassAndModuleChildren:
10
- Enabled: false
data/test/analyse_test.rb DELETED
@@ -1,78 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Test how the combinator analyses the parsed block contents.
4
- class AnalyseTest < Test::Unit::TestCase
5
- def test_empty_block
6
- assert_equal 'nil is nil', combinator {}.analyse
7
- end
8
-
9
- def test_variable
10
- foo = 23
11
- assert_equal 'foo is 23', combinator { foo }.analyse
12
- end
13
-
14
- def test_operator_equals
15
- foo = 42
16
- bar = 23
17
- result = combinator { foo == bar }.analyse
18
- assert_equal "(foo == bar) is false\nfoo is 42, bar is 23", result
19
- end
20
-
21
- def test_operator_equals_literal
22
- foo = 42
23
- result = combinator { foo == 23 }.analyse
24
- assert_equal "(foo == 23) is false\nfoo is 42", result
25
- end
26
-
27
- def test_operator_equals_array_literal
28
- foo = [1, 'bar']
29
- result = combinator { foo == [2, 'baz'] }.analyse
30
- assert_equal "(foo == [2, \"baz\"]) is false\nfoo is [1, \"bar\"]", result
31
- end
32
-
33
- def test_string_variable
34
- foo = 'blub'
35
- assert_equal 'foo is "blub"', combinator { foo }.analyse
36
- end
37
-
38
- def test_array_variable
39
- foo = [1, 2]
40
- assert_equal 'foo is [1, 2]', combinator { foo }.analyse
41
- end
42
-
43
- def test_object_variable
44
- foo = Object.new
45
- insp = foo.inspect
46
- assert_equal "foo is #{insp}", combinator { foo }.analyse
47
- end
48
-
49
- def test_literal
50
- assert_equal '23 is 23', combinator { 23 }.analyse
51
- end
52
-
53
- def test_instance_variable
54
- @foo = 23
55
- assert_equal '@foo is 23', combinator { @foo }.analyse
56
- end
57
-
58
- def test_instance_variable_method_call
59
- @foo = 23
60
- assert_equal "(@foo == 23) is true\n@foo is 23", combinator { @foo == 23 }.analyse
61
- end
62
-
63
- def test_instance_variable_as_argument_of_operator
64
- @foo = 23
65
- assert_equal '(23 + @foo) is 46', combinator { 23 + @foo }.analyse
66
- end
67
-
68
- def test_complex_subexpressions
69
- @foo = 23
70
- bar = 42
71
- baz = [42]
72
- result = combinator { (@foo + baz.first) == (bar + 23) }.analyse
73
- assert_equal \
74
- "((@foo + baz.first) == (bar + 23)) is true\n" \
75
- '(@foo + baz.first) is 65, (bar + 23) is 65',
76
- result
77
- end
78
- end
data/test/assert_test.rb DELETED
@@ -1,51 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Test behavior of overridden assert method.
4
- class AssertTest < Test::Unit::TestCase
5
- def test_simple_assert
6
- assert { true }
7
- end
8
-
9
- def failing_block_assertion_test message, &block
10
- assert(&block)
11
- rescue Exception => e
12
- assert_equal message, e.message
13
- end
14
-
15
- def test_simple_failing_assert
16
- failing_block_assertion_test('false is false.') { false }
17
- end
18
-
19
- def test_operator_equals_assert
20
- foo = 24
21
- failing_block_assertion_test("(foo == 23) is false\nfoo is 24.") { foo == 23 }
22
- end
23
-
24
- def test_instance_variable_assert
25
- @foo = 24
26
- failing_block_assertion_test("(@foo == 23) is false\n@foo is 24.") { @foo == 23 }
27
- end
28
-
29
- # Special cases
30
-
31
- def test_assert_with_custom_message
32
- foo = false
33
- begin
34
- assert('We want foo') { foo }
35
- rescue Exception => e
36
- assert_equal "We want foo.\nfoo is false.", e.message
37
- end
38
- end
39
-
40
- def test_blockless_assert
41
- assert false
42
- rescue Exception => e
43
- assert_equal '<false> is not true.', e.message
44
- end
45
-
46
- def test_blockless_assert_with_custom_message
47
- assert false, 'We want the truth'
48
- rescue Exception => e
49
- assert_equal "We want the truth.\n<false> is not true.", e.message
50
- end
51
- end
data/test/call_test.rb DELETED
@@ -1,18 +0,0 @@
1
- require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
-
3
- # Test how the combinator calls the passed block.
4
- class CallTest < Test::Unit::TestCase
5
- def test_empty_combinator
6
- assert_equal nil, combinator {}.call
7
- end
8
-
9
- def test_variable
10
- foo = 23
11
- assert_equal 23, combinator { foo }.call
12
- end
13
-
14
- def test_operator_call
15
- foo = 23
16
- assert_equal true, combinator { foo == 23 }.call
17
- end
18
- end
data/test/display_test.rb DELETED
@@ -1,57 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- # Test how the combinator displays the parsed block contents.
4
- class DisplayTest < Test::Unit::TestCase
5
- def test_empty_combinator
6
- assert_equal 'nil', combinator {}.to_s
7
- end
8
-
9
- def test_literal_number
10
- assert_equal '23', combinator { 23 }.to_s
11
- end
12
-
13
- def test_literal_string
14
- assert_equal '"aa"', combinator { 'aa' }.to_s
15
- end
16
-
17
- def test_method_calls
18
- assert_equal 'foo', combinator { foo }.to_s
19
- assert_equal 'foo.foo', combinator { foo.foo }.to_s
20
- assert_equal 'foo.foo(1)', combinator { foo.foo 1 }.to_s
21
- assert_equal 'foo(1)', combinator { foo 1 }.to_s
22
- assert_equal 'foo(bar)', combinator { foo bar }.to_s
23
- assert_equal 'foo(1).bar', combinator { foo(1).bar }.to_s
24
- assert_equal 'foo.foo.foo', combinator { foo.foo.foo }.to_s
25
- assert_equal 'foo(bar.baz)', combinator { foo bar.baz }.to_s
26
- end
27
-
28
- def test_operators
29
- assert_equal '(foo + 1)', combinator { foo + 1 }.to_s
30
- assert_equal '(foo - 1)', combinator { foo - 1 }.to_s
31
- end
32
-
33
- def test_operator_equals
34
- assert_equal '(foo == 1)', combinator { foo == 1 }.to_s
35
- end
36
-
37
- def test_array_index
38
- assert_equal 'foo[1]', combinator { foo[1] }.to_s
39
- end
40
-
41
- def test_to_s_method
42
- assert_equal 'foo.to_s', combinator { foo.to_s }.to_s
43
- end
44
-
45
- def test_operator_unary_minus
46
- assert_equal '-foo', combinator { -foo }.to_s
47
- end
48
-
49
- def test_operator_if_wont_work
50
- assert_equal 'bar', combinator { foo ? bar : baz }.to_s
51
- end
52
-
53
- def test_defined_instance_variables
54
- @foo = 1
55
- assert_equal '@foo', combinator { @foo }.to_s
56
- end
57
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'test/unit'
2
- require 'iba'
3
-
4
- class Test::Unit::TestCase
5
- include Iba::BlockAssertion
6
-
7
- def combinator &blk
8
- Iba::Combinator.new(&blk)
9
- end
10
- end