fear 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -60
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +7 -1
  5. data/Gemfile +5 -3
  6. data/Gemfile.lock +18 -20
  7. data/README.md +28 -14
  8. data/Rakefile +61 -60
  9. data/examples/pattern_extracting.rb +8 -6
  10. data/examples/pattern_matching_binary_tree_set.rb +4 -2
  11. data/examples/pattern_matching_number_in_words.rb +46 -42
  12. data/fear.gemspec +29 -27
  13. data/lib/fear.rb +44 -37
  14. data/lib/fear/await.rb +33 -0
  15. data/lib/fear/awaitable.rb +28 -0
  16. data/lib/fear/either.rb +2 -0
  17. data/lib/fear/either_api.rb +2 -0
  18. data/lib/fear/either_pattern_match.rb +2 -0
  19. data/lib/fear/empty_partial_function.rb +3 -1
  20. data/lib/fear/extractor.rb +30 -28
  21. data/lib/fear/extractor/anonymous_array_splat_matcher.rb +2 -0
  22. data/lib/fear/extractor/any_matcher.rb +2 -0
  23. data/lib/fear/extractor/array_head_matcher.rb +2 -0
  24. data/lib/fear/extractor/array_matcher.rb +2 -0
  25. data/lib/fear/extractor/array_splat_matcher.rb +2 -0
  26. data/lib/fear/extractor/empty_list_matcher.rb +2 -0
  27. data/lib/fear/extractor/extractor_matcher.rb +5 -3
  28. data/lib/fear/extractor/grammar.rb +5 -3
  29. data/lib/fear/extractor/identifier_matcher.rb +2 -0
  30. data/lib/fear/extractor/matcher.rb +5 -3
  31. data/lib/fear/extractor/matcher/and.rb +3 -1
  32. data/lib/fear/extractor/named_array_splat_matcher.rb +2 -0
  33. data/lib/fear/extractor/pattern.rb +7 -5
  34. data/lib/fear/extractor/typed_identifier_matcher.rb +2 -0
  35. data/lib/fear/extractor/value_matcher.rb +2 -0
  36. data/lib/fear/extractor_api.rb +2 -0
  37. data/lib/fear/failure.rb +2 -0
  38. data/lib/fear/failure_pattern_match.rb +2 -0
  39. data/lib/fear/for.rb +4 -2
  40. data/lib/fear/for_api.rb +3 -1
  41. data/lib/fear/future.rb +141 -64
  42. data/lib/fear/future_api.rb +2 -0
  43. data/lib/fear/left.rb +3 -1
  44. data/lib/fear/left_pattern_match.rb +2 -0
  45. data/lib/fear/none.rb +4 -2
  46. data/lib/fear/none_pattern_match.rb +2 -0
  47. data/lib/fear/option.rb +3 -1
  48. data/lib/fear/option_api.rb +2 -0
  49. data/lib/fear/option_pattern_match.rb +2 -0
  50. data/lib/fear/partial_function.rb +10 -8
  51. data/lib/fear/partial_function/and_then.rb +4 -2
  52. data/lib/fear/partial_function/any.rb +2 -0
  53. data/lib/fear/partial_function/combined.rb +3 -1
  54. data/lib/fear/partial_function/empty.rb +2 -0
  55. data/lib/fear/partial_function/guard.rb +7 -5
  56. data/lib/fear/partial_function/guard/and.rb +2 -0
  57. data/lib/fear/partial_function/guard/and3.rb +2 -0
  58. data/lib/fear/partial_function/guard/or.rb +2 -0
  59. data/lib/fear/partial_function/lifted.rb +2 -0
  60. data/lib/fear/partial_function/or_else.rb +3 -1
  61. data/lib/fear/partial_function_class.rb +3 -1
  62. data/lib/fear/pattern_match.rb +3 -1
  63. data/lib/fear/pattern_matching_api.rb +3 -1
  64. data/lib/fear/promise.rb +11 -3
  65. data/lib/fear/right.rb +3 -1
  66. data/lib/fear/right_biased.rb +4 -2
  67. data/lib/fear/right_pattern_match.rb +2 -0
  68. data/lib/fear/some.rb +2 -0
  69. data/lib/fear/some_pattern_match.rb +2 -0
  70. data/lib/fear/struct.rb +235 -0
  71. data/lib/fear/success.rb +2 -0
  72. data/lib/fear/success_pattern_match.rb +2 -0
  73. data/lib/fear/try.rb +2 -0
  74. data/lib/fear/try_api.rb +2 -0
  75. data/lib/fear/try_pattern_match.rb +2 -0
  76. data/lib/fear/unit.rb +6 -2
  77. data/lib/fear/utils.rb +4 -2
  78. data/lib/fear/version.rb +4 -1
  79. data/spec/fear/done_spec.rb +7 -5
  80. data/spec/fear/either/mixin_spec.rb +4 -2
  81. data/spec/fear/either_pattern_match_spec.rb +10 -8
  82. data/spec/fear/extractor/array_matcher_spec.rb +65 -63
  83. data/spec/fear/extractor/extractor_matcher_spec.rb +64 -62
  84. data/spec/fear/extractor/grammar_array_spec.rb +5 -3
  85. data/spec/fear/extractor/identified_matcher_spec.rb +18 -16
  86. data/spec/fear/extractor/identifier_matcher_spec.rb +26 -24
  87. data/spec/fear/extractor/pattern_spec.rb +17 -15
  88. data/spec/fear/extractor/typed_identifier_matcher_spec.rb +23 -21
  89. data/spec/fear/extractor/value_matcher_number_spec.rb +29 -27
  90. data/spec/fear/extractor/value_matcher_string_spec.rb +27 -25
  91. data/spec/fear/extractor/value_matcher_symbol_spec.rb +24 -22
  92. data/spec/fear/extractor_api_spec.rb +70 -68
  93. data/spec/fear/extractor_spec.rb +23 -21
  94. data/spec/fear/failure_spec.rb +59 -57
  95. data/spec/fear/for_spec.rb +19 -17
  96. data/spec/fear/future_spec.rb +456 -240
  97. data/spec/fear/guard_spec.rb +26 -24
  98. data/spec/fear/left_spec.rb +60 -58
  99. data/spec/fear/none_spec.rb +36 -34
  100. data/spec/fear/option/mixin_spec.rb +9 -7
  101. data/spec/fear/option_pattern_match_spec.rb +10 -8
  102. data/spec/fear/partial_function/empty_spec.rb +12 -10
  103. data/spec/fear/partial_function_and_then_spec.rb +39 -37
  104. data/spec/fear/partial_function_composition_spec.rb +46 -44
  105. data/spec/fear/partial_function_or_else_spec.rb +92 -90
  106. data/spec/fear/partial_function_spec.rb +46 -44
  107. data/spec/fear/pattern_match_spec.rb +31 -29
  108. data/spec/fear/promise_spec.rb +19 -17
  109. data/spec/fear/right_biased/left.rb +28 -26
  110. data/spec/fear/right_biased/right.rb +51 -49
  111. data/spec/fear/right_spec.rb +58 -56
  112. data/spec/fear/some_spec.rb +30 -28
  113. data/spec/fear/success_spec.rb +50 -48
  114. data/spec/fear/try/mixin_spec.rb +5 -3
  115. data/spec/fear/try_pattern_match_spec.rb +10 -8
  116. data/spec/fear/utils_spec.rb +16 -14
  117. data/spec/spec_helper.rb +7 -5
  118. data/spec/struct_spec.rb +226 -0
  119. metadata +18 -13
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Extractor do
2
- describe '.register_extractor' do
3
- Foo = Struct.new(:v1, :v2)
4
+ describe ".register_extractor" do
5
+ Foo = ::Struct.new(:v1, :v2)
4
6
  let(:matcher) do
