acos-asin-atan-atan2-serialize.html (3519B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/css-values-4/#trig-funcs"> 3 <link rel="help" href="https://drafts.csswg.org/css-values-4/#angles"> 4 <link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-serialize"> 5 <link rel="author" title="Apple Inc"> 6 <link rel="author" title="Seokho Song" href="seokho@chromium.org"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="../support/serialize-testcommon.js"></script> 10 <div id=target></div> 11 <script> 12 13 function test_serialization(specified, expected, {prop="transform"}={}) { 14 15 // We only test the specified serialization, 16 // and not the computed or used serialization, 17 // since we'd need to do that by retrieving the rotation matrix, 18 // and that isn't perfectly interoperable in corner cases. 19 // Plus the point of this test is to check the trig functions themselves. 20 test_specified_serialization(prop, `rotate(${specified})`, `rotate(${expected})`) 21 } 22 //TEST CASE | EXPECTED 23 var test_map = { 24 "acos(1)" :"calc(0deg)", 25 "acos(-1)" :"calc(180deg)", 26 "acos(-1.5)" :"calc(NaN * 1deg)", 27 "acos(1.5)" :"calc(NaN * 1deg)", 28 "acos(2)" :"calc(NaN * 1deg)", 29 "acos(0.5)" :"calc(60deg)", 30 "acos(1 - 0.5)" :"calc(60deg)", 31 "acos(0)" :"calc(90deg)", 32 "asin(1)" :"calc(90deg)", 33 "asin(-1)" :"calc(-90deg)", 34 "asin(-1.5)" :"calc(NaN * 1deg)", 35 "asin(1.5)" :"calc(NaN * 1deg)", 36 "asin(2)" :"calc(NaN * 1deg)", 37 "asin(0.5)" :"calc(30deg)", 38 "asin(1 - 0.5)" :"calc(30deg)", 39 "asin(0)" :"calc(0deg)", 40 "acos(pi - pi)" :"calc(90deg)", 41 "asin(pi - pi + 1)" :"calc(90deg)", 42 "atan(1)" :"calc(45deg)", 43 "atan(0.577350269)" :"calc(30deg)", 44 "atan(0)" :"calc(0deg)", 45 "atan(infinity)" :"calc(90deg)", 46 "atan2(37.320508075, 10)" :"calc(75deg)", 47 "atan2(1s, 1000ms)" :"calc(45deg)", 48 "atan2(infinity, infinity)" :"calc(45deg)", 49 "atan2(-infinity, -infinity)" :"calc(-135deg)", 50 "atan2(infinity, 10)" :"calc(90deg)", 51 "atan2(10, infinity)" :"calc(0deg)", 52 "atan2(NaN, 10)" :"calc(NaN * 1deg)", 53 "atan2(10, NaN)" :"calc(NaN * 1deg)", 54 "atan2(NaN, NaN)" :"calc(NaN * 1deg)", 55 }; 56 57 for (var exp in test_map) { 58 test_serialization(exp, test_map[exp]); 59 test_serialization(`calc(${exp})`, test_map[exp]); 60 } 61 </script>