mutant 0.9.3 → 0.9.4

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: 88d8955c5d10cb6d884c519e2e9472affa627ab71377f73bd0746f8e27aea1d5
4
- data.tar.gz: e4d07470181a24861d61e5f90a107fdcdc6da4f959392bf25c8bf6c8ce1e3628
3
+ metadata.gz: 5194ccc2d7c83d425c53dc7339242277010dcac6715248380417f936d88f7eda
4
+ data.tar.gz: ba35d0efea5be46b335947acd7452d72df6917deba2e6ccad96d8e0b60bdb2e4
5
5
  SHA512:
6
- metadata.gz: 6906c7b02d2979d2f666735266a1c7220d75b6af35457ff54b021b3cf5306c1c4b94688eacfb685c46ee554353f91d6a78f6ac999e7535981f162e4b9d312a65
7
- data.tar.gz: '059b7da0f47093ec1a7416fd1c3492f3eb01ccd3741796ff4f97ddbf597d2fd37c102c2bacfd5268204115efb6fc428088225d18785e22febfb49ba0d625710c'
6
+ metadata.gz: a63b99d244b957e3b3664243ed8a37704b2bdc596be0020de7f5665351958d941ec1be81584af798f7c0b63011d5cd689b4d3b77686469d869670592bffdecf4
7
+ data.tar.gz: 76c702695a6e04f874a73952fb153065bb0f76ebd098b50b6bb6e7b670568ca842aa78b70c71abb8728248eacf0e28ef123c02eab4c443d4a896fe3939ff453b
@@ -1,3 +1,7 @@
1
+ # v0.9.4 2020-01-03
2
+
3
+ * Bump unparser dependency
4
+
1
5
  # v0.9.3 2020-01-03
2
6
 
3
7
  * Change to soft dependency on mutant-license.
@@ -37,7 +37,7 @@ GIT
37
37
  PATH
38
38
  remote: .
39
39
  specs:
40
- mutant (0.9.3)
40
+ mutant (0.9.4)
41
41
  abstract_type (~> 0.0.7)
42
42
  adamantium (~> 0.2.0)
43
43
  anima (~> 0.3.1)
@@ -47,9 +47,10 @@ PATH
47
47
  equalizer (~> 0.0.9)
48
48
  ice_nine (~> 0.11.1)
49
49
  memoizable (~> 0.4.2)
50
+ mprelude (~> 0.1.0)
50
51
  parser (~> 2.6.5)
51
52
  procto (~> 0.0.2)
52
- unparser (~> 0.4.5)
53
+ unparser (~> 0.4.6)
53
54
 
54
55
  GEM
55
56
  remote: https://rubygems.org/
@@ -96,6 +97,13 @@ GEM
96
97
  kwalify (0.7.2)
97
98
  memoizable (0.4.2)
98
99
  thread_safe (~> 0.3, >= 0.3.1)
100
+ mprelude (0.1.0)
101
+ abstract_type (~> 0.0.7)
102
+ adamantium (~> 0.2.0)
103
+ concord (~> 0.1.5)
104
+ equalizer (~> 0.0.9)
105
+ ice_nine (~> 0.11.1)
106
+ procto (~> 0.0.2)
99
107
  mutant-license (0.1.0)
100
108
  parallel (1.19.1)
101
109
  parser (2.6.5.0)
@@ -10,6 +10,7 @@ require 'digest/sha1'
10
10
  require 'equalizer'
11
11
  require 'etc'
12
12
  require 'ice_nine'
13
+ require 'mprelude'
13
14
  require 'json'
14
15
  require 'open3'
15
16
  require 'optparse'
@@ -30,13 +31,14 @@ Thread.abort_on_exception = true
30
31
  #
31
32
  # @api private
32
33
  module Mutant
34
+ Either = MPrelude::Either
35
+
33
36
  EMPTY_STRING = ''
34
37
  EMPTY_ARRAY = [].freeze
35
38
  EMPTY_HASH = {}.freeze
36
39
  SCOPE_OPERATOR = '::'
37
40
  end # Mutant
38
41
 
39
- require 'mutant/base'
40
42
  require 'mutant/bootstrap'
