Skip to content

Commit 5baf3d8

Browse files
committed
Revert fuzzy equal precision
1 parent 6e34139 commit 5baf3d8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/sass/value/fuzzy_math.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module Value
66
module FuzzyMath
77
PRECISION = 10
88

9-
EPSILON = 10**-PRECISION
9+
EPSILON = 10**(-PRECISION - 1)
1010

11-
INVERSE_EPSILON = 10**PRECISION
11+
INVERSE_EPSILON = 10**(PRECISION + 1)
1212

1313
module_function
1414

spec/sass/value/number_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@
7474
end
7575

7676
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)))
7979
end
8080

8181
it "doesn't equal a different number" do
8282
expect(number).not_to eq(described_class.new(122))
8383
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)))
8686
end
8787

8888
it "doesn't equal a number with units" do

spec/spec_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
expect(actual.channels_or_nil).to fuzzy_match_array(expected.channels_or_nil)
5656
expect(actual.channel_missing?('alpha')).to eq(expected.channel_missing?('alpha'))
5757
expect(actual.alpha).to fuzzy_eq(expected.alpha)
58-
expect(actual).to eq(expected)
58+
# expect(actual).to eq(expected)
5959
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)
6161
else
6262
expect(actual).to eq(expected)
6363
end
@@ -68,7 +68,7 @@
6868
match do |actual|
6969
expect(actual).to match_array(expected.map do |obj|
7070
if obj.is_a?(Numeric)
71-
a_value_within((10**-precision) / 2).of(obj.round(precision))
71+
a_value_within(10**-precision).of(obj)
7272
else
7373
obj
7474
end

0 commit comments

Comments
 (0)