1
+ <!DOCTYPE html>
2
+ < link rel ="help " href ="https://drafts.csswg.org/css-values-4/#comp-func ">
3
+ < link rel ="help " href ="https://drafts.csswg.org/css-values-4/#numbers ">
4
+ < link rel ="help " href ="https://drafts.csswg.org/css-values-4/#calc-type-checking ">
5
+ < link rel ="author " title ="Apple Inc ">
6
+ < script src ="/resources/testharness.js "> </ script >
7
+ < script src ="/resources/testharnessreport.js "> </ script >
8
+ < script src ="../support/numeric-testcommon.js "> </ script >
9
+ < div id ="target "> </ div >
10
+ < script >
11
+
12
+ // Identity tests
13
+ test_math_used ( 'pow(1,1)' , '1' , { type :'number' } ) ;
14
+ test_math_used ( 'sqrt(1)' , '1' , { type :'number' } ) ;
15
+ test_math_used ( 'hypot(1)' , '1' , { type :'number' } ) ;
16
+
17
+ // Nestings
18
+ test_math_used ( 'sqrt(pow(1,1))' , '1' ) ;
19
+ test_math_used ( 'hypot(pow(1, sqrt(1)))' , '1' ) ;
20
+ test_math_used ( 'calc(hypot(pow((1 + sqrt(1)) / 2, sqrt(1))))' , '1' ) ;
21
+
22
+ // General calculations
23
+ test_math_used ( 'calc(100px * pow(2, pow(2, 2)))' , '1600px' ) ;
24
+ test_math_used ( 'calc(1px * pow(2, 3))' , '8px' )
25
+ test_math_used ( 'calc(100px * sqrt(100))' , '1000px' ) ;
26
+ test_math_used ( 'calc(1px * pow(2, sqrt(100))' , '1024px' ) ;
27
+ test_math_used ( 'hypot(3px, 4px)' , '5px' ) ;
28
+ test_math_used ( 'calc(100px * hypot(3, 4))' , '500px' ) ;
29
+ test_math_used ( 'hypot(-5px)' , '5px' ) ;
30
+ test_math_used ( 'calc(1px * hypot(-5))' , '5px' ) ;
31
+ test_math_used ( 'calc(1px * hypot(10000))' , '10000px' ) ;
32
+ test_math_used ( 'calc(2px * sqrt(100000000))' , '20000px' ) ;
33
+ test_math_used ( 'calc(3px * pow(200, 4))' , '33554428px' ) ;
34
+
35
+ //Type checking hypot
36
+ test_math_used ( 'hypot(1px)' , '1px' ) ;
37
+ test_math_used ( 'hypot(1cm)' , '1cm' ) ;
38
+ test_math_used ( 'hypot(1mm)' , '1mm' ) ;
39
+ test_math_used ( 'hypot(1Q)' , '1Q' ) ;
40
+ test_math_used ( 'hypot(1in)' , '1in' ) ;
41
+ test_math_used ( 'hypot(1pc)' , '1pc' ) ;
42
+ test_math_used ( 'hypot(1pt)' , '1pt' ) ;
43
+ test_math_used ( 'hypot(1em)' , '1em' ) ;
44
+ test_math_used ( 'hypot(1ex)' , '1ex' ) ;
45
+ test_math_used ( 'hypot(1ch)' , '1ch' ) ;
46
+ test_math_used ( 'hypot(1rem)' , '1rem' ) ;
47
+ test_math_used ( 'hypot(1vh)' , '1vh' ) ;
48
+ test_math_used ( 'hypot(1vw)' , '1vw' ) ;
49
+ test_math_used ( 'hypot(1vmin)' , '1vmin' ) ;
50
+ test_math_used ( 'hypot(1vmax)' , '1vmax' ) ;
51
+ test_math_used ( 'hypot(1s)' , '1s' , { type :'time' } ) ;
52
+ test_math_used ( 'hypot(1ms)' , '1ms' , { type :'time' } ) ;
53
+ test_math_used ( 'hypot(1deg)' , '1deg' , { type :'angle' , approx :0.001 } ) ;
54
+ test_math_used ( 'hypot(1grad)' , '1grad' , { type :'angle' , approx :0.001 } ) ;
55
+ test_math_used ( 'hypot(1rad)' , '1rad' , { type :'angle' , approx :0.001 } ) ;
56
+ test_math_used ( 'hypot(1turn)' , '1turn' , { type :'angle' , approx :0.001 } ) ;
57
+ </ script >
0 commit comments