5
7
  Fear.matcher do |m|
6
- m.case(Fear['Foo(43, second : Integer)']) { |second| "43 and #{second}" }
7
- m.case(Fear['Foo(42, second : Integer)']) { |second| "42 and #{second}" }
8
- m.else { 'no match' }
8
+ m.case(Fear["Foo(43, second : Integer)"]) { |second| "43 and #{second}" }
9
+ m.case(Fear["Foo(42, second : Integer)"]) { |second| "42 and #{second}" }
10
+ m.else { "no match" }
9
11
  end
10
12
  end
11
13
 
@@ -13,46 +15,46 @@ RSpec.describe Fear::Extractor do
13
15
  Fear.case(Foo) { |foo| [foo.v1, foo.v2] }.lift
14
16
  end
15
17
 
16
- context 'extractor not registered' do
17
- it 'raise Fear::Extractor::ExtractorNotFound' do
18
+ context "extractor not registered" do
19
+ it "raise Fear::Extractor::ExtractorNotFound" do
18
20
  expect do
19
- described_class.find_extractor('UnknownExtractor')
21
+ described_class.find_extractor("UnknownExtractor")
20
22
  end.to raise_error(Fear::Extractor::ExtractorNotFound)
21
23
  end
22
24
  end
23
25
 
24
- context 'register by name' do
25
- let(:extractor) { ->(*) { Fear.some('matched') } }
26
+ context "register by name" do
27
+ let(:extractor) { ->(*) { Fear.some("matched") } }
26
28
 
