fear 3.0.0 → 3.1.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +105 -0
  3. data/.simplecov +2 -2
  4. data/.standard.yml +1 -0
  5. data/Gemfile +14 -14
  6. data/Gemfile.lock +56 -37
  7. data/Rakefile +24 -24
  8. data/examples/pattern_extracting.rb +2 -2
  9. data/examples/pattern_matching_number_in_words.rb +12 -12
  10. data/fear.gemspec +2 -3
  11. data/lib/fear/either/left_projection.rb +5 -5
  12. data/lib/fear/either/pattern_match.rb +2 -2
  13. data/lib/fear/either.rb +1 -1
  14. data/lib/fear/empty_partial_function.rb +2 -2
  15. data/lib/fear/failure.rb +4 -4
  16. data/lib/fear/for.rb +1 -1
  17. data/lib/fear/for_api.rb +1 -1
  18. data/lib/fear/future.rb +5 -5
  19. data/lib/fear/left/pattern_match.rb +1 -1
  20. data/lib/fear/left.rb +3 -3
  21. data/lib/fear/none_class.rb +2 -2
  22. data/lib/fear/option.rb +1 -1
  23. data/lib/fear/partial_function/and_then.rb +2 -2
  24. data/lib/fear/partial_function/combined.rb +3 -3
  25. data/lib/fear/partial_function/or_else.rb +2 -2
  26. data/lib/fear/partial_function_class.rb +1 -1
  27. data/lib/fear/pattern_match.rb +2 -2
  28. data/lib/fear/pattern_matching_api.rb +1 -1
  29. data/lib/fear/right/pattern_match.rb +1 -1
  30. data/lib/fear/right.rb +3 -3
  31. data/lib/fear/right_biased.rb +2 -2
  32. data/lib/fear/some.rb +2 -2
  33. data/lib/fear/success.rb +4 -4
  34. data/lib/fear/try_api.rb +1 -1
  35. data/lib/fear/utils.rb +1 -1
  36. data/lib/fear/version.rb +1 -1
  37. data/spec/fear/either/pattern_match_spec.rb +6 -6
  38. data/spec/fear/either_spec.rb +1 -1
  39. data/spec/fear/left_spec.rb +1 -1
  40. data/spec/fear/option/pattern_match_spec.rb +5 -5
  41. data/spec/fear/option_spec.rb +2 -2
  42. data/spec/fear/partial_function/any_spec.rb +3 -3
  43. data/spec/fear/partial_function/empty_spec.rb +1 -1
  44. data/spec/fear/partial_function_and_then_spec.rb +5 -5
  45. data/spec/fear/partial_function_composition_spec.rb +6 -6
  46. data/spec/fear/partial_function_or_else_spec.rb +13 -13
  47. data/spec/fear/partial_function_spec.rb +7 -7
  48. data/spec/fear/pattern_match_spec.rb +5 -5
  49. data/spec/fear/right_spec.rb +1 -1
  50. data/spec/fear/try/try_pattern_match_spec.rb +6 -6
  51. data/spec/fear/try_api_spec.rb +2 -2
  52. data/spec/fear/utils_spec.rb +3 -3
  53. metadata +7 -50
  54. data/.github/workflows/rubocop.yml +0 -39
  55. data/.github/workflows/spec.yml +0 -39
  56. data/.rubocop.yml +0 -7
@@ -7,7 +7,7 @@ module Fear
7
7
  def right(*)
8
8
  self
9
9
  end
10
- alias success right
10
+ alias_method :success, :right
11
11
  end
12
12
 
13
13
  private_constant :PatternMatch
data/lib/fear/left.rb CHANGED
@@ -15,13 +15,13 @@ module Fear
15
15
  def right?
16
16
  false
17
17
  end
18
- alias success? right?
18
+ alias_method :success?, :right?
19
19
 
20
20
  # @return [true]
21
21
  def left?
22
22
  true
23
23
  end
24
- alias failure? left?
24
+ alias_method :failure?, :left?
25
25
 
26
26
  # @return [Either]
