summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-values/round-mod-rem-computed.html
blob: 4c365eb2a1420d40b1f74ef587409a7d261db226 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!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-type-checking">
<link rel="author" title="Apple Inc">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/numeric-testcommon.js"></script>
<div style="width: 75px;">
    <div id="target"></div>
</div>
<script>
// Simple tests
test_math_used('round(10,10)', '10', {type:'number'});
test_math_used('mod(1,1)', '0', {type:'number'});
test_math_used('rem(1,1)', '0', {type:'number'});

//Test basic round
test_math_used('calc(round(100,10))', '100', {type:'number'});
test_math_used('calc(round(up, 101,10))', '110', {type:'number'});
test_math_used('calc(round(down, 106,10))', '100', {type:'number'});
test_math_used('calc(round(to-zero,105, 10))', '100', {type:'number'});
test_math_used('calc(round(to-zero,-105, 10))', '-100', {type:'number'});
test_math_used('calc(round(-100,10))', '-100', {type:'number'});
test_math_used('calc(round(up, -103,10))', '-100', {type:'number'});

//Test basic mod/rem
test_math_used('mod(18,5)', '3', {type:'number'});
test_math_used('rem(18,5)', '3', {type:'number'});
test_math_used('mod(-140,-90)', '-50', {type:'number'});
test_math_used('mod(-18,5)', '2', {type:'number'});
test_math_used('rem(-18,5)', '-3', {type:'number'});
test_math_used('mod(140,-90)', '-40', {type:'number'});
test_math_used('rem(140,-90)', '50', {type:'number'});

//Test basic calculations
test_math_used('calc(round(round(100,10), 10))', '100', {type:'number'});
test_math_used('calc(round(up, round(100,10) + 1,10))', '110', {type:'number'});
test_math_used('calc(round(down, round(100,10) + 2 * 3,10))', '100', {type:'number'});
test_math_used('calc(round(to-zero,round(100,10) * 2 - 95, 10))', '100', {type:'number'});
test_math_used('calc(round(round(100,10)* -1,10))', '-100', {type:'number'});
test_math_used('calc(round(up, -103 + -103 / -103 - 1,10))', '-100', {type:'number'});
test_math_used('calc(mod(18,5) * 2 + mod(17,5))', '8', {type:'number'});
test_math_used('calc(rem(mod(18,5),5))', '3', {type:'number'});
test_math_used('calc(rem(mod(18,5),mod(17,5)))', '1', {type:'number'});
test_math_used('calc(mod(-140,-90))', '-50', {type:'number'});
test_math_used('calc(mod(rem(1,18)* -1,5))', '4', {type:'number'});

// Type check
test_math_used('round(10px,6px)', '12px');
test_math_used('round(10cm,6cm)', '12cm');
test_math_used('round(10mm,6mm)', '12mm');
test_math_used('round(10Q, 6Q)', '12Q');
test_math_used('round(10in,6in)', '12in');
test_math_used('round(10pc,6pc)', '12pc');
test_math_used('round(10pt,6pt)', '12pt');
test_math_used('round(10em,6em)', '12em');
test_math_used('round(10ex,6ex)', '12ex');
test_math_used('round(10ch,6ch)', '12ch');
test_math_used('round(10rem,6rem)', '12rem');
test_math_used('round(10vh,6vh)', '12vh');
test_math_used('round(10vw,6vw)', '12vw');
test_math_used('round(10vmin,6vmin)', '12vmin');
test_math_used('round(10vmax,6vmax)', '12vmax');
test_math_used('round(10s,6s)', '12s', {type:'time'});
test_math_used('round(10ms,6ms)', '12ms', {type:'time'});
test_math_used('round(10deg,6deg)', '12deg', {type:'angle', approx:0.1});
test_math_used('round(10grad,6grad)', '12grad', {type:'angle', approx:0.1});
test_math_used('round(10rad,6rad)', '12rad',{type:'angle', approx:0.1});
test_math_used('round(10turn,6turn)', '12turn',{type:'angle', approx:0.1});