27
29
  before do
28
30
  described_class.register_extractor(
29
- 'ExtractorRegisteredByName',
30
- 'ExtractorRegisteredByName2',
31
+ "ExtractorRegisteredByName",
32
+ "ExtractorRegisteredByName2",
31
33
  extractor,
32
34
  )
33
35
  end
34
36
 
35
- it 'returns extractor' do
36
- expect(described_class.find_extractor('ExtractorRegisteredByName')).to eq(extractor)
37
- expect(described_class.find_extractor('ExtractorRegisteredByName2')).to eq(extractor)
37
+ it "returns extractor" do
38
+ expect(described_class.find_extractor("ExtractorRegisteredByName")).to eq(extractor)
39
+ expect(described_class.find_extractor("ExtractorRegisteredByName2")).to eq(extractor)
38
40
  end
39
41
  end
40
42
 
41
- context 'register by class' do
42
- let(:extractor) { ->(*) { Fear.some('matched') } }
43
+ context "register by class" do
44
+ let(:extractor) { ->(*) { Fear.some("matched") } }
43
45
  ExtractorRegisteredByClass = Class.new
44
46
 
45
47
  before do
46
48
  described_class.register_extractor(
47
49
  ExtractorRegisteredByClass,
48
- 'ExtractorRegisteredByClass2',
50
+ "ExtractorRegisteredByClass2",
49
51
  extractor,
50
52
  )
51
53
  end
52
54
 
53
- it 'returns extractor' do
54
- expect(described_class.find_extractor('ExtractorRegisteredByClass')).to eq(extractor)
55
- expect(described_class.find_extractor('ExtractorRegisteredByClass2')).to eq(extractor)
55
+ it "returns extractor" do
56
+ expect(described_class.find_extractor("ExtractorRegisteredByClass")).to eq(extractor)
57
+ expect(described_class.find_extractor("ExtractorRegisteredByClass2")).to eq(extractor)
56
58
  end
57
59
  end
58
60
  end
@@ -1,155 +1,157 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Failure do
2
- let(:exception) { RuntimeError.new('error') }
4
+ let(:exception) { RuntimeError.new("error") }
3
5
  let(:failure) { Fear.failure(exception) }
4
6
 
5
7
  it_behaves_like Fear::RightBiased::Left do
6
8
  let(:left) { failure }
7
9
  end
8
10
 
9
- describe '#exception' do
11
+ describe "#exception" do
10
12
  subject { failure.exception }
11
13
  it { is_expected.to eq(exception) }
12
14
  end
13
15
 
14
- describe '#success?' do
16
+ describe "#success?" do
15
17
  subject { failure }
16
18
  it { is_expected.not_to be_success }
17
19
  end
18
20
 
19
- describe '#failure?' do
21
+ describe "#failure?" do
20
22
  subject { failure }
21
23
  it { is_expected.to be_failure }
22
24
  end
23
25
 
24
- describe '#get' do
26
+ describe "#get" do
25
27
  subject { proc { failure.get } }
26
- it { is_expected.to raise_error(RuntimeError, 'error') }
28
+ it { is_expected.to raise_error(RuntimeError, "error") }
27
29
  end
28
30
 
29
- describe '#or_else' do
30
- context 'default does not fail' do
31
- subject { failure.or_else { Fear::Success.new('value') } }
32
- it { is_expected.to eq(Fear::Success.new('value')) }
31
+ describe "#or_else" do
32
+ context "default does not fail" do
33
+ subject { failure.or_else { Fear::Success.new("value") } }
34
+ it { is_expected.to eq(Fear::Success.new("value")) }
33
35
  end
34
36
 
