| <!DOCTYPE html> |
| <link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func"> |
| <link rel="help" href="https://drafts.csswg.org/css-values-4/#numbers"> |
| <link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-type-checking"> |
| <link rel="author" title="Apple Inc"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="../support/numeric-testcommon.js"></script> |
| <div id="target"></div> |
| <script> |
| // Simple tests |
| test_math_used('round(10,10)', '10', {type:'number'}); |
| test_math_used('mod(1,1)', '0', {type:'number'}); |
| test_math_used('rem(1,1)', '0', {type:'number'}); |
| |
| //Test basic round |
| test_math_used('calc(round(100,10))', '100', {type:'number'}); |
| test_math_used('calc(round(up, 101,10))', '110', {type:'number'}); |
| test_math_used('calc(round(down, 106,10))', '100', {type:'number'}); |
| test_math_used('calc(round(to-zero,105, 10))', '100', {type:'number'}); |
| test_math_used('calc(round(to-zero,-105, 10))', '-100', {type:'number'}); |
| test_math_used('calc(round(-100,10))', '-100', {type:'number'}); |
| test_math_used('calc(round(up, -103,10))', '-100', {type:'number'}); |
| |
| //Test basic mod/rem |
| test_math_used('mod(18,5)', '3', {type:'number'}); |
| test_math_used('rem(18,5)', '3', {type:'number'}); |
| test_math_used('mod(-140,-90)', '-50', {type:'number'}); |
| test_math_used('mod(-18,5)', '2', {type:'number'}); |
| test_math_used('rem(-18,5)', '-3', {type:'number'}); |
| test_math_used('mod(140,-90)', '-40', {type:'number'}); |
| test_math_used('rem(140,-90)', '50', {type:'number'}); |
| |
| //Test basic calculations |
| test_math_used('calc(round(round(100,10), 10))', '100', {type:'number'}); |
| test_math_used('calc(round(up, round(100,10) + 1,10))', '110', {type:'number'}); |
| test_math_used('calc(round(down, round(100,10) + 2 * 3,10))', '100', {type:'number'}); |
| test_math_used('calc(round(to-zero,round(100,10) * 2 - 95, 10))', '100', {type:'number'}); |
| test_math_used('calc(round(round(100,10)* -1,10))', '-100', {type:'number'}); |
| test_math_used('calc(round(up, -103 + -103 / -103 - 1,10))', '-100', {type:'number'}); |
| test_math_used('calc(mod(18,5) * 2 + mod(17,5))', '8', {type:'number'}); |
| test_math_used('calc(rem(mod(18,5),5))', '3', {type:'number'}); |
| test_math_used('calc(rem(mod(18,5),mod(17,5)))', '1', {type:'number'}); |
| test_math_used('calc(mod(-140,-90))', '-50', {type:'number'}); |
| test_math_used('calc(mod(rem(1,18)* -1,5))', '-1', {type:'number'}); |
| |
| // Type check |
| test_math_used('round(10px,6px)', '12px'); |
| test_math_used('round(10cm,6cm)', '12cm'); |
| test_math_used('round(10mm,6mm)', '12mm'); |
| test_math_used('round(10Q, 6Q)', '12Q'); |
| test_math_used('round(10in,6in)', '12in'); |
| test_math_used('round(10pc,6pc)', '12pc'); |
| test_math_used('round(10pt,6pt)', '12pt'); |
| test_math_used('round(10em,6em)', '12em'); |
| test_math_used('round(10ex,6ex)', '12ex'); |
| test_math_used('round(10ch,6ch)', '12ch'); |
| test_math_used('round(10rem,6rem)', '12rem'); |
| test_math_used('round(10vh,6vh)', '12vh'); |
| test_math_used('round(10vw,6vw)', '12vw'); |
| test_math_used('round(10vmin,6vmin)', '12vmin'); |
| test_math_used('round(10vmax,6vmax)', '12vmax'); |
| test_math_used('round(10s,6s)', '12s'); |
| test_math_used('round(10ms,6ms)', '12ms'); |
| test_math_used('round(10deg,6deg)', '12deg', {type:'angle', approx:0.1}); |
| test_math_used('round(10grad,6grad)', '12grad', {type:'angle', approx:0.1}); |
| test_math_used('round(10rad,6rad)', '12rad',{type:'angle', approx:0.1}); |
| test_math_used('round(10turn,6turn)', '12turn',{type:'angle', approx:0.1}); |
| |
| test_math_used('mod(10px,6px)', '4px'); |
| test_math_used('mod(10cm,6cm)', '4cm'); |
| test_math_used('mod(10mm,6mm)', '4mm'); |
| test_math_used('mod(10Q, 6Q)', '4Q'); |
| test_math_used('mod(10in,6in)', '4in'); |
| test_math_used('mod(10pc,6pc)', '4pc'); |
| test_math_used('mod(10em,6em)', '4em'); |
| test_math_used('mod(10ex,6ex)', '4ex'); |
| test_math_used('mod(10ch,6ch)', '4ch'); |
| test_math_used('mod(10rem,6rem)', '4rem'); |
| test_math_used('mod(10vh,6vh)', '4vh'); |
| test_math_used('mod(10vw,6vw)', '4vw'); |
| test_math_used('mod(10vmin,6vmin)', '4vmin'); |
| test_math_used('mod(10vmax,6vmax)', '4vmax'); |
| test_math_used('mod(10s,6s)', '4s'); |
| test_math_used('mod(10ms,6ms)', '4ms'); |
| test_math_used('mod(10deg,6deg)', '4deg', {type:'angle', approx:0.1}); |
| test_math_used('mod(10grad,6grad)', '4grad', {type:'angle', approx:0.1}); |
| test_math_used('mod(10rad,6rad)', '4rad',{type:'angle', approx:0.1}); |
| test_math_used('mod(10turn,6turn)', '4turn',{type:'angle', approx:0.1}); |
| |
| test_math_used('rem(10px,6px)', '4px'); |
| test_math_used('rem(10cm,6cm)', '4cm'); |
| test_math_used('rem(10mm,6mm)', '4mm'); |
| test_math_used('rem(10Q, 6Q)', '4Q'); |
| test_math_used('rem(10in,6in)', '4in'); |
| test_math_used('rem(10pc,6pc)', '4pc'); |
| test_math_used('rem(10em,6em)', '4em'); |
| test_math_used('rem(10ex,6ex)', '4ex'); |
| test_math_used('rem(10ch,6ch)', '4ch'); |
| test_math_used('rem(10rem,6rem)', '4rem'); |
| test_math_used('rem(10vh,6vh)', '4vh'); |
| test_math_used('rem(10vw,6vw)', '4vw'); |
| test_math_used('rem(10vmin,6vmin)', '4vmin'); |
| test_math_used('rem(10vmax,6vmax)', '4vmax'); |
| test_math_used('rem(10s,6s)', '4s'); |
| test_math_used('rem(10ms,6ms)', '4ms'); |
| test_math_used('rem(10deg,6deg)', '4deg', {type:'angle', approx:0.1}); |
| test_math_used('rem(10grad,6grad)', '4grad', {type:'angle', approx:0.1}); |
| test_math_used('rem(10rad,6rad)', '4rad',{type:'angle', approx:0.1}); |
| test_math_used('rem(10turn,6turn)', '4turn',{type:'angle', approx:0.1}); |
| </script> |