41
43
  require 'mutant/version'
42
44
  require 'mutant/env'
@@ -36,10 +36,10 @@ module Mutant
36
36
  def self.run(world, default_config, arguments)
37
37
  License
38
38
  .apply(world)
39
- .apply { Config.load_config_file(world, default_config) }
40
- .apply { |file_config| apply(world, file_config, arguments) }
41
- .apply { |cli_config| Bootstrap.apply(world, cli_config) }
42
- .apply(&Runner.method(:apply))
39
+ .bind { Config.load_config_file(world, default_config) }
40
+ .bind { |file_config| apply(world, file_config, arguments) }
41
+ .bind { |cli_config| Bootstrap.apply(world, cli_config) }
42
+ .bind(&Runner.method(:apply))
43
43
  .from_right { |error| world.stderr.puts(error); return false }
44
44
  .success?
45
45
  end
@@ -28,7 +28,7 @@ module Mutant
28
28
  # @return [Either<String, Integration>]
29
29
  def self.setup(env)
30
30
  attempt_require(env)
31
- .apply { attempt_const_get(env) }
31
+ .bind { attempt_const_get(env) }
32
32
  .fmap { |klass| klass.new(env.config).setup }
33
33
  end
34
34
 
@@ -23,7 +23,7 @@ module Mutant
23
23
  load_mutant_license(world)
24
24
  .fmap { license_path(world) }
25
25
  .fmap { |path| Subscription.from_json(world.json.load(path)) }
26
- .apply { |sub| sub.apply(world) }
26
+ .bind { |sub| sub.apply(world) }
27
27
  end
28
28
  private_class_method :license_result
29
29
 
@@ -53,7 +53,7 @@ module Mutant
53
53
  world
54
54
  .capture_stdout(%w[git remote --verbose])
55
55
  .fmap(&method(:parse_remotes))
56
- .apply(&method(:check_subscription))
56
+ .bind(&method(:check_subscription))
57
57
  end
58
58
 
59
59
  private
@@ -263,7 +263,7 @@ module Mutant
263
263
  PRIMITIVE
264
264
  .apply(input)
265
265
  .lmap(&method(:lift_error))
266
- .apply(&method(:run))
266
+ .bind(&method(:run))
267
267
  end
268
268
 
269
269
  private
@@ -351,8 +351,8 @@ module Mutant
351
351
  PRIMITIVE
352
352
  .apply(input)
353
353
  .lmap(&method(:lift_error))
354
- .apply(&method(:reject_keys))
355
- .apply(&method(:transform))
354
+ .bind(&method(:reject_keys))
355
+ .bind(&method(:transform))
356
356
  end
357
357
 
358
358
  private
@@ -363,7 +363,7 @@ module Mutant
363
363
  #
364
364
  # @return [Either<Error, Hash>]
365
365
  def transform(input)
366
- transform_required(input).apply do |required|
366
+ transform_required(input).bind do |required|
367
367
  transform_optional(input).fmap(&required.method(:merge))
368
368
  end
369
369
  end
@@ -503,7 +503,8 @@ module Mutant
503
503
  #
504
504
  # @return [Either<Error, Object>]
505
505
  def apply(input)
506
- Either.wrap_error(error_class) { block.call(input) }
506
+ Either
507
+ .wrap_error(error_class) { block.call(input) }
507
508
  .lmap { |exception| error(input: input, message: exception.to_s) }
508
509
  end
509
510
  end # Exception
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.9.3'
5
+ VERSION = '0.9.4'
6
6
  end # Mutant
@@ -21,18 +21,19 @@ Gem::Specification.new do |gem|
21
21
  gem.extra_rdoc_files = %w[LICENSE]
22
22
  gem.executables = %w[mutant]
23
23
 