35
- context 'default fails with error' do
36
- subject(:or_else) { failure.or_else { raise 'unexpected error' } }
37
+ context "default fails with error" do
38
+ subject(:or_else) { failure.or_else { raise "unexpected error" } }
37
39
  it { is_expected.to be_kind_of(described_class) }
38
- it { expect { or_else.get }.to raise_error(RuntimeError, 'unexpected error') }
40
+ it { expect { or_else.get }.to raise_error(RuntimeError, "unexpected error") }
39
41
  end
40
42
  end
41
43
 
42
- describe '#flatten' do
44
+ describe "#flatten" do
43
45
  subject { failure.flatten }
44
46
  it { is_expected.to eq(failure) }
45
47
  end
46
48
 
47
- describe '#select' do
48
- subject { failure.select { |v| v == 'value' } }
49
+ describe "#select" do
50
+ subject { failure.select { |v| v == "value" } }
49
51
  it { is_expected.to eq(failure) }
50
52
  end
51
53
 
52
- context '#recover_with' do
53
- context 'block matches the error and does not fail' do
54
+ context "#recover_with" do
55
+ context "block matches the error and does not fail" do
54
56
  subject do
55
57
  failure.recover_with do |m|
56
58
  m.case(RuntimeError) { |error| Fear.success(error.message) }
57
59
  end
58
60
  end
59
61
 
60
- it 'returns result of evaluation of the block against the error' do
61
- is_expected.to eq(Fear::Success.new('error'))
62
+ it "returns result of evaluation of the block against the error" do
63
+ is_expected.to eq(Fear::Success.new("error"))
62
64
  end
63
65
  end
64
66
 
65
- context 'block does not match the error' do
67
+ context "block does not match the error" do
66
68
  subject do
67
69
  failure.recover_with do |m|
68
70
  m.case(ZeroDivisionError) { Fear.success(0) }
69
71
  end
70
72
  end
71
73
 
72
- it 'returns the same failure' do
74
+ it "returns the same failure" do
73
75
  is_expected.to eq(failure)
74
76
  end
75
77
  end
76
78
 
77
- context 'block fails' do
78
- subject(:recover_with) { failure.recover_with { raise 'unexpected error' } }
79
+ context "block fails" do
80
+ subject(:recover_with) { failure.recover_with { raise "unexpected error" } }
79
81
 
80
82
  it { is_expected.to be_kind_of(described_class) }
81
- it { expect { recover_with.get }.to raise_error(RuntimeError, 'unexpected error') }
83
+ it { expect { recover_with.get }.to raise_error(RuntimeError, "unexpected error") }
82
84
  end
83
85
  end
84
86
 
85
- context '#recover' do
86
- context 'block matches the error and does not fail' do
87
+ context "#recover" do
88
+ context "block matches the error and does not fail" do
87
89
  subject do
88
90
  failure.recover do |m|
89
91
  m.case(RuntimeError, &:message)
90
92
  end
91
93
  end
92
94
 
93
- it 'returns Success of evaluation of the block against the error' do
94
- is_expected.to eq(Fear.success('error'))
95
+ it "returns Success of evaluation of the block against the error" do
96
+ is_expected.to eq(Fear.success("error"))
95
97
  end
96
98
  end
97
99
 
98
- context 'block does not match the error' do
100
+ context "block does not match the error" do
99
101
  subject do
100
102
  failure.recover do |m|
101
103
  m.case(ZeroDivisionError, &:message)
102
104
  end
103
105
  end
104
106
 
105
- it 'returns the same failure' do
107
+ it "returns the same failure" do
106
108
  is_expected.to eq(failure)
107
109
  end
108
110
  end
109
111
 
110
- context 'block fails' do
112
+ context "block fails" do
111
113
  subject(:recover) do
112
114
  failure.recover do
113
- raise 'unexpected error'
115
+ raise "unexpected error"
114
116
  end
115
117
  end
116
118
 
117
119
  it { is_expected.to be_kind_of(described_class) }
118
- it { expect { recover.get }.to raise_error(RuntimeError, 'unexpected error') }
120
+ it { expect { recover.get }.to raise_error(RuntimeError, "unexpected error") }
119
121
  end
120
122
  end
121
123
 
122
- describe '#to_either' do
124
+ describe "#to_either" do
123
125
  subject { failure.to_either }
124
126
  it { is_expected.to eq(Fear.left(exception)) }
125
127
  end
126
128
 
127
- describe '#===' do
129
+ describe "#===" do
128
130
  subject { match === failure }