27
27
  def select_or_else(*)
@@ -46,7 +46,7 @@ module Fear
46
46
  # @param reduce_left [Proc]
47
47
  # @return [any]
48
48
  def reduce(reduce_left, _reduce_right)
49
- reduce_left.(value)
49
+ reduce_left.call(value)
50
50
  end
51
51
 
52
52
  # @return [self]
@@ -28,7 +28,7 @@ module Fear
28
28
  true
29
29
  end
30
30
 
31
- alias :blank? :empty?
31
+ alias_method :blank?, :empty?
32
32
 
33
33
  # @return [false]
34
34
  def present?
@@ -51,7 +51,7 @@ module Fear
51
51
  end
52
52
 
53
53
  # @return [String]
54
- alias to_s inspect
54
+ alias_method :to_s, :inspect
55
55
 
56
56
  # @param other [Any]
57
57
  # @return [Boolean]
data/lib/fear/option.rb CHANGED
@@ -211,7 +211,7 @@ module Fear
211
211
  end
212
212
 
213
213
  def match(value, &block)
214
- matcher(&block).(value)
214
+ matcher(&block).call(value)
215
215
  end
216
216
  end
217
217
 
@@ -25,7 +25,7 @@ module Fear
25
25
  # @param arg [any]
26
26
  # @return [any ]
27
27
  def call(arg)
28
- function.(partial_function.(arg))
28
+ function.call(partial_function.call(arg))
29
29
  end
30
30
 
31
31
  # @param arg [any]
@@ -41,7 +41,7 @@ module Fear
41
41
  result = partial_function.call_or_else(arg) do
42
42
  return yield(arg)
43
43
  end
44
- function.(result)
44
+ function.call(result)
45
45
  end
46
46
  end
47
47
 
@@ -24,11 +24,11 @@ module Fear
24
24
  # @param arg [any]
25
25
  # @return [any ]
26
26
  def call(arg)
27
- f2.(f1.(arg))
27
+ f2.call(f1.call(arg))
28
28
  end
29
29
 
30
- alias === call
31
- alias [] call
30
+ alias_method :===, :call
31
+ alias_method :[], :call
32
32
 
33
33
  # @param arg [any]
34
34
  # @yieldparam arg [any]
@@ -27,8 +27,8 @@ module Fear
27
27
  f1.call_or_else(arg, &f2)
28
28
  end
29
29
 
30
- alias === call
31
- alias [] call
30
+ alias_method :===, :call
31
+ alias_method :[], :call
32
32
 
33
33
  # @param other [Fear::PartialFunction]
34
34
  # @return [Fear::PartialFunction]
@@ -27,7 +27,7 @@ module Fear
27
27
  # @yield [arg] if function not defined
28
28
  def call_or_else(arg)
29
29
  if defined_at?(arg)
30
- function.(arg)
30
+ function.call(arg)
31
31
  else
32
32
  yield arg
33
33
  end
@@ -33,7 +33,7 @@ module Fear
33
33
  # @note Use this class only to build custom pattern match classes. See +Fear::OptionPatternMatch+ as an example.
34
34
  class PatternMatch
35
35
  class << self
36
- alias __new__ new
36
+ alias_method :__new__, :new
37
37
 
38
38
  # @return [Fear::PartialFunction]
39
39
  def new
@@ -61,7 +61,7 @@ module Fear
61
61
 
62
62
  Module.new do
63
63
  define_method(as) do |&matchers|
64
- matcher_class.new(&matchers).(self)
64
+ matcher_class.new(&matchers).call(self)
65
65
  end
66
66
  end
67
67
  end
@@ -79,7 +79,7 @@ module Fear
79
79
  # @yieldparam matcher [Fear::PartialFunction]
80
80
  # @return [any]
81
81
  def match(value, &block)
82
- matcher(&block).(value)
82
+ matcher(&block).call(value)
83
83
  end
84
84
 
85
85
  # Creates partial function defined on domain described with guards
@@ -7,7 +7,7 @@ module Fear
7
7
  def left(*)
