File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module Sass
4
4
module Value
5
5
# Sass's {FuzzyMath} module.
6
6
module FuzzyMath
7
- PRECISION = 11
7
+ PRECISION = 10
8
8
9
9
EPSILON = 10 **-PRECISION
10
10
Original file line number Diff line number Diff line change 5
5
# @see https://github.com/sass/sass-spec/blob/main/js-api-spec/value/number.test.ts
6
6
describe Sass ::Value ::Number do
7
7
let ( :precision ) do
8
- 10
8
+ Sass :: Value . const_get ( :FuzzyMath ) :: PRECISION
9
9
end
10
10
11
11
describe 'unitless' do
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 - 2 ) ) )
78
- expect ( number ) . to eq ( described_class . new ( 123 - 10 . pow ( -precision - 2 ) ) )
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 ) ) )
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 - 1 ) ) )
85
- expect ( number ) . not_to eq ( described_class . new ( 123 - 10 . pow ( -precision - 1 ) ) )
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 ) ) )
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 44
44
supports_block_expectations
45
45
end
46
46
47
- precision = Sass ::Value . const_get ( :FuzzyMath ) ::PRECISION - 1
47
+ precision = Sass ::Value . const_get ( :FuzzyMath ) ::PRECISION
48
48
49
49
RSpec ::Matchers . matcher :fuzzy_eq do |expected |
50
50
match do |actual |
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
59
when Numeric
59
- expect ( actual ) . to be_within ( ( ( 10 **-precision ) / 2 ) ) . of ( expected . round ( precision ) )
60
+ expect ( actual ) . to be_within ( ( 10 **-precision ) / 2 ) . of ( expected . round ( precision ) )
60
61
else
61
62
expect ( actual ) . to eq ( expected )
62
63
end
You can’t perform that action at this time.
0 commit comments