| <!DOCTYPE html> |
| <link rel="help" href="https://drafts.csswg.org/css-values-4/#exponent-funcs"> |
| <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('log(1)', '0', {type:'number'}); |
| test_math_used('log(10, 10)', '1', {type:'number'}); |
| test_math_used('exp(0)', '1', {type:'number'}); |
| |
| // Test e |
| test_math_used('calc(log(e) )', '1', {type:'number', approx:0.1}); |
| test_math_used('calc(e - exp(1))', '0', {type:'number', approx:0.1}); |
| |
| //General calculations |
| test_math_used('calc(log( 1 + 1 + 2 /2 - 2) )', '0', {type:'number', approx:0.1}); |
| test_math_used('calc(log(1) + exp(0))', '1', {type:'number', approx:0.1}); |
| test_math_used('calc(exp(log(1) + exp(0)*2))', '7.4', {type:'number', approx:0.1}); |
| test_math_used('calc(log(log(1) + exp(0)*10))', '2.3', {type:'number', approx:0.1}); |
| test_math_used('calc(log(log(1) + exp(0)*20, 10))', '1.3', {type:'number', approx:0.1}); |
| test_math_used('calc(log(e) / log(e) + exp(0)*2 * log(e))', '3', {type:'number', approx:0.1}); |
| test_math_used('calc(log((1 + 1) /2) / log(e) + exp(0*1)*2 * log(e))', '2', {type:'number', approx:0.1}); |
| test_math_used('calc(log((3 + 1) /2, 2) / log(e) + exp(0*1)*2 * log(e))', '3', {type:'number', approx:0.1}); |
| test_math_used('calc(log((3 + 1) /2, 2) / log(e, e) + exp(0*1)*2 * log(e, e))', '3', {type:'number', approx:0.1}); |
| test_math_used('calc(exp(0) + 1)', '2', {type:'number', approx:0.1}); |
| |
| // Test unresolved at parse time |
| test_math_used('calc(e - exp(sibling-index()))', '0', {type:'number', approx:0.1}); |
| test_math_used('calc(log(exp(2 * sibling-index())))', '2', {type:'number', approx:0.1}); |
| test_math_used('calc(e - exp(sign(1em - 1px)))', '0', {type:'number', approx:0.1}); |
| test_math_used('calc(log(exp(2 * sign(1em - 1px))))', '2', {type:'number', approx:0.1}); |
| |
| // Test nesting |
| test_math_used('calc(log(exp(1)))', '1', {type:'number', approx:0.1}); |
| test_math_used('calc(log(exp(log(e))))', '1', {type:'number', approx:0.1}); |
| |
| // Special values |
| // https://drafts.csswg.org/css-values-4/#exponent-infinities |
| |
| // log(A, B): if B is 1 or negative, the result is NaN. |
| // B values between 0 and 1, or greater than 1, are valid. |
| test_nan('log(2, 1)'); |
| test_nan('log(2, -1)'); |
| test_nan('log(2, 0)'); |
| test_nan('log(2, -0)'); |
| test_nan('log(5, 1)'); |
| test_math_used('log(2, 0.5)', '-1', {type: 'number'}); |
| test_math_used('log(2, 2)', '1', {type: 'number'}); |
| |
| // In log(A, B): if A is negative, the result is NaN. |
| test_nan('log(-1)'); |
| test_nan('log(-1, 2)'); |
| |
| // If A is 0+ or 0-, the result is -infinity. |
| test_minus_infinity('log(0)'); |
| test_minus_infinity('log(-0)'); |
| test_minus_infinity('log(0, 2)'); |
| |
| // If A is 1, the result is 0+. |
| test_plus_zero('log(1)'); |
| test_plus_zero('log(1, 2)'); |
| test_plus_zero('log(1, 0.5)'); |
| |
| // If A is +infinity, the result is +infinity. |
| test_plus_infinity('log(infinity)'); |
| test_plus_infinity('log(infinity, 2)'); |
| |
| // NaN is infectious, even when A is 1. |
| // https://drafts.csswg.org/css-values-4/#exponent-infinities |
| // https://drafts.csswg.org/css-values-4/#calc-ieee |
| test_nan('log(NaN)'); |
| test_nan('log(NaN, 1)'); |
| test_nan('log(1, NaN)'); |
| test_nan('log(NaN, 2)'); |
| test_nan('log(2, NaN)'); |
| |
| // exp() |
| // If A is +infinity, the result is +infinity. |
| // If A is -infinity, the result is 0+. |
| test_plus_infinity('exp(infinity)'); |
| test_plus_zero('exp(-infinity)'); |
| |
| // NaN is infectious |
| // https://drafts.csswg.org/css-values-4/#exponent-infinities |
| // https://drafts.csswg.org/css-values-4/#calc-ieee |
| test_nan('exp(NaN)'); |
| </script> |