1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<!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>
// Identity tests
test_math_used('pow(1,1)', '1', {type:'number'});
test_math_used('sqrt(1)', '1', {type:'number'});
test_math_used('hypot(1)', '1', {type:'number'});
// Nestings
test_math_used('sqrt(pow(1,1))', '1');
test_math_used('hypot(pow(1, sqrt(1)))', '1');
test_math_used('calc(hypot(pow((1 + sqrt(1)) / 2, sqrt(1))))', '1');
// General calculations
test_math_used('calc(100px * pow(2, pow(2, 2)))','1600px');
test_math_used('calc(1px * pow(2, 3))', '8px')
test_math_used('calc(100px * sqrt(100))', '1000px');
test_math_used('calc(1px * pow(2, sqrt(100))', '1024px');
test_math_used('hypot(3px, 4px)', '5px');
test_math_used('calc(100px * hypot(3, 4))', '500px');
test_math_used('hypot(-5px)', '5px');
test_math_used('calc(1px * hypot(-5))', '5px');
test_math_used('calc(1px * hypot(10000))','10000px');
test_math_used('calc(2px * sqrt(100000000))','20000px');
test_math_used('calc(3px * pow(200, 4))', '33554428px');
//Type checking hypot
test_math_used('hypot(1px)', '1px');
test_math_used('hypot(1cm)', '1cm');
test_math_used('hypot(1mm)', '1mm');
test_math_used('hypot(1Q)', '1Q');
test_math_used('hypot(1in)', '1in');
test_math_used('hypot(1pc)', '1pc');
test_math_used('hypot(1pt)', '1pt');
test_math_used('hypot(1em)', '1em');
test_math_used('hypot(1ex)', '1ex');
test_math_used('hypot(1ch)', '1ch');
test_math_used('hypot(1rem)', '1rem');
test_math_used('hypot(1vh)', '1vh');
test_math_used('hypot(1vw)', '1vw');
test_math_used('hypot(1vmin)', '1vmin');
test_math_used('hypot(1vmax)', '1vmax');
test_math_used('hypot(1s)', '1s', {type:'time'});
test_math_used('hypot(1ms)', '1ms', {type:'time'});
test_math_used('hypot(1deg)', '1deg', {type:'angle', approx:0.001});
test_math_used('hypot(1grad)', '1grad', {type:'angle', approx:0.001});
test_math_used('hypot(1rad)', '1rad', {type:'angle', approx:0.001});
test_math_used('hypot(1turn)', '1turn', {type:'angle', approx:0.001});
</script>
|