Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test result precision #2024

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions js-api-spec/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,10 @@ const toLooselyEqual = (received: unknown, actual: number) => {
};

// The max distance two Sass numbers can be from each another before they're
// considered different (2 decimals).
// considered different (11 decimals).
//
// Uses ** instead of Math.pow() for constant folding.
// TODO: Ideally this should be more precise, but ColorJS does not always match.
const epsilon = 10 ** -2;
const epsilon = 10 ** -11;

const toLooselyEqualColor = (received: unknown, actual: sass.SassColor) => {
function isSassColor(item: unknown): item is sass.SassColor {
Expand Down
2 changes: 1 addition & 1 deletion js-api-spec/value/color/color-4-conversions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Color 4 SassColors Conversions', () => {
new SassColor({red: 100, green: 200, blue: 50})
)
).toLooselyEqualColor(
new SassColor({hue: 140, saturation: 80, lightness: 49.5098039216})
new SassColor({hue: 140, saturation: 80, lightness: 49.509803921568626})
));
});
});
24 changes: 12 additions & 12 deletions js-api-spec/value/color/color-4-nonparametizable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ describe('Color 4 SassColors Non-parametizable', () => {
'display-p3',
{
'local-minde': constructors.oklch(
0.80777568417,
0.3262439045,
148.1202740275
0.8077756760084225,
0.32624391948277537,
148.1202761637585
),
clip: constructors.oklch(
0.848829286984,
0.3685278106,
145.6449503702
0.8488292928532466,
0.3685277976813825,
145.64495558662838
),
},
],
Expand All @@ -43,14 +43,14 @@ describe('Color 4 SassColors Non-parametizable', () => {
'srgb',
{
'local-minde': constructors.oklch(
0.809152570179,
0.2379027576,
147.4021477687
0.809152561530627,
0.23790276994468387,
147.40215048389234
),
clip: constructors.oklch(
0.866439611536,
0.2948272403,
142.4953388878
0.8664396175234368,
0.2948272245426958,
142.4953450414439
),
},
],
Expand Down
48 changes: 24 additions & 24 deletions js-api-spec/value/color/interpolation-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0.5,
},
[58.614201646094955, 10.016665992350433, -8.387820174394456],
[58.614201693004674, 10.016667522478151, -8.387819651868517],
],
[
{
Expand All @@ -29,35 +29,35 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0,
},
[38.95792456574883, -15.169549415088852, -17.792484605053115],
[38.957924659568256, -15.169546354833418, -17.792483560001216],
],
],
oklab: [
[
{
weight: 0.5,
},
[0.6476500020040917, 0.02748550994678843, -0.023408287379941606],
[0.6476500060804854, 0.027485511076670896, -0.023408311310399166],
],
[
{
weight: 1,
},
[0.8241000000000002, 0.10608808442731632, 0.0015900762693974446],
[0.8241000051752044, 0.10608808769190603, 0.0015900461037656743],
],
[
{
weight: 0,
},
[0.47120000400818335, -0.05111706453373946, -0.048406651029280656],
[0.47120000698576636, -0.05111706553856424, -0.048406668724564006],
],
],
lch: [
[
{
weight: 0.5,
},
[58.61420164622054, 29.299459370089924, 295.6021177856686],
[58.614201693004674, 29.299457976259603, 295.6021198088788],
],
[
{
Expand All @@ -69,83 +69,83 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0,
},
[38.957924566, 23.38135449889311, 229.5496923459574],
[38.957924659568256, 23.381351711232465, 229.54969639237788],
],
[
{
weight: 0.5,
method: 'shorter',
},
[58.61420164622054, 29.299459370089924, 295.6021177856686],
[58.614201693004674, 29.299457976259603, 295.6021198088788],
],
[
{
weight: 0.5,
method: 'longer',
},
[58.61420164622054, 29.299459370089924, 115.60211778566858],
[58.614201693004674, 29.299457976259603, 115.6021198088788],
],
[
{
weight: 0.5,
method: 'increasing',
},
[58.61420164622054, 29.299459370089924, 115.60211778566858],
[58.614201693004674, 29.299457976259603, 115.6021198088788],
],
[
{
weight: 0.5,
method: 'decreasing',
},
[58.61420164622054, 29.299459370089924, 295.6021177856686],
[58.614201693004674, 29.299457976259603, 295.6021198088788],
],
],
oklch: [
[
{
weight: 0.5,
},
[0.6476500020040917, 0.08824999343187809, 292.1493505923757],
[0.6476500060804854, 0.0882500012863419, 292.1493473823782],
],
[
{
weight: 1,
},
[0.8241, 0.1061, 0.8586999999999989],
[0.8241000051752044, 0.1061000028121472, 0.8586836854624949],
],
[
{
weight: 0,
},
[0.47120000400818335, 0.07039998686375618, 223.4400011847514],
[0.47120000698576636, 0.07039999976053661, 223.44001107929404],
],
[
{
weight: 0.5,
method: 'shorter',
},
[0.6476500020040917, 0.08824999343187809, 292.1493505923757],
[0.6476500060804854, 0.0882500012863419, 292.1493473823782],
],
[
{
weight: 0.5,
method: 'longer',
},
[0.6476500020040917, 0.08824999343187809, 112.1493505923757],
[0.6476500060804854, 0.0882500012863419, 112.14934738237824],
],
[
{
weight: 0.5,
method: 'increasing',
},
[0.6476500020040917, 0.08824999343187809, 112.1493505923757],
[0.6476500060804854, 0.0882500012863419, 112.14934738237824],
],
[
{
weight: 0.5,
method: 'decreasing',
},
[0.6476500020040917, 0.08824999343187809, 292.1493505923757],
[0.6476500060804854, 0.0882500012863419, 292.1493473823782],
],
],
srgb: [
Expand Down Expand Up @@ -233,7 +233,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0.5,
},
[0.5427623847027483, 0.4757813439417372, 0.5419635636962455],
[0.5427628071521571, 0.4757810859208764, 0.5419635611723659],
],
[
{
Expand All @@ -245,7 +245,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0,
},
[0.2431790331963506, 0.3045087255847488, 0.38356879501347535],
[0.24317987809516806, 0.304508209543027, 0.3835687899657161],
],
],
rec2020: [
Expand Down Expand Up @@ -293,7 +293,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0.5,
},
[0.3740759617070767, 0.3215358224064546, 0.2908164562135577],
[0.37407596368010154, 0.32153582267804004, 0.29081645447205257],
],
[
{
Expand All @@ -305,15 +305,15 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0,
},
[0.08408207011375313, 0.10634498228480066, 0.14703708775508573],
[0.08408207405980274, 0.10634498282797152, 0.14703708427207543],
],
],
rgb: [
[
{
weight: 0.5,
},
[146.56944672156501, 134.1448156837381, 157.00580432872178],
[146.49494601036622, 133.9494959758061, 156.77020571682615],
],
[
{
Expand All @@ -325,7 +325,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = {
{
weight: 0,
},
[38.14436413378462, 100.00369046118837, 120.62648929056449],
[37.99536271138702, 99.61305104532435, 120.15529206677323],
],
],
hsl: [
Expand Down
Loading
Loading