129
131
 
130
- context 'matches erectly' do
132
+ context "matches erectly" do
131
133
  let(:match) { Fear.failure(exception) }
132
134
  it { is_expected.to eq(true) }
133
135
  end
134
136
 
135
- context 'value does not match' do
137
+ context "value does not match" do
136
138
  let(:match) { Fear.failure(ArgumentError.new) }
137
139
  it { is_expected.to eq(false) }
138
140
  end
139
141
 
140
- context 'matches by class' do
142
+ context "matches by class" do
141
143
  let(:match) { Fear.failure(RuntimeError) }
142
144
  it { is_expected.to eq(true) }
143
145
  end
144
146
 
145
- context 'does not matches by class' do
147
+ context "does not matches by class" do
146
148
  let(:match) { Fear.failure(ArgumentError) }
147
149
  it { is_expected.to eq(false) }
148
150
  end
149
151
  end
150
152
 
151
- describe '#match' do
152
- context 'matched' do
153
+ describe "#match" do
154
+ context "matched" do
153
155
  subject do
154
156
  failure.match do |m|
155
157
  m.failure(->(x) { x.message.length < 2 }) { |x| "Error: #{x}" }
@@ -158,15 +160,15 @@ RSpec.describe Fear::Failure do
158
160
  end
159
161
  end
160
162
 
161
- it { is_expected.to eq('Error: error') }
163
+ it { is_expected.to eq("Error: error") }
162
164
  end
163
165
 
164
- context 'nothing matched and no else given' do
166
+ context "nothing matched and no else given" do
165
167
  subject do
166
168
  proc do
167
169
  failure.match do |m|
168
170
  m.failure(->(x) { x.message.length < 2 }) { |x| "Error: #{x}" }
169
- m.success { 'noop' }
171
+ m.success { "noop" }
170
172
  end
171
173
  end
172
174
  end
@@ -174,7 +176,7 @@ RSpec.describe Fear::Failure do
174
176
  it { is_expected.to raise_error(Fear::MatchError) }
175
177
  end
176
178
 
177
- context 'nothing matched and else given' do
179
+ context "nothing matched and else given" do
178
180
  subject do
179
181
  failure.match do |m|
180
182
  m.failure(->(x) { x.message.length < 2 }) { |x| "Error: #{x}" }
@@ -186,31 +188,31 @@ RSpec.describe Fear::Failure do
186
188
  end
187
189
  end
188
190
 
189
- describe '#to_s' do
191
+ describe "#to_s" do
190
192
  subject { failure.to_s }
191
193
 
192
- it { is_expected.to eq('#<Fear::Failure exception=#<RuntimeError: error>>') }
194
+ it { is_expected.to eq("#<Fear::Failure exception=#<RuntimeError: error>>") }
193
195
  end
194
196
 
195
- describe 'pattern matching' do
196
- subject { Fear.xcase('Failure(v : ArgumentError)') { 'matched' }.call_or_else(var) { 'nothing' } }
197
+ describe "pattern matching" do
198
+ subject { Fear.xcase("Failure(v : ArgumentError)") { "matched" }.call_or_else(var) { "nothing" } }
197
199
 
198
- context 'failure of ArgumentError' do
200
+ context "failure of ArgumentError" do
199
201
  let(:var) { Fear.failure(ArgumentError.new) }
200
202
 
201
- it { is_expected.to eq('matched') }
203
+ it { is_expected.to eq("matched") }
202
204
  end
203
205
 
204
- context 'failure of RuntimeError' do
206
+ context "failure of RuntimeError" do
205
207
  let(:var) { Fear.failure(RuntimeError.new) }
206
208
 
207
- it { is_expected.to eq('nothing') }
209
+ it { is_expected.to eq("nothing") }
208
210
  end
209
211
 
210
- context 'not failure' do
211
- let(:var) { '42' }
212
+ context "not failure" do
213
+ let(:var) { "42" }
212
214
 
213
- it { is_expected.to eq('nothing') }
215
+ it { is_expected.to eq("nothing") }
214
216
  end
215
217
  end
216
218
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::For do
2
- context 'unary' do
3
- context 'Some' do
4
+ context "unary" do
5
+ context "Some" do
4
6
  subject do
5
7
  Fear.for(Fear.some(2)) { |a| a * 2 }
6
8
  end
@@ -8,7 +10,7 @@ RSpec.describe Fear::For do
8
10
  it { is_expected.to eq(Fear.some(4)) }