24
- gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
25
- gem.add_runtime_dependency('adamantium', '~> 0.2.0')
26
- gem.add_runtime_dependency('anima', '~> 0.3.1')
27
- gem.add_runtime_dependency('ast', '~> 2.2')
28
- gem.add_runtime_dependency('concord', '~> 0.1.5')
29
- gem.add_runtime_dependency('diff-lcs', '~> 1.3')
30
- gem.add_runtime_dependency('equalizer', '~> 0.0.9')
31
- gem.add_runtime_dependency('ice_nine', '~> 0.11.1')
32
- gem.add_runtime_dependency('memoizable', '~> 0.4.2')
33
- gem.add_runtime_dependency('parser', '~> 2.6.5')
34
- gem.add_runtime_dependency('procto', '~> 0.0.2')
35
- gem.add_runtime_dependency('unparser', '~> 0.4.5')
24
+ gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
25
+ gem.add_runtime_dependency('adamantium', '~> 0.2.0')
26
+ gem.add_runtime_dependency('anima', '~> 0.3.1')
27
+ gem.add_runtime_dependency('ast', '~> 2.2')
28
+ gem.add_runtime_dependency('concord', '~> 0.1.5')
29
+ gem.add_runtime_dependency('diff-lcs', '~> 1.3')
30
+ gem.add_runtime_dependency('equalizer', '~> 0.0.9')
31
+ gem.add_runtime_dependency('ice_nine', '~> 0.11.1')
32
+ gem.add_runtime_dependency('memoizable', '~> 0.4.2')
33
+ gem.add_runtime_dependency('mprelude', '~> 0.1.0')
34
+ gem.add_runtime_dependency('parser', '~> 2.6.5')
35
+ gem.add_runtime_dependency('procto', '~> 0.0.2')
36
+ gem.add_runtime_dependency('unparser', '~> 0.4.6')
36
37
 
37
38
  gem.add_development_dependency('devtools', '~> 0.1.23')
38
39
  gem.add_development_dependency('parallel', '~> 1.3')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.4.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: mprelude
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.1.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.1.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: parser
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +184,14 @@ dependencies:
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: 0.4.5
187
+ version: 0.4.6
174
188
  type: :runtime
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: 0.4.5
194
+ version: 0.4.6
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: devtools
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -252,7 +266,6 @@ files:
252
266
  - lib/mutant/ast/nodes.rb
253
267
  - lib/mutant/ast/sexp.rb
254
268
  - lib/mutant/ast/types.rb
255
- - lib/mutant/base.rb
256
269
  - lib/mutant/bootstrap.rb
257
270
  - lib/mutant/cli.rb
258
271
  - lib/mutant/color.rb
@@ -499,7 +512,6 @@ files:
499
512
  - spec/unit/mutant/config_spec.rb
500
513
  - spec/unit/mutant/context_spec.rb
501
514
  - spec/unit/mutant/diff_spec.rb
502
- - spec/unit/mutant/either_spec.rb
503
515
  - spec/unit/mutant/env_spec.rb
504
516
  - spec/unit/mutant/expression/method_spec.rb
505
517
  - spec/unit/mutant/expression/methods_spec.rb
@@ -527,7 +539,6 @@ files:
527
539
  - spec/unit/mutant/matcher/scope_spec.rb
528
540
  - spec/unit/mutant/matcher/static_spec.rb
529
541
  - spec/unit/mutant/matcher_spec.rb
530
- - spec/unit/mutant/maybe_spec.rb
531
542
  - spec/unit/mutant/meta/example/dsl_spec.rb
532
543
  - spec/unit/mutant/meta/example/verification_spec.rb
533
544
  - spec/unit/mutant/meta/example_spec.rb
@@ -613,7 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
613
624
  - !ruby/object:Gem::Version
614
625
  version: '0'
615
626
  requirements: []
616
- rubygems_version: 3.0.3
627
+ rubygems_version: 3.0.6
617
628
  signing_key:
618
629
  specification_version: 4
619
630
  summary: ''
@@ -637,7 +648,6 @@ test_files:
637
648
  - spec/unit/mutant/config_spec.rb
638
649
  - spec/unit/mutant/context_spec.rb
639
650
  - spec/unit/mutant/diff_spec.rb
640
- - spec/unit/mutant/either_spec.rb
641
651
  - spec/unit/mutant/env_spec.rb
642
652
  - spec/unit/mutant/expression/method_spec.rb
643
653
  - spec/unit/mutant/expression/methods_spec.rb
@@ -665,7 +675,6 @@ test_files:
665
675
  - spec/unit/mutant/matcher/scope_spec.rb