8
8
  self
9
9
  end
10
- alias failure left
10
+ alias_method :failure, :left
11
11
  end
12
12
 
13
13
  private_constant :PatternMatch
data/lib/fear/right.rb CHANGED
@@ -15,13 +15,13 @@ module Fear
15
15
  def right?
16
16
  true
17
17
  end
18
- alias success? right?
18
+ alias_method :success?, :right?
19
19
 
20
20
  # @return [false]
21
21
  def left?
22
22
  false
23
23
  end
24
- alias failure? left?
24
+ alias_method :failure?, :left?
25
25
 
26
26
  # @param default [Proc, any]
27
27
  # @return [Either]
@@ -59,7 +59,7 @@ module Fear
59
59
  # @param reduce_right [Proc]
60
60
  # @return [any]
61
61
  def reduce(_reduce_left, reduce_right)
62
- reduce_right.(value)
62
+ reduce_right.call(value)
63
63
  end
64
64
 
65
65
  # @return [Either]
@@ -70,7 +70,7 @@ module Fear
70
70
  yield(value)
71
71
  self
72
72
  end
73
- alias apply each
73
+ alias_method :apply, :each
74
74
 
75
75
  # Maps the value using given block.
76
76
  #
@@ -145,7 +145,7 @@ module Fear
145
145
  def each
146
146
  self
147
147
  end
148
- alias apply each
148
+ alias_method :apply, :each
149
149
 
150
150
  # Ignores the given block and return self.
151
151
  #
data/lib/fear/some.rb CHANGED
@@ -28,7 +28,7 @@ module Fear
28
28
  false
29
29
  end
30
30
 
31
- alias :blank? :empty?
31
+ alias_method :blank?, :empty?
32
32
 
33
33
  # @return [true]
34
34
  def present?
@@ -65,7 +65,7 @@ module Fear
65
65
  end
66
66
 
67
67
  # @return [String]
68
- alias to_s inspect
68
+ alias_method :to_s, :inspect
69
69
 
70
70
  # @param other [Fear::Option]
71
71
  # @return [Fear::Option]
data/lib/fear/success.rb CHANGED
@@ -52,7 +52,7 @@ module Fear
52
52
  else
53
53
  raise NoSuchElementError, "Predicate does not hold for `#{value}`"
54
54
  end
55
- rescue StandardError => error
55
+ rescue => error
56
56
  Failure.new(error)
57
57
  end
58
58
 
@@ -69,14 +69,14 @@ module Fear
69
69
  # @return [Try]
70
70
  def map
71
71
  super
72
- rescue StandardError => error
72
+ rescue => error
73
73
  Failure.new(error)
74
74
  end
75
75
 
76
76
  # @return [Try]
77
77
  def flat_map
78
78
  super
79
- rescue StandardError => error
79
+ rescue => error
80
80
  Failure.new(error)
81
81
  end
82
82
 
@@ -97,7 +97,7 @@ module Fear
97
97
  end
98
98
 
99
99
  # @return [String]
100
- alias to_s inspect
100
+ alias_method :to_s, :inspect
101
101
 
102
102
  # @return [<any>]
103
103
  def deconstruct
data/lib/fear/try_api.rb CHANGED
@@ -12,7 +12,7 @@ module Fear
12
12
  #
13
13
  def try
14
14
  success(yield)
15
- rescue StandardError => error
15
+ rescue => error
16
16
  failure(error)
17
17
  end
18
18
 
data/lib/fear/utils.rb CHANGED
@@ -38,7 +38,7 @@ module Fear
38
38
 
39
39
  def return_or_call_proc(value)
40
40
  if value.respond_to?(:call)
41
- value.()
41
+ value.call
42
42
  else
43
43
  value
44
44
  end
data/lib/fear/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fear
4
- VERSION = "3.0.0"
4
+ VERSION = "3.1.0"
5
5
  public_constant :VERSION
6
6
  end
@@ -10,10 +10,10 @@ RSpec.describe Fear::Either::PatternMatch do
10
10
  end