9
11
  end
10
12
 
11
- context 'None' do
13
+ context "None" do
12
14
  subject do
13
15
  Fear.for(Fear.none) { |a| a * 2 }
14
16
  end
@@ -17,7 +19,7 @@ RSpec.describe Fear::For do
17
19
  end
18
20
  end
19
21
 
20
- context 'arrays' do
22
+ context "arrays" do
21
23
  subject do
22
24
  Fear.for([1, 2], [2, 3], [3, 4]) do |a, b, c|
23
25
  a * b * c
@@ -27,14 +29,14 @@ RSpec.describe Fear::For do
27
29
  it { is_expected.to eq([6, 8, 9, 12, 12, 16, 18, 24]) }
28
30
  end
29
31
 
30
- context 'ternary' do
32
+ context "ternary" do
31
33
  subject do
32
34
  Fear.for(first, second, third) do |a, b, c|
33
35
  a * b * c
34
36
  end
35
37
  end
36
38
 
37
- context 'all Same' do
39
+ context "all Same" do
38
40
  let(:first) { Fear.some(2) }
39
41
  let(:second) { Fear.some(3) }
40
42
  let(:third) { Fear.some(4) }
@@ -42,7 +44,7 @@ RSpec.describe Fear::For do
42
44
  it { is_expected.to eq(Fear.some(24)) }
43
45
  end
44
46
 
45
- context 'first is None' do
47
+ context "first is None" do
46
48
  let(:first) { Fear.none }
47
49
  let(:second) { Fear.some(3) }
48
50
  let(:third) { Fear.some(4) }
@@ -50,7 +52,7 @@ RSpec.describe Fear::For do
50
52
  it { is_expected.to eq(Fear.none) }
51
53
  end
52
54
 
53
- context 'second is None' do
55
+ context "second is None" do
54
56
  let(:first) { Fear.some(2) }
55
57
  let(:second) { Fear.none }
56
58
  let(:third) { Fear.some(4) }
@@ -58,7 +60,7 @@ RSpec.describe Fear::For do
58
60
  it { is_expected.to eq(Fear.none) }
59
61
  end
60
62
 
61
- context 'last is None' do
63
+ context "last is None" do
62
64
  let(:first) { Fear.some(2) }
63
65
  let(:second) { Fear.some(3) }
64
66
  let(:third) { Fear.none }
@@ -66,7 +68,7 @@ RSpec.describe Fear::For do
66
68
  it { is_expected.to eq(Fear.none) }
67
69
  end
68
70
 
69
- context 'all Same in lambdas' do
71
+ context "all Same in lambdas" do
70
72
  let(:first) { proc { Fear.some(2) } }
71
73
  let(:second) { proc { Fear.some(3) } }
72
74
  let(:third) { proc { Fear.some(4) } }
@@ -74,28 +76,28 @@ RSpec.describe Fear::For do
74
76
  it { is_expected.to eq(Fear.some(24)) }
75
77
  end
76
78
 
77
- context 'first is None in lambda, second is failure in lambda' do
79
+ context "first is None in lambda, second is failure in lambda" do
78
80
  let(:first) { proc { Fear.none } }
79
- let(:second) { proc { raise 'kaboom' } }
81
+ let(:second) { proc { raise "kaboom" } }
80
82
  let(:third) { proc {} }
81
83
 
82
- it 'returns None without evaluating second and third' do
84
+ it "returns None without evaluating second and third" do
83
85
  is_expected.to eq(Fear.none)
84
86
  end
85
87
  end
86
88
 
87
- context 'second is None in lambda, third is failure in lambda' do
89
+ context "second is None in lambda, third is failure in lambda" do
88
90
  let(:first) { Fear.some(2) }
89
91
  let(:second) { proc { Fear.none } }
90
- let(:third) { proc { raise 'kaboom' } }
92
+ let(:third) { proc { raise "kaboom" } }
91
93
 
92
- it 'returns None without evaluating third' do
94
+ it "returns None without evaluating third" do
93
95
  is_expected.to eq(Fear.none)
94
96
  end
95
97
  end
96
98
  end
97
99
 
98
- context 'refer to previous variable from lambda' do
100
+ context "refer to previous variable from lambda" do
99
101
  subject do
100
102
  Fear.for(first, second, third) do |_, b, c|
101
103
  b * c