summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-values/calc-infinity-nan-serialize-length.html
blob: 4fd9479a164e2755ef0f11727635cc80a6edfe8d (plain)
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
<!DOCTYPE HTML>
<title>Infinity and NaN: calc() serialization for length values.</title>
<link rel="author" title="Seokho Song"  href="mailto:0xdevssh@gmail.com">
<link rel="help" href="https://drafts.csswg.org/css-values/#calc-type-checking">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/serialize-testcommon.js"></script>
<div id="target"></div>
<div id="log"></div>
<script>
function test_serialization(t,s, {prop="width"}={}) {
    test_specified_serialization(prop, t, s)
}
//TEST CASE                                          | EXPECTED
var test_map = {
    "1px * NaN"                                     :"calc(NaN * 1px)",
    "1px * nan"                                     :"calc(NaN * 1px)",
    "1px * infinity / infinity"                     :"calc(NaN * 1px)",
    "1px * 0 * infinity"                            :"calc(NaN * 1px)",
    "1px * (infinity + -infinity)"                  :"calc(NaN * 1px)",
    "1px * (-infinity + infinity)"                  :"calc(NaN * 1px)",
    "1px * (infinity - infinity)"                   :"calc(NaN * 1px)",
    "1px * infinity"                                :"calc(infinity * 1px)",
    "1px * -infinity"                               :"calc(-infinity * 1px)",
    "1px * iNFinIty"                                :"calc(infinity * 1px)",
    "1px * (infinity + infinity)"                   :"calc(infinity * 1px)",
    "1px * (-infinity + -infinity)"                 :"calc(-infinity * 1px)",
    "1px * 1/infinity"                              :"calc(0px)",
    "1px * infinity * infinity"                     :"calc(infinity * 1px)",
    "1px * -infinity * -infinity"                   :"calc(infinity * 1px)",
    "1 * max(INFinity*3px, 0px)"                    :"calc(infinity * 1px)",
    "1 * min(inFInity*4px, 0px)"                    :"calc(0px)",
    "1 * max(nAn*2px, 0px)"                         :"calc(NaN * 1px)",
    "1 * min(nan*3px, 0px)"                         :"calc(NaN * 1px)",
    "1 * clamp(-INFINITY*20px, 0px, infiniTY*10px)" :"calc(0px)",

    "1px * max(NaN, min(0,10))"                     :"calc(NaN * 1px)",
    "1px * clamp(NaN, 0, 10)"                       :"calc(NaN * 1px)",

    "1px * max(0, min(10, NaN))"                    :"calc(NaN * 1px)",
    "1px * clamp(0, 10, NaN)"                       :"calc(NaN * 1px)",

    "1px * max(0, min(NaN, 10))"                    :"calc(NaN * 1px)",
    "1px * clamp(0, NaN, 10)"                       :"calc(NaN * 1px)",

    "1px * clamp(-Infinity, 0, infinity)"           :"calc(0px)",
    "1px * clamp(-inFinity, infinity, 10)"          :"calc(10px)",
};

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