summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/math-indirect-truncate.js
blob: 9cc967ca331a436489e7bd2cc02ad0b63e8d95b4 (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
function testCeil() {
  function ceil(a, b) {
    return Math.ceil(a / b) | 0;
  }

  // Warm-up
  for (var i = 0; i < 50; i++) {
    ceil(5, 5);
  }

  assertEq(ceil(5, 3), 2);
}
testCeil();

function testFloor() {
  function floor(a, b) {
    return Math.floor(a / b) | 0;
  }

  // Warm-up
  for (var i = 0; i < 50; i++) {
    floor(5, 5);
  }

  assertEq(floor(-5, 3), -2);
}
testFloor();

function testRound() {
  function round(a, b) {
    return Math.round(a / b) | 0;
  }

  // Warm-up
  for (var i = 0; i < 50; i++) {
    round(5, 5);
  }

  assertEq(round(5, 3), 2);
}
testRound();

function testTrunc() {
  function trunc(a, b) {
    return Math.trunc(a / b) | 0;
  }

  // Warm-up
  for (var i = 0; i < 50; i++) {
    trunc(5, 5);
  }

  assertEq(trunc(5, 3), 1);
}
testTrunc();