summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-values/calc-catch-divide-by-0.html
blob: ed5dbc90e4102df30e51ace05b5c8ea95208068c (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
<!DOCTYPE HTML>
<title>Zero Division: calc() serialization.</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 = {
    "100px * 0 / 0"                   :"calc(NaN * 1px)",
    "100px / 0"                       :"calc(infinity * 1px)",
    "100px / (0)"                     :"calc(infinity * 1px)",
    "100px / (2 - 2)"                 :"calc(infinity * 1px)",
    "100px / (2 - (-62 + 64))"        :"calc(infinity * 1px)",
    "100px * (1 / 0)"                 :"calc(infinity * 1px)",
    "100px * (1 / (0))"               :"calc(infinity * 1px)",
    "100px * (1 / (2 - 2))"           :"calc(infinity * 1px)",
    "100px * (1 / (2 - (-62 + 64)))"  :"calc(infinity * 1px)",
    "1px * max(1/0, 0)"               :"calc(infinity * 1px)",
    "1px * min(1/0, 0)"               :"calc(0px)",
    "1px * max(0/0, 0)"               :"calc(NaN * 1px)",
    "1px * min(0/0, 0)"               :"calc(NaN * 1px)",

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

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

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

    "1px * clamp(-1/0, 0, 1/0)"       :"calc(0px)",
    "1px * clamp(-1/0, 1/0, 10)"      :"calc(10px)",
};
for (var exp in test_map) {
    test_serialization("calc("+exp+")", test_map[exp])
}

</script>