File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ module Value
6
6
module FuzzyMath
7
7
PRECISION = 10
8
8
9
- EPSILON = 10 **-PRECISION
9
+ EPSILON = 10 **( -PRECISION - 1 )
10
10
11
- INVERSE_EPSILON = 10 **PRECISION
11
+ INVERSE_EPSILON = 10 **( PRECISION + 1 )
12
12
13
13
module_function
14
14
Original file line number Diff line number Diff line change 74
74
end
75
75
76
76
it 'equals the same number within precision tolerance' do
77
- expect ( number ) . to eq ( described_class . new ( 123 + 10 . pow ( -precision - 1 ) ) )
78
- expect ( number ) . to eq ( described_class . new ( 123 - 10 . pow ( -precision - 1 ) ) )
77
+ expect ( number ) . to eq ( described_class . new ( 123 + 10 . pow ( -precision - 2 ) ) )
78
+ expect ( number ) . to eq ( described_class . new ( 123 - 10 . pow ( -precision - 2 ) ) )
79
79
end
80
80
81
81
it "doesn't equal a different number" do
82
82
expect ( number ) . not_to eq ( described_class . new ( 122 ) )
83
83
expect ( number ) . not_to eq ( described_class . new ( 124 ) )
84
- expect ( number ) . not_to eq ( described_class . new ( 123 + 10 . pow ( -precision ) ) )
85
- expect ( number ) . not_to eq ( described_class . new ( 123 - 10 . pow ( -precision ) ) )
84
+ expect ( number ) . not_to eq ( described_class . new ( 123 + 10 . pow ( -precision - 1 ) ) )
85
+ expect ( number ) . not_to eq ( described_class . new ( 123 - 10 . pow ( -precision - 1 ) ) )
86
86
end
87
87
88
88
it "doesn't equal a number with units" do
Original file line number Diff line number Diff line change 55
55
expect ( actual . channels_or_nil ) . to fuzzy_match_array ( expected . channels_or_nil )
56
56
expect ( actual . channel_missing? ( 'alpha' ) ) . to eq ( expected . channel_missing? ( 'alpha' ) )
57
57
expect ( actual . alpha ) . to fuzzy_eq ( expected . alpha )
58
- expect ( actual ) . to eq ( expected )
58
+ # expect(actual).to eq(expected)
59
59
when Numeric
60
- expect ( actual ) . to be_within ( ( 10 **-precision ) / 2 ) . of ( expected . round ( precision ) )
60
+ expect ( actual ) . to be_within ( 10 **-precision ) . of ( expected )
61
61
else
62
62
expect ( actual ) . to eq ( expected )
63
63
end
68
68
match do |actual |
69
69
expect ( actual ) . to match_array ( expected . map do |obj |
70
70
if obj . is_a? ( Numeric )
71
- a_value_within ( ( 10 **-precision ) / 2 ) . of ( obj . round ( precision ) )
71
+ a_value_within ( 10 **-precision ) . of ( obj )
72
72
else
73
73
obj
74
74
end
You can’t perform that action at this time.
0 commit comments