11
11
 
12
12
  it do
13
- expect(matcher.(Fear.right(4))).to eq("4 is even")
14
- expect(matcher.(Fear.right(3))).to eq("3 is odd")
13
+ expect(matcher.call(Fear.right(4))).to eq("4 is even")
14
+ expect(matcher.call(Fear.right(3))).to eq("3 is odd")
15
15
  expect do
16
- matcher.(Fear.left(44))
16
+ matcher.call(Fear.left(44))
17
17
  end.to raise_error(Fear::MatchError)
18
18
  end
19
19
  end
@@ -27,10 +27,10 @@ RSpec.describe Fear::Either::PatternMatch do
27
27
  end
28
28
 
29
29
  it do
30
- expect(matcher.(Fear.left(4))).to eq("4 is even")
31
- expect(matcher.(Fear.left(3))).to eq("3 is odd")
30
+ expect(matcher.call(Fear.left(4))).to eq("4 is even")
31
+ expect(matcher.call(Fear.left(3))).to eq("3 is odd")
32
32
  expect do
33
- matcher.(Fear.right(44))
33
+ matcher.call(Fear.right(44))
34
34
  end.to raise_error(Fear::MatchError)
35
35
  end
36
36
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec.describe Fear::Either do
4
4
  describe "#matcher" do
5
- subject(:result) { matcher.(value) }
5
+ subject(:result) { matcher.call(value) }
6
6
 
7
7
  let(:matcher) do
8
8
  described_class.matcher do |m|
@@ -77,7 +77,7 @@ RSpec.describe Fear::Left do
77
77
  subject do
78
78
  left.reduce(
79
79
  ->(left) { "Left: #{left}" },
80
- ->(right) { "Right: #{right}" },
80
+ ->(right) { "Right: #{right}" }
81
81
  )
82
82
  end
83
83
 
@@ -10,10 +10,10 @@ RSpec.describe Fear::Option::PatternMatch do
10
10
  end
11
11
 
12
12
  it do
13
- expect(matcher.(Fear.some(4))).to eq("4 is even")
14
- expect(matcher.(Fear.some(3))).to eq("3 is odd")
13
+ expect(matcher.call(Fear.some(4))).to eq("4 is even")
14
+ expect(matcher.call(Fear.some(3))).to eq("3 is odd")
15
15
  expect do
16
- matcher.(Fear.none)
16
+ matcher.call(Fear.none)
17
17
  end.to raise_error(Fear::MatchError)
18
18
  end
19
19
  end
@@ -26,9 +26,9 @@ RSpec.describe Fear::Option::PatternMatch do
26
26
  end
27
27
 
28
28
  it do
29
- expect(matcher.(Fear.none)).to eq("nil")
29
+ expect(matcher.call(Fear.none)).to eq("nil")
30
30
  expect do
31
- matcher.(Fear.some(3))
31
+ matcher.call(Fear.some(3))
32
32
  end.to raise_error(Fear::MatchError)
33
33
  end
34
34
  end
@@ -62,7 +62,7 @@ RSpec.describe Fear::Option do
62
62
 
63
63
  context "some mapped to nil" do
64
64
  let(:option) { Fear.some(42) }
65
- let(:filter_map) { ->(*) { nil } }
65
+ let(:filter_map) { ->(*) {} }
66
66
 
67
67
  it { is_expected.to be_none }
68
68
  end
@@ -97,7 +97,7 @@ RSpec.describe Fear::Option do
97
97
  end
98
98
 
99
99
  describe "#matcher" do
100
- subject(:result) { matcher.(value) }
100
+ subject(:result) { matcher.call(value) }
101
101
 
102
102
  let(:matcher) do
103
103
  described_class.matcher do |m|
@@ -18,8 +18,8 @@ RSpec.describe Fear::PartialFunction::Any do
18
18
  describe ".to_proc" do
19
19
  subject(:any_proc) { any.to_proc }
20
20
 
