@@ -22,8 +22,25 @@ describe('Exact-by-default division', () => {
2222 [ 'calc(1 / 3)' , 'calc(1 / 3)' ] ,
2323 [ 'calc(10px / 3 * 3)' , 'calc(10px)' ] ,
2424 [ 'calc(10px / -3)' , 'calc(-10px / 3)' ] ,
25- [ 'calc(1px / 1in)' , 'calc(1px / 1in )' ] ,
25+ [ 'calc(1px / 1in)' , 'calc(1 / 96 )' ] ,
2626 [ 'calc(1in / 1px)' , 'calc(96)' ] ,
27+ [ 'calc(1pt / 1pc)' , 'calc(1 / 12)' ] ,
28+ [ 'calc(1pc / 1pt)' , 'calc(12)' ] ,
29+ [ 'calc(2in / 1px)' , 'calc(192)' ] ,
30+ [ 'calc(7px / 1in)' , 'calc(7 / 96)' ] ,
31+ [ 'calc(1in / 7px)' , 'calc(96 / 7)' ] ,
32+ [ 'calc(-1px / 1in)' , 'calc(-1 / 96)' ] ,
33+ [ 'calc(1px / -1in)' , 'calc(-1 / 96)' ] ,
34+ [ 'calc(1cm / 1px)' , 'calc(1cm / 1px)' ] ,
35+ [ 'calc(1deg / 1rad)' , 'calc(1deg / 1rad)' ] ,
36+ [ 'calc((100px + 60em) / 3)' , 'calc((100px + 60em) / 3)' ] ,
37+ [ 'calc((3px + 5em) / 3)' , 'calc((3px + 5em) / 3)' ] ,
38+ [ 'calc((3px + 6em) / -3)' , 'calc(-1px - 2em)' ] ,
39+ [ 'calc((3px + var(--a)) / 3)' , 'calc((3px + var(--a)) / 3)' ] ,
40+ [ 'calc(1px * 3 / 3px)' , 'calc(1)' ] ,
41+ [ 'calc(1px / 3px * 3)' , 'calc(1)' ] ,
42+ [ 'calc((3px + 6em) / 3)' , 'calc(1px + 2em)' ] ,
43+ [ 'calc((30px + 60%) / 3)' , 'calc(10px + 20%)' ] ,
2744 [ 'calc(var(--n) / 4)' , 'calc(var(--n) / 4)' ] ,
2845 [ 'calc(2 * var(--n) / 3)' , 'calc(2 * var(--n) / 3)' ] ,
2946 // Quotients whose parts would be rounded on output are folded instead.
@@ -54,6 +71,24 @@ describe('Exact-by-default division', () => {
5471 ) ;
5572 } ) ;
5673
74+ test ( 'precision undefined keeps the default' , ( ) => {
75+ assert . equal (
76+ reduceCalc ( 'calc(100% / 3)' , { precision : undefined } ) ,
77+ 'calc(100% / 3)'
78+ ) ;
79+ assert . equal (
80+ reduceCalc ( 'calc(1cm + 1px)' , { precision : undefined } ) ,
81+ 'calc(1cm + 1px)'
82+ ) ;
83+ } ) ;
84+
85+ test ( 'precision false folds inexact unit quotients' , ( ) => {
86+ assert . equal (
87+ reduceCalc ( 'calc(1cm / 1px)' , { precision : false } ) ,
88+ 'calc(37.79527559055118)'
89+ ) ;
90+ } ) ;
91+
5792 test ( 'a higher precision folds quotients that are exact there' , ( ) => {
5893 assert . equal (
5994 reduceCalc ( 'calc(1px / 96)' , { precision : 10 } ) ,
0 commit comments