fear 1.0.0 → 1.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 (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,76 +1,78 @@
1
- RSpec.describe Fear::Extractor::ValueMatcher, 'Number' do
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Fear::Extractor::ValueMatcher, "Number" do
2
4
  let(:parser) { Fear::Extractor::GrammarParser.new }
3
5
  let(:matcher) { parser.parse(pattern).to_matcher }
4
6
 
5
- describe '#defined_at?' do
7
+ describe "#defined_at?" do
6
8
  subject { matcher }
7
9
 
8
- context 'Integer' do
9
- let(:pattern) { '1' }
10
+ context "Integer" do
11
+ let(:pattern) { "1" }
10
12
 
11
13
  it { is_expected.to be_defined_at(1) }
12
14
  it { is_expected.to be_defined_at(1.0) }
13
15
  it { is_expected.not_to be_defined_at(2) }
14
- it { is_expected.not_to be_defined_at('1') }
16
+ it { is_expected.not_to be_defined_at("1") }
15
17
  end
16
18
 
17
- context 'Float' do
18
- context 'against float' do
19
- let(:pattern) { '1.2' }
19
+ context "Float" do
20
+ context "against float" do
21
+ let(:pattern) { "1.2" }
20
22
 
21
23
  it { is_expected.to be_defined_at(1.2) }
22
24
  it { is_expected.not_to be_defined_at(1.3) }
23
25
  end
24
26
 
25
- context 'against integer' do
26
- let(:pattern) { '1.0' }
27
+ context "against integer" do
28
+ let(:pattern) { "1.0" }
27
29
 
28
30
  it { is_expected.to be_defined_at(1) }
29
31
  it { is_expected.not_to be_defined_at(2) }
30
- it { is_expected.not_to be_defined_at('1') }
32
+ it { is_expected.not_to be_defined_at("1") }
31
33
  end
32
34
  end
33
35
  end
34
36
 
35
- describe '#call' do
36
- subject { matcher.call(other) }
37
+ describe "#call" do
38
+ subject { matcher.(other) }
37
39
 
38
- let(:pattern) { '1.0' }
40
+ let(:pattern) { "1.0" }
39
41
 
40
- context 'defined' do
42
+ context "defined" do
41
43
  let(:other) { 1 }
42
44
 
43
45
  it { is_expected.to eq({}) }
44
46
  end
45
47
  end
46
48
 
47
- describe '#failure_reason' do
49
+ describe "#failure_reason" do
48
50
  subject { matcher.failure_reason(other) }
49
51
 
50
- let(:pattern) { '1.0' }
52
+ let(:pattern) { "1.0" }
51
53
 
52
- context 'match integer' do
54
+ context "match integer" do
53
55
  let(:other) { 1 }
54
- let(:pattern) { '1' }
56
+ let(:pattern) { "1" }
55
57
 
56
58
  it { is_expected.to eq(Fear.none) }
57
59
  end
58
60
 
59
- context 'match float' do
61
+ context "match float" do
60
62
  let(:other) { 1.0 }
61
- let(:pattern) { '1' }
63
+ let(:pattern) { "1" }
62
64
 
63
65
  it { is_expected.to eq(Fear.none) }
64
66
  end
65
67
 
66
- context 'does not match another integer' do
68
+ context "does not match another integer" do
67
69
  let(:other) { 2 }
68
- let(:pattern) { '1' }
70
+ let(:pattern) { "1" }
69
71
 
70
- it { is_expected.to eq(Fear.some(<<-ERROR.strip)) }
71
- Expected `2` to match:
72
- 1
73
- ^
72
+ it { is_expected.to eq(Fear.some(<<~ERROR.strip)) }
73
+ Expected `2` to match:
74
+ 1
75
+ ^
74
76
  ERROR
75
77
  end
76
78
  end
@@ -1,25 +1,27 @@
1
- RSpec.describe Fear::Extractor::ValueMatcher, 'String' do
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Fear::Extractor::ValueMatcher, "String" do
2
4
  let(:parser) { Fear::Extractor::GrammarParser.new }
3
5
  let(:matcher) { parser.parse(pattern).to_matcher }
4
6
 
5
- describe '#defined_at?' do
7
+ describe "#defined_at?" do
6
8
  subject { matcher }
7
9
 
8
- context 'double quotas' do
10
+ context "double quotas" do
9
11
  let(:pattern) { %("foo") }
10
12
 
11
- it { is_expected.to be_defined_at('foo') }
12
- it { is_expected.not_to be_defined_at('boo') }
13
+ it { is_expected.to be_defined_at("foo") }
14
+ it { is_expected.not_to be_defined_at("boo") }
13
15
  it { is_expected.not_to be_defined_at(2) }
14
16
 
15
- context 'single quotes inside' do
17
+ context "single quotes inside" do
16
18
  let(:pattern) { %("f'o'o") }
17
19
 
18
20
  it { is_expected.to be_defined_at(%(f'o'o)) }
19
21
  it { is_expected.not_to be_defined_at(%(f"o"o)) }
20
22
  end
21
23
 
22
- context 'escaped double quotes inside' do
24
+ context "escaped double quotes inside" do
23
25
  let(:pattern) { '"f\"oo"' }
24
26
 
25
27
  it { is_expected.to be_defined_at('f"oo') }
@@ -27,21 +29,21 @@ RSpec.describe Fear::Extractor::ValueMatcher, 'String' do
27
29
  end
28
30
  end
29
31
 
30
- context 'single quotas' do
32
+ context "single quotas" do
31
33
  let(:pattern) { %('foo') }
32
34
 
33
- it { is_expected.to be_defined_at('foo') }
34
- it { is_expected.not_to be_defined_at('boo') }
35
+ it { is_expected.to be_defined_at("foo") }
36
+ it { is_expected.not_to be_defined_at("boo") }
35
37
  it { is_expected.not_to be_defined_at(2) }
36
38
 
37
- context 'double quotes inside' do
39
+ context "double quotes inside" do
38
40
  let(:pattern) { %('f"o"o') }
39
41
 
40
42
  it { is_expected.to be_defined_at(%(f"o"o)) }
41
43
  it { is_expected.not_to be_defined_at(%(f'o'o)) }
42
44
  end
43
45
 
44
- context 'escaped single quotes inside' do
46
+ context "escaped single quotes inside" do
45
47
  let(:pattern) { "'f\\'oo'" }
46
48
 
47
49
  it { is_expected.to be_defined_at("f\\'oo") }
@@ -50,36 +52,36 @@ RSpec.describe Fear::Extractor::ValueMatcher, 'String' do
50
52
  end
51
53
  end
52
54
 
53
- describe '#call' do
54
- subject { matcher.call(other) }
55
+ describe "#call" do
56
+ subject { matcher.(other) }
55
57
 
56
58
  let(:pattern) { '"foo"' }
57
59
 
58
- context 'defined' do
59
- let(:other) { 'foo' }
60
+ context "defined" do
61
+ let(:other) { "foo" }
60
62
 
61
63
  it { is_expected.to eq({}) }
62
64
  end
63
65
  end
64
66
 
65
- describe '#failure_reason' do
67
+ describe "#failure_reason" do
66
68
  subject { matcher.failure_reason(other) }
67
69
 
68
- context 'match' do
69
- let(:other) { 'foo' }
70
+ context "match" do
71
+ let(:other) { "foo" }
70
72
  let(:pattern) { '"foo"' }
71
73
 
72
74
  it { is_expected.to eq(Fear.none) }
73
75
  end
74
76
 
75
- context 'does not match' do
76
- let(:other) { 'bar' }
77
+ context "does not match" do
78
+ let(:other) { "bar" }
77
79
  let(:pattern) { '"foo"' }
78
80
 
79
- it { is_expected.to eq(Fear.some(<<-ERROR.strip)) }
80
- Expected `"bar"` to match:
81
- "foo"
82
- ^
81
+ it { is_expected.to eq(Fear.some(<<~ERROR.strip)) }
82
+ Expected `"bar"` to match:
83
+ "foo"
84
+ ^
83
85
  ERROR
84
86
  end
85
87
  end
@@ -1,68 +1,70 @@
1
- RSpec.describe Fear::Extractor::ValueMatcher, 'Symbol' do
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Fear::Extractor::ValueMatcher, "Symbol" do
2
4
  let(:parser) { Fear::Extractor::GrammarParser.new }
3
5
  let(:matcher) { parser.parse(pattern).to_matcher }
4
6
 
5
- describe '#defined_at?' do
7
+ describe "#defined_at?" do
6
8
  subject { matcher }
7
9
 
8
- context 'no quotas' do
9
- let(:pattern) { ':foo' }
10
+ context "no quotas" do
11
+ let(:pattern) { ":foo" }
10
12
 
11
13
  it { is_expected.to be_defined_at(:foo) }
12
- it { is_expected.not_to be_defined_at('foo') }
14
+ it { is_expected.not_to be_defined_at("foo") }
13
15
  it { is_expected.not_to be_defined_at(:boo) }
14
16
  it { is_expected.not_to be_defined_at(2) }
15
17
  end
16
18
 
17
- context 'double quotas' do
19
+ context "double quotas" do
18
20
  let(:pattern) { %(:"foo") }
19
21
 
20
22
  it { is_expected.to be_defined_at(:foo) }
21
- it { is_expected.not_to be_defined_at('foo') }
23
+ it { is_expected.not_to be_defined_at("foo") }
22
24
  it { is_expected.not_to be_defined_at(:boo) }
23
25
  it { is_expected.not_to be_defined_at(2) }
24
26
  end
25
27
 
26
- context 'single quotas' do
28
+ context "single quotas" do
27
29
  let(:pattern) { %(:'foo') }
28
30
 
29
31
  it { is_expected.to be_defined_at(:foo) }
30
- it { is_expected.not_to be_defined_at('foo') }
32
+ it { is_expected.not_to be_defined_at("foo") }
31
33
  it { is_expected.not_to be_defined_at(:boo) }
32
34
  it { is_expected.not_to be_defined_at(2) }
33
35
  end
34
36
  end
35
37
 
36
- describe '#call' do
37
- subject { matcher.call(other) }
38
+ describe "#call" do
39
+ subject { matcher.(other) }
38
40
 
39
- let(:pattern) { ':foo' }
41
+ let(:pattern) { ":foo" }
40
42
 
41
- context 'defined' do
43
+ context "defined" do
42
44
  let(:other) { :foo }
43
45
 
44
46
  it { is_expected.to eq({}) }
45
47
  end
46
48
  end
47
49
 
48
- describe '#failure_reason' do
50
+ describe "#failure_reason" do
49
51
  subject { matcher.failure_reason(other) }
50
52
 
51
- context 'match' do
53
+ context "match" do
52
54
  let(:other) { :foo }
53
- let(:pattern) { ':foo' }
55
+ let(:pattern) { ":foo" }
54
56
 
55
57
  it { is_expected.to eq(Fear.none) }
56
58
  end
57
59
 
58
- context 'does not match' do
60
+ context "does not match" do
59
61
  let(:other) { :bar }
60
- let(:pattern) { ':foo' }
62
+ let(:pattern) { ":foo" }
61
63
 
62
- it { is_expected.to eq(Fear.some(<<-ERROR.strip)) }
63
- Expected `:bar` to match:
64
- :foo
65
- ^
64
+ it { is_expected.to eq(Fear.some(<<~ERROR.strip)) }
65
+ Expected `:bar` to match:
66
+ :foo
67
+ ^
66
68
  ERROR
67
69
  end
68
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::ExtractorApi do
2
4
  def assert(value)
3
5
  expect(value).to eq(true)
@@ -17,97 +19,97 @@ RSpec.describe Fear::ExtractorApi do
17
19
  expect { yield }.not_to raise_error
18
20
  end
19
21
 
20
- specify 'Array' do
21
- assert(Fear['[]'] === [])
22
- assert_not(Fear['[]'] === [1])
23
- assert(Fear['[1]'] === [1])
24
- assert_not(Fear['[1]'] === [1, 2])
25
- assert_not(Fear['[1]'] === [2])
26
- assert(Fear['[1, 2]'] === [1, 2])
27
- assert_not(Fear['[1, 2]'] === [1, 3])
28
- assert_not(Fear['[1, 2]'] === [1, 2, 4])
29
- assert_not(Fear['[1, 2]'] === [1])
30
- assert(Fear['[*]'] === [])
31
- assert(Fear['[*]'] === [1, 2])
32
- assert_not(Fear['[1, *]'] === [])
33
- assert(Fear['[1, *]'] === [1])
34
- assert(Fear['[1, *]'] === [1, 2])
35
- assert(Fear['[1, *]'] === [1, 2, 3])
36
- assert(Fear['[[1]]'] === [[1]])
37
- assert(Fear['[[1],2]'] === [[1], 2])
38
- assert(Fear['[[1],*]'] === [[1], 2])
39
- assert(Fear['[[*],*]'] === [[1], 2])
40
- assert_invalid_syntax { Fear['[*, 2]'] }
41
- assert_invalid_syntax { Fear['[*, ]'] }
42
- assert_invalid_syntax { Fear['[1, *, ]'] }
43
- assert_invalid_syntax { Fear['[1, *, 2]'] }
44
- assert_invalid_syntax { Fear['[1, *, *]'] }
45
- assert_invalid_syntax { Fear['[*, *]'] }
46
- assert(Fear['[a, b]'] === [1, 2])
47
- assert_not(Fear['[a, b, c]'] === [1, 2])
48
- assert(Fear['[a, b, _]'] === [1, 2, 3])
49
- assert(Fear['[a, b, *c]'] === [1, 2])
50
- assert_not(Fear['[a, b, c, *d]'] === [1, 2])
22
+ specify "Array" do
23
+ assert(Fear["[]"] === [])
24
+ assert_not(Fear["[]"] === [1])
25
+ assert(Fear["[1]"] === [1])
26
+ assert_not(Fear["[1]"] === [1, 2])
27
+ assert_not(Fear["[1]"] === [2])
28
+ assert(Fear["[1, 2]"] === [1, 2])
29
+ assert_not(Fear["[1, 2]"] === [1, 3])
30
+ assert_not(Fear["[1, 2]"] === [1, 2, 4])
31
+ assert_not(Fear["[1, 2]"] === [1])
32
+ assert(Fear["[*]"] === [])
33
+ assert(Fear["[*]"] === [1, 2])
34
+ assert_not(Fear["[1, *]"] === [])
35
+ assert(Fear["[1, *]"] === [1])
36
+ assert(Fear["[1, *]"] === [1, 2])
37
+ assert(Fear["[1, *]"] === [1, 2, 3])
38
+ assert(Fear["[[1]]"] === [[1]])
39
+ assert(Fear["[[1],2]"] === [[1], 2])
40
+ assert(Fear["[[1],*]"] === [[1], 2])
41
+ assert(Fear["[[*],*]"] === [[1], 2])
42
+ assert_invalid_syntax { Fear["[*, 2]"] }
43
+ assert_invalid_syntax { Fear["[*, ]"] }
44
+ assert_invalid_syntax { Fear["[1, *, ]"] }
45
+ assert_invalid_syntax { Fear["[1, *, 2]"] }
46
+ assert_invalid_syntax { Fear["[1, *, *]"] }
47
+ assert_invalid_syntax { Fear["[*, *]"] }
48
+ assert(Fear["[a, b]"] === [1, 2])
49
+ assert_not(Fear["[a, b, c]"] === [1, 2])
50
+ assert(Fear["[a, b, _]"] === [1, 2, 3])
51
+ assert(Fear["[a, b, *c]"] === [1, 2])
52
+ assert_not(Fear["[a, b, c, *d]"] === [1, 2])
51
53
  end
52
54
 
53
- specify 'String' do
54
- assert(Fear['"foo"'] === 'foo')
55
+ specify "String" do
56
+ assert(Fear['"foo"'] === "foo")
55
57
  assert(Fear['"f\"oo"'] === 'f"oo')
56
- assert_not(Fear['"foo"'] === 'bar')
57
- assert(Fear["'foo'"] === 'foo')
58
- assert_not(Fear["'foo'"] === 'bar')
58
+ assert_not(Fear['"foo"'] === "bar")
59
+ assert(Fear["'foo'"] === "foo")
60
+ assert_not(Fear["'foo'"] === "bar")
59
61
  end
60
62
 
61
- specify 'Symbol' do
63
+ specify "Symbol" do
62
64
  assert(Fear[':"foo"'] === :foo)
63
65
  assert(Fear[":'foo'"] === :foo)
64
- assert(Fear[':foo'] === :foo)
65
- assert_not(Fear[':foo'] === :bar)
66
+ assert(Fear[":foo"] === :foo)
67
+ assert_not(Fear[":foo"] === :bar)
66
68
  end
67
69
 
68
- specify 'Boolean' do
69
- assert(Fear['true'] === true)
70
- assert(Fear['false'] === false)
71
- assert_not(Fear['true'] === false)
72
- assert_not(Fear['false'] === true)
70
+ specify "Boolean" do
71
+ assert(Fear["true"] === true)
72
+ assert(Fear["false"] === false)
73
+ assert_not(Fear["true"] === false)
74
+ assert_not(Fear["false"] === true)
73
75
  end
74
76
 
75
- specify 'Nil' do
76
- assert(Fear['nil'] === nil) # rubocop:disable Style/NilComparison
77
- assert_not(Fear['nil'] === 42)
77
+ specify "Nil" do
78
+ assert(Fear["nil"] === nil) # rubocop:disable Style/NilComparison
79
+ assert_not(Fear["nil"] === 42)
78
80
  end
79
81
 
80
- specify '_' do
81
- assert(Fear['_'] === nil) # rubocop:disable Style/NilComparison
82
- assert(Fear['_'] === true)
83
- assert(Fear['_'] === false)
84
- assert(Fear['_'] === 42)
85
- assert(Fear['_'] === 'foo')
86
- assert(Fear['_'] === [42])
82
+ specify "_" do
83
+ assert(Fear["_"] === nil) # rubocop:disable Style/NilComparison
84
+ assert(Fear["_"] === true)
85
+ assert(Fear["_"] === false)
86
+ assert(Fear["_"] === 42)
87
+ assert(Fear["_"] === "foo")
88
+ assert(Fear["_"] === [42])
87
89
  end
88
90
 
89
- specify 'type matching' do
91
+ specify "type matching" do
90
92
  class Foo
91
93
  class Bar
92
94
  end
93
95
  end
94
96
 
95
- assert(Fear['Integer'] === 3)
96
- assert_not(Fear['Integer'] === '3')
97
- assert(Fear['Numeric'] === 3)
98
- assert(Fear['Foo::Bar'] === Foo::Bar.new)
99
- assert(Fear['var : Integer'] === 3)
100
- assert_not(Fear['var : Integer'] === '3')
97
+ assert(Fear["Integer"] === 3)
98
+ assert_not(Fear["Integer"] === "3")
99
+ assert(Fear["Numeric"] === 3)
100
+ assert(Fear["Foo::Bar"] === Foo::Bar.new)
101
+ assert(Fear["var : Integer"] === 3)
102
+ assert_not(Fear["var : Integer"] === "3")
101
103
  end
102
104
 
103
- specify 'capture matcher' do
104
- assert(Fear['array @ [head : Integer, *tail]'] === [1, 2])
105
- assert_not(Fear['array @ [head : Integer, *tail]'] === ['1', 2])
105
+ specify "capture matcher" do
106
+ assert(Fear["array @ [head : Integer, *tail]"] === [1, 2])
107
+ assert_not(Fear["array @ [head : Integer, *tail]"] === ["1", 2])
106
108
  end
107
109
 
108
- specify 'extractor' do
109
- assert_valid_syntax { Fear['Foo(a, b : Integer)'] }
110
- assert(Fear['Fear::Some(a : Integer)'] === Fear.some(42))
111
- assert_not(Fear['Fear::Some(a : Integer)'] === Fear.some('foo'))
110
+ specify "extractor" do
111
+ assert_valid_syntax { Fear["Foo(a, b : Integer)"] }
112
+ assert(Fear["Fear::Some(a : Integer)"] === Fear.some(42))
113
+ assert_not(Fear["Fear::Some(a : Integer)"] === Fear.some("foo"))
112
114
  end
113
115
  end