From 39570025075a1289bb44a6f25a5db1f00dba2344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 27 Sep 2024 16:55:26 -0700 Subject: [PATCH] Increase expected test data precision --- js-api-spec/setup.ts | 5 +- .../value/color/color-4-conversions.test.ts | 2 +- .../color/color-4-nonparametizable.test.ts | 24 ++++----- .../value/color/interpolation-examples.ts | 48 ++++++++--------- js-api-spec/value/color/spaces.ts | 51 ++++++++++--------- 5 files changed, 66 insertions(+), 64 deletions(-) diff --git a/js-api-spec/setup.ts b/js-api-spec/setup.ts index 8eccfc275..38e722e55 100644 --- a/js-api-spec/setup.ts +++ b/js-api-spec/setup.ts @@ -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 { diff --git a/js-api-spec/value/color/color-4-conversions.test.ts b/js-api-spec/value/color/color-4-conversions.test.ts index 7e08517fd..35ea21441 100644 --- a/js-api-spec/value/color/color-4-conversions.test.ts +++ b/js-api-spec/value/color/color-4-conversions.test.ts @@ -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}) )); }); }); diff --git a/js-api-spec/value/color/color-4-nonparametizable.test.ts b/js-api-spec/value/color/color-4-nonparametizable.test.ts index e69d64019..cd325c72d 100644 --- a/js-api-spec/value/color/color-4-nonparametizable.test.ts +++ b/js-api-spec/value/color/color-4-nonparametizable.test.ts @@ -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 ), }, ], @@ -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 ), }, ], diff --git a/js-api-spec/value/color/interpolation-examples.ts b/js-api-spec/value/color/interpolation-examples.ts index e3de03788..d50349e04 100644 --- a/js-api-spec/value/color/interpolation-examples.ts +++ b/js-api-spec/value/color/interpolation-examples.ts @@ -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], ], [ { @@ -29,7 +29,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { weight: 0, }, - [38.95792456574883, -15.169549415088852, -17.792484605053115], + [38.957924659568256, -15.169546354833418, -17.792483560001216], ], ], oklab: [ @@ -37,19 +37,19 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { 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: [ @@ -57,7 +57,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { weight: 0.5, }, - [58.61420164622054, 29.299459370089924, 295.6021177856686], + [58.614201693004674, 29.299457976259603, 295.6021198088788], ], [ { @@ -69,35 +69,35 @@ 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: [ @@ -105,47 +105,47 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { 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: [ @@ -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], ], [ { @@ -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: [ @@ -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], ], [ { @@ -305,7 +305,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { weight: 0, }, - [0.08408207011375313, 0.10634498228480066, 0.14703708775508573], + [0.08408207405980274, 0.10634498282797152, 0.14703708427207543], ], ], rgb: [ @@ -313,7 +313,7 @@ export const interpolations: {[space: string]: InterpolationExample[]} = { { weight: 0.5, }, - [146.56944672156501, 134.1448156837381, 157.00580432872178], + [146.49494601036622, 133.9494959758061, 156.77020571682615], ], [ { @@ -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: [ diff --git a/js-api-spec/value/color/spaces.ts b/js-api-spec/value/color/spaces.ts index 806fc0c17..7d02473cb 100644 --- a/js-api-spec/value/color/spaces.ts +++ b/js-api-spec/value/color/spaces.ts @@ -48,8 +48,8 @@ export const spaces: { name: 'lab', isLegacy: false, isPolar: false, - pink: [78.27047872644108, 35.20288139978972, 1.0168442562642044], - blue: [38.95792456574883, -15.169549415088856, -17.792484605053115], + pink: [78.27047872644108, 35.20288139978972, 1.0168442562641822], + blue: [38.957924659568256, -15.169546354833418, -17.792483560001216], channels: ['lightness', 'a', 'b'] as ChannelNameLab[], ranges: [ [0, 100], @@ -69,8 +69,8 @@ export const spaces: { name: 'oklab', isLegacy: false, isPolar: false, - pink: [0.8241000000000002, 0.10608808442731632, 0.0015900762693974446], - blue: [0.47120000400818335, -0.05111706453373946, -0.048406651029280656], + pink: [0.8241000051752044, 0.10608808769190603, 0.0015900461037656743], + blue: [0.47120000698576636, -0.05111706553856424, -0.048406668724564006], channels: ['lightness', 'a', 'b'] as ChannelNameLab[], ranges: [ [0, 1], @@ -90,8 +90,8 @@ export const spaces: { name: 'lch', isLegacy: false, isPolar: true, - pink: [78.27047872644108, 35.21756424128674, 1.6545432253797676], - blue: [38.957924566, 23.38135449889311, 229.54969234595737], + pink: [78.27047872644108, 35.21756424128674, 1.6545432253797117], + blue: [38.957924659568256, 23.381351711232465, 229.54969639237788], channels: ['lightness', 'chroma', 'hue'] as ChannelNameLch[], hasPowerless: true, ranges: [ @@ -112,8 +112,8 @@ export const spaces: { name: 'oklch', isLegacy: false, isPolar: true, - pink: [0.8241, 0.1061, 0.8587], - blue: [0.47120000400818335, 0.07039998686375618, 223.44000118475142], + pink: [0.8241000051752044, 0.1061000028121472, 0.8586836854624949], + blue: [0.47120000698576636, 0.07039999976053661, 223.44001107929404], channels: ['lightness', 'chroma', 'hue'] as ChannelNameLch[], hasPowerless: true, ranges: [ @@ -134,7 +134,7 @@ export const spaces: { name: 'srgb', isLegacy: false, isPolar: false, - pink: [0.9999785463111585, 0.6599448662991679, 0.758373017125016], + pink: [0.9999785463111587, 0.6599448662991679, 0.7583730171250161], blue: [0.14900142239759614, 0.39063941586401707, 0.47119722379126755], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ @@ -152,7 +152,7 @@ export const spaces: { name: 'srgb-linear', isLegacy: false, isPolar: false, - pink: [0.999951196094508, 0.3930503811476254, 0.5356603778005655], + pink: [0.9999511960945082, 0.39305038114762536, 0.5356603778005656], blue: [0.019378214827482948, 0.12640222770203852, 0.18834349393523495], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ @@ -170,7 +170,7 @@ export const spaces: { name: 'display-p3', isLegacy: false, isPolar: false, - pink: [0.9510333333617188, 0.6749909745845027, 0.7568568353546363], + pink: [0.9510333333617188, 0.6749909745845027, 0.7568568353546361], blue: [0.21620126176161275, 0.38537730537965537, 0.46251697991685353], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ @@ -188,7 +188,7 @@ export const spaces: { name: 'a98-rgb', isLegacy: false, isPolar: false, - pink: [0.9172837001828321, 0.6540226622083835, 0.7491144397116841], + pink: [0.9172837001828322, 0.6540226622083833, 0.749114439711684], blue: [0.2557909283504703, 0.3904466064332277, 0.4651826475952292], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ @@ -206,8 +206,8 @@ export const spaces: { name: 'prophoto-rgb', isLegacy: false, isPolar: false, - pink: [0.842345736209146, 0.6470539622987257, 0.7003583323790157], - blue: [0.24317903319635056, 0.3045087255847488, 0.38356879501347535], + pink: [0.842345736209146, 0.6470539622987259, 0.7003583323790157], + blue: [0.24317987809516806, 0.304508209543027, 0.3835687899657161], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ [0, 1], @@ -224,8 +224,8 @@ export const spaces: { name: 'rec2020', isLegacy: false, isPolar: false, - pink: [0.8837118321235519, 0.6578067923850563, 0.7273197917658354], - blue: [0.2151122740532409, 0.32363973150195124, 0.4090033869684574], + pink: [0.883711832123552, 0.6578067923850561, 0.7273197917658352], + blue: [0.21511227405324085, 0.3236397315019512, 0.4090033869684574], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ [0, 1], @@ -263,8 +263,8 @@ export const spaces: { name: 'xyz-d50', isLegacy: false, isPolar: false, - pink: [0.6640698533004002, 0.5367266625281085, 0.4345958246720296], - blue: [0.08408207011375313, 0.10634498228480066, 0.1470370877550857], + pink: [0.6640698533004004, 0.5367266625281086, 0.43459582467202973], + blue: [0.08408207405980274, 0.10634498282797152, 0.14703708427207543], channels: ['x', 'y', 'z'] as ChannelNameXyz[], ranges: [ [0, 1], @@ -305,8 +305,8 @@ export const spaces: { name: 'rgb', isLegacy: true, isPolar: false, - pink: [254.9945293093454, 168.28594090628783, 193.38511936687908], - blue: [38.144364133784602, 100.003690461188378, 120.626489290564506], + pink: [254.99452930934547, 168.28594090628783, 193.3851193668791], + blue: [37.99536271138702, 99.61305104532435, 120.15529206677323], channels: ['red', 'green', 'blue'] as ChannelNameRgb[], ranges: [ [0, 255], @@ -326,7 +326,7 @@ export const spaces: { name: 'hsl', isLegacy: true, isPolar: true, - pink: [342.63204677447646, 99.98738302509669, 82.99617063051632], + pink: [342.63204677447646, 99.98738302509679, 82.99617063051633], blue: [195.0016494775154, 51.95041997811069, 31.009932309443183], channels: ['hue', 'saturation', 'lightness'] as ChannelNameHsl[], hasPowerless: true, @@ -341,7 +341,7 @@ export const spaces: { [0.5, 110, 50], { clip: [0.5, 100, 50], - 'local-minde': [2.9140262667, 100, 52.0514687465], + 'local-minde': [2.9140266584158057, 100, 52.05146824961835], }, ], ], @@ -351,7 +351,7 @@ export const spaces: { name: 'hwb', isLegacy: true, isPolar: true, - pink: [342.63204677447646, 65.99448662991679, 0.002145368884157506], + pink: [342.63204677447646, 65.9944866299168, 0.002145368884129084], blue: [195.0016494775154, 14.900142239759612, 52.880277620873244], channels: ['hue', 'whiteness', 'blackness'] as ChannelNameHwb[], hasPowerless: true, @@ -364,7 +364,10 @@ export const spaces: { gamutExamples: [ [ [0.5, -3, -7], - {clip: [0.5, 0, 0], 'local-minde': [3.4921217446, 11.2665189221, 0]}, + { + clip: [0.5, 0, 0], + 'local-minde': [3.492122559065345, 11.266517197307957, 0], + }, ], ], },