21
- it { expect(any_proc.(42)).to eq(true) }
22
- it { expect(any_proc.("foo")).to eq(true) }
23
- it { expect(any_proc.(Object.new)).to eq(true) }
21
+ it { expect(any_proc.call(42)).to eq(true) }
22
+ it { expect(any_proc.call("foo")).to eq(true) }
23
+ it { expect(any_proc.call(Object.new)).to eq(true) }
24
24
  end
25
25
  end
@@ -8,7 +8,7 @@ RSpec.describe Fear::PartialFunction::Empty do
8
8
  end
9
9
 
10
10
  describe "#call" do
11
- subject { -> { described_class.(42) } }
11
+ subject { -> { described_class.call(42) } }
12
12
 
13
13
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 42") }
14
14
  end
@@ -23,13 +23,13 @@ RSpec.describe Fear::PartialFunction, "#and_then" do
23
23
 
24
24
  describe "#call" do
25
25
  context "defined" do
26
- subject { pf_and_f.(4) }
26
+ subject { pf_and_f.call(4) }
27
27
 
28
28
  it { is_expected.to eq("f: pf: 4") }
29
29
  end
30
30
 
31
31
  context "not defined" do
32
- subject { -> { pf_and_f.(3) } }
32
+ subject { -> { pf_and_f.call(3) } }
33
33
 
34
34
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 3") }
35
35
  end
@@ -86,7 +86,7 @@ RSpec.describe Fear::PartialFunction, "#and_then" do
86
86
 
87
87
  describe "#call" do
88
88
  context "first defined, second defined on result of first" do
89
- subject { first_and_then_second.(6) }
89
+ subject { first_and_then_second.call(6) }
90
90
 
91
91
  let(:first) { Fear.case(->(x) { x.even? }) { |x| x / 2 } }
92
92
  let(:second) { Fear.case(->(x) { x % 3 == 0 }) { |x| x / 3 } }
@@ -95,7 +95,7 @@ RSpec.describe Fear::PartialFunction, "#and_then" do
95
95
  end
96
96
 
97
97
  context "first defined, second not defined on result of first" do
98
- subject { -> { first_and_then_second.(4) } }
98
+ subject { -> { first_and_then_second.call(4) } }
99
99
 
100
100
  let(:first) { Fear.case(->(x) { x.even? }) { |x| x / 2 } }
101
101
  let(:second) { Fear.case(->(x) { x % 3 == 0 }) { |x| x / 3 } }
@@ -104,7 +104,7 @@ RSpec.describe Fear::PartialFunction, "#and_then" do
104
104
  end
105
105
 
106
106
  context "first not defined" do
107
- subject { -> { first_and_then_second.(3) } }
107
+ subject { -> { first_and_then_second.call(3) } }
108
108
 
109
109
  let(:first) { Fear.case(->(x) { x.even? }) { |x| "first: #{x}" } }
110
110
  let(:second) { Fear.case(->(x) { x % 3 == 0 }) { |x| "second: #{x}" } }
@@ -60,13 +60,13 @@ RSpec.describe Fear::PartialFunction do
60
60
  it "two branches" do
61
61
  first_branch = Fear.case(Integer, &:itself).and_then(Fear.case(1) { "one" })
62
62
  second_branch = Fear.case(String, &:itself).and_then(
63
- (Fear.case("zero") { 0 }).or_else(Fear.case("one") { 1 }),
63
+ (Fear.case("zero") { 0 }).or_else(Fear.case("one") { 1 })
64
64
  )
65
65
 
66
66
  full = first_branch.or_else(second_branch)
67
- expect(full.(1)).to eq("one")
68
- expect(full.("zero")).to eq(0)
69
- expect(full.("one")).to eq(1)
67
+ expect(full.call(1)).to eq("one")
68
+ expect(full.call("zero")).to eq(0)
69
+ expect(full.call("one")).to eq(1)
70
70
  end
71
71
 
72
72
  it "or else anh then" do
@@ -76,7 +76,7 @@ RSpec.describe Fear::PartialFunction do
76
76
 
77
77
  f5 = f1.and_then(f3).or_else(f2)