test_math_used('mod(10px,6px)', '4px');
test_math_used('mod(10cm,6cm)', '4cm');
test_math_used('mod(10mm,6mm)', '4mm');
test_math_used('mod(10Q, 6Q)', '4Q');
test_math_used('mod(10in,6in)', '4in');
test_math_used('mod(10pc,6pc)', '4pc');
test_math_used('mod(10em,6em)', '4em');
test_math_used('mod(10ex,6ex)', '4ex');
test_math_used('mod(10ch,6ch)', '4ch');
test_math_used('mod(10rem,6rem)', '4rem');
test_math_used('mod(10vh,6vh)', '4vh');
test_math_used('mod(10vw,6vw)', '4vw');
test_math_used('mod(10vmin,6vmin)', '4vmin');
test_math_used('mod(10vmax,6vmax)', '4vmax');
test_math_used('mod(10s,6s)', '4s', {type:'time'});
test_math_used('mod(10ms,6ms)', '4ms', {type:'time'});
test_math_used('mod(10deg,6deg)', '4deg', {type:'angle', approx:0.1});
test_math_used('mod(10grad,6grad)', '4grad', {type:'angle', approx:0.1});
test_math_used('mod(10rad,6rad)', '4rad',{type:'angle', approx:0.1});
test_math_used('mod(10turn,6turn)', '4turn',{type:'angle', approx:0.1});

test_math_used('rem(10px,6px)', '4px');
test_math_used('rem(10cm,6cm)', '4cm');
test_math_used('rem(10mm,6mm)', '4mm');
test_math_used('rem(10Q, 6Q)', '4Q');
test_math_used('rem(10in,6in)', '4in');
test_math_used('rem(10pc,6pc)', '4pc');
test_math_used('rem(10em,6em)', '4em');
test_math_used('rem(10ex,6ex)', '4ex');
test_math_used('rem(10ch,6ch)', '4ch');
test_math_used('rem(10rem,6rem)', '4rem');
test_math_used('rem(10vh,6vh)', '4vh');
test_math_used('rem(10vw,6vw)', '4vw');
test_math_used('rem(10vmin,6vmin)', '4vmin');
test_math_used('rem(10vmax,6vmax)', '4vmax');
test_math_used('rem(10s,6s)', '4s', {type:'time'});
test_math_used('rem(10ms,6ms)', '4ms', {type:'time'});
test_math_used('rem(10deg,6deg)', '4deg', {type:'angle', approx:0.1});
test_math_used('rem(10grad,6grad)', '4grad', {type:'angle', approx:0.1});
test_math_used('rem(10rad,6rad)', '4rad',{type:'angle', approx:0.1});
test_math_used('rem(10turn,6turn)', '4turn',{type:'angle', approx:0.1});

//Test percentage and mixed units
test_math_used('round(10%,1px)', '8px');
test_math_used('round(10%,5px)', '10px');
test_math_used('round(2rem,5px)', '30px');
test_math_used('round(100px,1rem)', '96px');
test_math_used('round(10s,6000ms)', '12s', {type:'time'});
test_math_used('round(10000ms,6s)', '12s', {type:'time'});

test_math_used('mod(10%,1px)', '0.5px');
test_math_used('mod(10%,5px)', '2.5px');
test_math_used('mod(2rem,5px)', '2px');
test_math_used('mod(100px,1rem)', '4px');
test_math_used('mod(10s,6000ms)', '4s', {type:'time'});
test_math_used('mod(10000ms,6s)', '4s', {type:'time'});
test_math_used('mod(18px,100% / 15)', '3px');
test_math_used('mod(-18px,100% / 15)', '2px');
test_math_used('mod(18%,5%)', '3%');
test_math_used('mod(-18%,5%)', '2%');
test_math_used('mod(18vw,5vw)', '3vw');
test_math_used('mod(-18vw,5vw)', '2vw');

test_math_used('rem(10%,1px)', '0.5px');
test_math_used('rem(10%,5px)', '2.5px');
test_math_used('rem(2rem,5px)', '2px');
test_math_used('rem(100px,1rem)', '4px');
test_math_used('rem(10s,6000ms)', '4s', {type:'time'});
test_math_used('rem(10000ms,6s)', '4s', {type:'time'});
test_math_used('rem(18px,100% / 15)', '3px');
test_math_used('rem(-18px,100% / 15)', '-3px');
test_math_used('rem(18vw,5vw)', '3vw');
test_math_used('rem(-18vw,5vw)', '-3vw');

test_math_used('calc(round(1px + 0%, 1px + 0%))', '1px');
test_math_used('calc(mod(1px + 0%, 1px + 0%))', '0px');
test_math_used('calc(rem(1px + 0%, 1px + 0%))', '0px');

</script>