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
|
<!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-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"}={}) {
test_specified_serialization(prop, `scale(${specified})`, `scale(${expected})`)
}
//TEST CASE | EXPECTED
var test_map = {
"cos(0)" :"calc(1)",
"sin(0)" :"calc(0)",
"tan(0)" :"calc(0)",
"calc(sin(0) + 0.5)" :"calc(0.5)",
"calc(sin(0) + cos(0) + tan(0))" :"calc(1)",
"calc(cos(0) + 0.5)" :"calc(1.5)",
"calc(tan(0) + 0.5)" :"calc(0.5)",
"cos(0deg)" :"calc(1)",
"sin(0deg)" :"calc(0)",
"tan(0deg)" :"calc(0)",
"sin(30deg)" :"calc(0.5)",
"sin(0.523599)" :"calc(0.5)",
"sin(0.523599rad)" :"calc(0.5)",
"sin(33.333333grad)" :"calc(0.5)",
"sin(0.08333333turn)" :"calc(0.5)",
"cos(60deg)" :"calc(0.5)",
"cos(66.66666666grad)" :"calc(0.5)",
"cos(1.047197551)" :"calc(0.5)",
"cos(1.047197551rad)" :"calc(0.5)",
"cos(0.16666666666turn)" :"calc(0.5)",
"tan(45deg)" :"calc(1)",
"tan(50grad)" :"calc(1)",
"tan(0.78539816)" :"calc(1)",
"tan(0.78539816rad)" :"calc(1)",
"tan(0.125turn)" :"calc(1)",
"tan(90deg)" :"calc(infinity)",
"tan(-90deg)" :"calc(-infinity)",
"calc(sin(30deg) + cos(60deg) + tan(45deg))" :"calc(2)",
"calc(sin(infinity))" :"calc(NaN)",
"calc(cos(infinity))" :"calc(NaN)",
"calc(tan(infinity))" :"calc(NaN)",
"calc(sin(-infinity))" :"calc(NaN)",
"calc(cos(-infinity))" :"calc(NaN)",
"calc(tan(-infinity))" :"calc(NaN)",
};
for (var exp in test_map) {
test_serialization(exp, test_map[exp]);
test_serialization(`calc(${exp})`, test_map[exp]);
}
</script>
|