78
78
 
79
- expect(f5.(11)).to eq(10)
80
- expect(f5.(3)).to eq(2)
79
+ expect(f5.call(11)).to eq(10)
80
+ expect(f5.call(3)).to eq(2)
81
81
  end
82
82
  end
@@ -34,25 +34,25 @@ RSpec.describe Fear::PartialFunction, "#or_else" do
34
34
 
35
35
  describe "#call" do
36
36
  context "first defined, second not" do
37
- subject { first_or_else_second.(4) }
37
+ subject { first_or_else_second.call(4) }
38
38
 
39
39
  it { is_expected.to eq("first: 4") }
40
40
  end
41
41
 
42
42
  context "first not defined, second defined" do
43
- subject { first_or_else_second.(9) }
43
+ subject { first_or_else_second.call(9) }
44
44
 
45
45
  it { is_expected.to eq("second: 9") }
46
46
  end
47
47
 
48
48
  context "first not defined, second not defined" do
49
- subject { -> { first_or_else_second.(5) } }
49
+ subject { -> { first_or_else_second.call(5) } }
50
50
 
51
51
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 5") }
52
52
  end
53
53
 
54
54
  context "first and second defined" do
55
- subject { first_or_else_second.(6) }
55
+ subject { first_or_else_second.call(6) }
56
56
 
57
57
  it { is_expected.to eq("first: 6") }
58
58
  end
@@ -124,31 +124,31 @@ RSpec.describe Fear::PartialFunction, "#or_else" do
124
124
 
125
125
  describe "#call" do
126
126
  context "first defined, second not" do
127
- subject { first_or_else_second_or_else_third.(4) }
127
+ subject { first_or_else_second_or_else_third.call(4) }
128
128
 
129
129
  it { is_expected.to eq("first: 4") }
130
130
  end
131
131
 
132
132
  context "first not defined, second defined" do
133
- subject { first_or_else_second_or_else_third.(9) }
133
+ subject { first_or_else_second_or_else_third.call(9) }
134
134
 
135
135
  it { is_expected.to eq("second: 9") }
136
136
  end
137
137
 
138
138
  context "first not defined, second not defined, third defined" do
139
- subject { first_or_else_second_or_else_third.(7) }
139
+ subject { first_or_else_second_or_else_third.call(7) }
140
140
 
141
141
  it { is_expected.to eq("third: 7") }
142
142
  end
143
143
 
144
144
  context "first not defined, second not defined, third not defined" do
145
- subject { -> { first_or_else_second_or_else_third.(1) } }
145
+ subject { -> { first_or_else_second_or_else_third.call(1) } }
146
146
 
147
147
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 1") }
148
148
  end
149
149
 
150
150
  context "first, second and third defined" do
151
- subject { first_or_else_second.(42) }
151
+ subject { first_or_else_second.call(42) }
152
152
 
153
153
  it { is_expected.to eq("first: 42") }
154
154
  end
@@ -221,25 +221,25 @@ RSpec.describe Fear::PartialFunction, "#or_else" do
221
221
 
222
222
  describe "#call" do
223
223
  context "first defined, second not" do
224
- subject { first_or_else_second_and_then_function.(2) }
224
+ subject { first_or_else_second_and_then_function.call(2) }
225
225
 
226
226
  it { is_expected.to eq("f: first: 2") }
227
227
  end
228
228
 
229
229
  context "first not defined, second defined" do
230
- subject { first_or_else_second_and_then_function.(3) }
230
+ subject { first_or_else_second_and_then_function.call(3) }
231
231
 
232
232
  it { is_expected.to eq("f: second: 3") }
233
233
  end
234
234
 
235
235
  context "first not defined, second not defined" do
236
- subject { -> { first_or_else_second_and_then_function.(5) } }
236
+ subject { -> { first_or_else_second_and_then_function.call(5) } }
237
237
 
238
238
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 5") }
239
239
  end
240
240
 
241
241
  context "first defined, second defined" do