666
676
  - spec/unit/mutant/matcher/static_spec.rb
667
677
  - spec/unit/mutant/matcher_spec.rb
668
- - spec/unit/mutant/maybe_spec.rb
669
678
  - spec/unit/mutant/meta/example/dsl_spec.rb
670
679
  - spec/unit/mutant/meta/example/verification_spec.rb
671
680
  - spec/unit/mutant/meta/example_spec.rb
@@ -1,192 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mutant
4
- module Functor
5
- include AbstractType
6
-
7
- abstract_method :fmap
8
-
9
- private
10
-
11
- # Raise error unless block is provided
12
- #
13
- # @raise [MissingBlockError]
14
- # if no block is given
15
- #
16
- # @return [self]
17
- def require_block
18
- fail LocalJumpError unless block_given?
19
- self
20
- end
21
- end # Functor
22
-
23
- class Maybe
24
- include(
25
- AbstractType,
26
- Adamantium::Flat,
27
- Functor
28
- )
29
-
30
- class Nothing < self
31
- instance = new
32
-
33
- define_method(:new) { instance }
34
-
35
- # Evaluate functor block
36
- #
37
- # @return [Maybe::Nothing]
38
- def fmap(&block)
39
- require_block(&block)
40
- end
41
-
42
- # Evaluate applicative block
43
- #
44
- # @return [Maybe::Nothing]
45
- def apply(&block)
46
- require_block(&block)
47
- end
48
- end # Nothing
49
-
50
- class Just < self
51
- include Concord.new(:value)
52
-
53
- # Evalute functor block
54
- #
55
- # @return [Maybe::Just<Object>]
56
- def fmap
57
- Just.new(yield(value))
58
- end
59
-
60
- # Evalute applicative block
61
- #
62
- # @return [Maybe]
63
- def apply
64
- yield(value)
65
- end
66
- end # Just
67
- end # Maybe
68
-
69
- class Either
70
- include(
71
- AbstractType,
72
- Adamantium::Flat,
73
- Concord.new(:value),
74
- Functor
75
- )
76
-
77
- # Execute block and wrap error in left
78
- #
79
- # @param [Class:Exception] error
80
- #
81
- # @return [Either<Exception, Object>]
82
- def self.wrap_error(error)
83
- Right.new(yield)
84
- rescue error => exception
85
- Left.new(exception)
86
- end
87
-
88
- class Left < self
89
- # Evaluate functor block
90
- #
91
- # @return [Either::Left<Object>]
92
- def fmap(&block)
93
- require_block(&block)
94
- end
95
-
96
- # Evaluate applicative block
97
- #
98
- # @return [Either::Left<Object>]
99
- def apply(&block)
100
- require_block(&block)
101
- end
102
-
103
- # Unwrap value from left
104
- #
105
- # @return [Object]
106
- def from_left
107
- value
108
- end
109
-
110
- # Unwrap value from right
111
- #
112
- # @return [Object]
113
- #
114
- # rubocop:disable Style/GuardClause
115
- def from_right
116
- if block_given?
117
- yield(value)
118
- else
119
- fail "Expected right value, got #{inspect}"
120
- end
121
- end
122
- # rubocop:enable Style/GuardClause
123
-
124
- # Map over left value
125
- #
126
- # @return [Either::Right<Object>]
127
- def lmap
128
- Left.new(yield(value))
129
- end
130
-
131
- # Evaluate left side of branch
132
- #
133
- # @param [#call] left
134
- # @param [#call] _right
135
- def either(left, _right)
136
- left.call(value)
137
- end
138
- end # Left
139
-
140
- class Right < self
141
- # Evaluate functor block
142
- #
143
- # @return [Either::Right<Object>]
144
- def fmap
145
- Right.new(yield(value))
146
- end
147
-
148
- # Evaluate applicative block
149
- #
150
- # @return [Either<Object>]
151
- def apply
152
- yield(value)
153
- end
154
-
155
- # Unwrap value from left
156
- #
157
- # @return [Object]
158
- #
159
- # rubocop:disable Style/GuardClause
160
- def from_left
161
- if block_given?
162
- yield(value)
163
- else
164
- fail "Expected left value, got #{inspect}"
165
- end
166
- end
167
- # rubocop:enable Style/GuardClause
168
-
169
- # Unwrap value from right
170
- #
171
- # @return [Object]
172
- def from_right
173
- value
174
- end
175
-
176
- # Map over left value
177
- #
178
- # @return [Either::Right<Object>]
179
- def lmap(&block)
180
- require_block(&block)
181
- end
182
-
183
- # Evaluate right side of branch
184
- #
185
- # @param [#call] _left
186
- # @param [#call] right
187
- def either(_left, right)
188
- right.call(value)
189
- end
190
- end # Right
191
- end # Either
192
- end # Mutant
@@ -1,247 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Mutant::Either do
4
- describe '.wrap_error' do
5
- def apply
6
- described_class.wrap_error(error, &block)
7
- end
8
-
9
- let(:error) { TestError }
10
-
11
- class TestError < RuntimeError; end
12
-
13
- context 'when block returns' do
14
- let(:value) { instance_double(Object, 'value') }
15
- let(:block) { -> { value } }
16
-
17
- it 'returns right wrapping block value' do
18
- expect(apply).to eql(described_class::Right.new(value))
19
- end
20
- end
21
-
22
- context 'when block raises' do
23
- let(:exception) { error.new }
24
- let(:block) { -> { fail exception } }
25
-
26
- context 'with covered exception' do
27
- it 'returns left wrapping exception' do
28
- expect(apply).to eql(described_class::Left.new(exception))
29
- end
30
- end
31
-
32
- context 'with uncovered exception' do
33
- let(:exception) { StandardError.new }
34
-
35
- it 'returns raises error' do
36
- expect { apply }.to raise_error(StandardError)
37
- end
38
- end
39
- end
40
- end
41
- end
42
-
43
- RSpec.describe Mutant::Either::Left do
44
- subject { described_class.new(value) }
45
-
46
- let(:block_result) { instance_double(Object, 'block result') }
47
- let(:value) { instance_double(Object, 'value') }
48
- let(:yields) { [] }
49
-
50
- let(:block) do
51
- lambda do |value|
52
- yields << value
53
- block_result
54
- end
55
- end
56
-
57
- class TestError < RuntimeError; end
58
-
59
- describe '#fmap' do
60
- def apply
61
- subject.fmap(&block)
62
- end
63
-
64
- include_examples 'no block evaluation'
65
- include_examples 'requires block'
66
- include_examples 'returns self'
67
- end
68
-
69
- describe '#apply' do
70
- def apply
71
- subject.apply(&block)
72
- end
73
-
74
- include_examples 'no block evaluation'
75
- include_examples 'requires block'
76
- include_examples 'returns self'
77
- end
78
-
79
- describe '#from_left' do
80
- def apply
81
- subject.from_left(&block)
82
- end
83
-
84
- it 'returns left value' do
85
- expect(apply).to be(value)
86
- end
87
-
88
- include_examples 'no block evaluation'
89
- end
90
-
91
- describe '#from_right' do
92
- def apply
93
- subject.from_right(&block)
94
- end
95
-
96
- context 'without block' do
97
- let(:block) { nil }
98
-
99
- it 'raises RuntimeError error' do
100
- expect { apply }.to raise_error(
101
- RuntimeError,
102
- "Expected right value, got #{subject.inspect}"
103
- )
104
- end
105
- end
106
-
107
- context 'with block' do
108
- let(:yields) { [] }
109
- let(:block_return) { instance_double(Object, 'block-return') }
110
-
111
- let(:block) do
112
- lambda do |value|
113
- yields << value
114
- block_return
115
- end
116
- end
117
-
118
- it 'calls block with left value' do
119
- expect { apply }.to change(yields, :to_a).from([]).to([value])
120
- end
121
-
122
- it 'returns block value' do
123
- expect(apply).to be(block_return)
124
- end
125
- end
126
- end
127
-
128
- describe '#lmap' do
129
- def apply
130
- subject.lmap(&block)
131
- end
132
-
133
- include_examples 'requires block'
134
- include_examples 'Functor#fmap block evaluation'
135
- end
136
-
137
- describe '#either' do
138
- def apply
139
- subject.either(block, -> { fail })
140
- end
141
-
142
- include_examples '#apply block evaluation'
143
- end
144
- end
145
-
146
- RSpec.describe Mutant::Either::Right do
147
- subject { described_class.new(value) }
148
-
149
- let(:block_result) { instance_double(Object, 'block result') }
150
- let(:value) { instance_double(Object, 'value') }
151
- let(:yields) { [] }
152
-
153
- let(:block) do
154
- lambda do |value|
155
- yields << value
156
- block_result
157
- end
158
- end
159
-
160
- describe '#fmap' do
161
- def apply
162
- subject.fmap(&block)
163
- end
164
-
165
- include_examples 'requires block'
166
- include_examples 'Functor#fmap block evaluation'
167
- end
168
-
169
- describe '#apply' do
170
- def apply
171
- subject.apply(&block)
172
- end
173
-
174
- include_examples 'requires block'
175
- include_examples '#apply block evaluation'
176
- end
177
-
178
- describe '#from_left' do
179
- def apply
180
- subject.from_left(&block)
181
- end
182
-
183
- context 'without block' do
184
- let(:block) { nil }
185
-
186
- it 'raises RuntimeError error' do
187
- expect { apply }.to raise_error(
188
- RuntimeError,
189
- "Expected left value, got #{subject.inspect}"
190
- )
191
- end
192
- end
193
-
194
- context 'with block' do
195
- let(:yields) { [] }
196
- let(:block_return) { instance_double(Object, 'block-return') }
197
-
198
- let(:block) do
199
- lambda do |value|
200
- yields << value
201
- block_return
202
- end
203
- end
204
-
205
- it 'calls block with right value' do
206
- expect { apply }.to change(yields, :to_a).from([]).to([value])
207
- end
208
-
209
- it 'returns block value' do
210
- expect(apply).to be(block_return)
211
- end
212
- end
213
- end
214
-
215
- describe '#from_right' do
216
- def apply
217
- subject.from_right(&block)
218
- end
219
-
220
- it 'returns right value' do
221
- expect(apply).to be(value)
222
- end
223
-
224
- include_examples 'no block evaluation'
225
- end
226
-
227
- describe '#lmap' do
228
- def apply
229
- subject.lmap(&block)
230
- end
231
-
232
- include_examples 'requires block'
233
- include_examples 'no block evaluation'
234
-
235
- it 'returns self' do
236
- expect(apply).to be(subject)
237
- end
238
- end
239
-
240
- describe '#either' do
241
- def apply
242
- subject.either(-> { fail }, block)
243
- end
244
-
245
- include_examples '#apply block evaluation'
246
- end
247
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Mutant::Maybe::Nothing do
4
- subject { described_class.new }
5
-
6
- let(:block) { -> {} }
7
-
8
- describe '#fmap' do
9
- def apply
10
- subject.fmap(&block)
11
- end
12
-
13
- include_examples 'no block evaluation'
14
- include_examples 'requires block'
15
- include_examples 'returns self'
16
- end
17
-
18
- describe '#apply' do
19
- def apply
20
- subject.apply(&block)
21
- end
22
-
23
- include_examples 'no block evaluation'
24
- include_examples 'requires block'
25
- include_examples 'returns self'
26
- end
27
- end
28
-
29
- RSpec.describe Mutant::Maybe::Just do
30
- subject { described_class.new(value) }
31
-
32
- let(:block_result) { instance_double(Object, 'block result') }
33
- let(:value) { instance_double(Object, 'value') }
34
- let(:yields) { [] }
35
-
36
- let(:block) do
37
- lambda do |value|
38
- yields << value
39
- block_result
40
- end
41
- end
42
-
43
- describe '#fmap' do
44
- def apply
45
- subject.fmap(&block)
46
- end
47
-
48
- include_examples 'requires block'
49
- include_examples 'Functor#fmap block evaluation'
50
- end
51
-
52
- describe '#apply' do
53
- def apply
54
- subject.apply(&block)
55
- end
56
-
57
- include_examples 'requires block'
58
- include_examples '#apply block evaluation'
59
- end
60
- end