File: acos-asin-atan-atan2-serialize.html

package info (click to toggle)
firefox-esr 140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,539,276 kB
  • sloc: cpp: 7,381,286; javascript: 6,388,710; ansic: 3,710,139; python: 1,393,780; xml: 628,165; asm: 426,918; java: 184,004; sh: 65,742; makefile: 19,302; objc: 13,059; perl: 12,912; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,226; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (61 lines) | stat: -rw-r--r-- 3,519 bytes parent folder | download | duplicates (12)
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
58
59
60
61
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#trig-funcs">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#angles">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-serialize">
<link rel="author" title="Apple Inc">
<link rel="author" title="Seokho Song" href="seokho@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/serialize-testcommon.js"></script>
<div id=target></div>
<script>

function test_serialization(specified, expected, {prop="transform"}={}) {

    // We only test the specified serialization,
    // and not the computed or used serialization,
    // since we'd need to do that by retrieving the rotation matrix,
    // and that isn't perfectly interoperable in corner cases.
    // Plus the point of this test is to check the trig functions themselves.
    test_specified_serialization(prop, `rotate(${specified})`, `rotate(${expected})`)
}
//TEST CASE                                            | EXPECTED
var test_map = {
    "acos(1)"                                           :"calc(0deg)",
    "acos(-1)"                                          :"calc(180deg)",
    "acos(-1.5)"                                        :"calc(NaN * 1deg)",
    "acos(1.5)"                                         :"calc(NaN * 1deg)",
    "acos(2)"                                           :"calc(NaN * 1deg)",
    "acos(0.5)"                                         :"calc(60deg)",
    "acos(1 - 0.5)"                                     :"calc(60deg)",
    "acos(0)"                                           :"calc(90deg)",
    "asin(1)"                                           :"calc(90deg)",
    "asin(-1)"                                          :"calc(-90deg)",
    "asin(-1.5)"                                        :"calc(NaN * 1deg)",
    "asin(1.5)"                                         :"calc(NaN * 1deg)",
    "asin(2)"                                           :"calc(NaN * 1deg)",
    "asin(0.5)"                                         :"calc(30deg)",
    "asin(1 - 0.5)"                                     :"calc(30deg)",
    "asin(0)"                                           :"calc(0deg)",
    "acos(pi - pi)"                                     :"calc(90deg)",
    "asin(pi - pi + 1)"                                 :"calc(90deg)",
    "atan(1)"                                           :"calc(45deg)",
    "atan(0.577350269)"                                 :"calc(30deg)",
    "atan(0)"                                           :"calc(0deg)",
    "atan(infinity)"                                    :"calc(90deg)",
    "atan2(37.320508075, 10)"                           :"calc(75deg)",
    "atan2(1s, 1000ms)"                                 :"calc(45deg)",
    "atan2(infinity, infinity)"                         :"calc(45deg)",
    "atan2(-infinity, -infinity)"                       :"calc(-135deg)",
    "atan2(infinity, 10)"                               :"calc(90deg)",
    "atan2(10, infinity)"                               :"calc(0deg)",
    "atan2(NaN, 10)"                                    :"calc(NaN * 1deg)",
    "atan2(10, NaN)"                                    :"calc(NaN * 1deg)",
    "atan2(NaN, NaN)"                                   :"calc(NaN * 1deg)",
};

for (var exp in test_map) {
    test_serialization(exp, test_map[exp]);
    test_serialization(`calc(${exp})`, test_map[exp]);
}
</script>