242
- subject { first_or_else_second_and_then_function.(6) }
242
+ subject { first_or_else_second_and_then_function.call(6) }
243
243
 
244
244
  it { is_expected.to eq("f: first: 6") }
245
245
  end
@@ -80,13 +80,13 @@ RSpec.describe Fear::PartialFunction do
80
80
  let(:partial_function) { Fear.case(->(v) { v != 0 }) { |x| 4 / x } }
81
81
 
82
82
  context "defined" do
83
- subject { lifted.(2) }
83
+ subject { lifted.call(2) }
84
84
 
85
85
  it { is_expected.to eq(Fear::Some.new(2)) }
86
86
  end
87
87
 
88
88
  context "not defined" do
89
- subject { lifted.(0) }
89
+ subject { lifted.call(0) }
90
90
 
91
91
  it { is_expected.to eq(Fear::None) }
92
92
  end
@@ -108,13 +108,13 @@ RSpec.describe Fear::PartialFunction do
108
108
  let(:partial_function) { Fear.case(->(v) { v != 0 }) { |x| 4 / x } }
109
109
 
110
110
  context "defined" do
111
- subject { partial_function.(2) }
111
+ subject { partial_function.call(2) }
112
112
 
113
113
  it { is_expected.to eq(2) }
114
114
  end
115
115
 
116
116
  context "not defined" do
117
- subject { -> { partial_function.(0) } }
117
+ subject { -> { partial_function.call(0) } }
118
118
 
119
119
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 0") }
120
120
  end
@@ -124,13 +124,13 @@ RSpec.describe Fear::PartialFunction do
124
124
  let(:partial_function) { Fear.case(->(v) { v != 0 }) { |x| 4 / x }.to_proc }
125
125
 
126
126
  context "defined" do
127
- subject { partial_function.(2) }
127
+ subject { partial_function.call(2) }
128
128
 
129
129
  it { is_expected.to eq(2) }
130
130
  end
131
131
 
132
132
  context "not defined" do
133
- subject { -> { partial_function.(0) } }
133
+ subject { -> { partial_function.call(0) } }
134
134
 
135
135
  it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 0") }
136
136
  end
@@ -189,7 +189,7 @@ RSpec.describe Fear::PartialFunction do
189
189
  end
190
190
 
191
191
  shared_examples "#or_else" do |method_name|
192
- subject { is_even.__send__(method_name, is_odd).(value) }
192
+ subject { is_even.__send__(method_name, is_odd).call(value) }
193
193
 
194
194
  let(:is_even) { Fear.case(:even?.to_proc) { |x| "#{x} is even" } }
195
195
  let(:is_odd) { Fear.case(:odd?.to_proc) { |x| "#{x} is odd" } }
@@ -11,26 +11,26 @@ RSpec.describe Fear::PatternMatch do
11
11
  end
12
12
 
13
13
  context "Integer" do
14
- subject { matcher.(4) }
14
+ subject { matcher.call(4) }
15
15
 
16
16
  it { is_expected.to eq("4 is int") }
17
17
  end
18
18
 
19
19
  context "String" do
20
- subject { matcher.("4") }
20
+ subject { matcher.call("4") }
21
21
 
22
22
  it { is_expected.to eq("4 is str") }
23
23
  end
24
24
 
25
25
  context "Symbol" do
26
- subject { matcher.(:a) }
26
+ subject { matcher.call(:a) }
27
27
 
28
28
  it { is_expected.to eq("a is something else") }
29
29
  end
30
30
  end
31
31
 
32
32
  context "else before other branches" do
33
- subject { matcher.(4) }
33
+ subject { matcher.call(4) }
34
34
 
35
35
  let(:matcher) do
36
36
  described_class.new do |m|
@@ -43,7 +43,7 @@ RSpec.describe Fear::PatternMatch do
43
43
  end
44
44
 
45
45
  context "several else branches" do
46
- subject { matcher.(4) }
46
+ subject { matcher.call(4) }
47
47
 
48
48
  let(:matcher) do
49
49
  described_class.new do |m|