• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5function Module(stdlib, foreign, heap) {
6  "use asm";
7  function f1(i) {
8    i = +i;
9    return +(i * -1);
10  }
11  function f2(i) {
12    i = +i;
13    return +(-1 * i);
14  }
15  function f3(i) {
16    i = +i;
17    return +(-i);
18  }
19  return { f1: f1, f2: f2, f3: f3 };
20}
21
22var m = Module(this, {}, new ArrayBuffer(64 * 1024));
23
24assertEquals(NaN, m.f1(NaN));
25assertEquals(NaN, m.f2(NaN));
26assertEquals(NaN, m.f3(NaN));
27assertEquals(Infinity, 1 / m.f1(-0));
28assertEquals(Infinity, 1 / m.f2(-0));
29assertEquals(Infinity, 1 / m.f3(-0));
30assertEquals(Infinity, m.f1(-Infinity));
31assertEquals(Infinity, m.f2(-Infinity));
32assertEquals(Infinity, m.f3(-Infinity));
33assertEquals(-Infinity, 1 / m.f1(0));
34assertEquals(-Infinity, 1 / m.f2(0));
35assertEquals(-Infinity, 1 / m.f3(0));
36assertEquals(-Infinity, m.f1(Infinity));
37assertEquals(-Infinity, m.f2(Infinity));
38assertEquals(-Infinity, m.f3(Infinity));
39for (var i = -2147483648; i < 2147483648; i += 3999777) {
40  assertEquals(-i, m.f1(i));
41  assertEquals(-i, m.f2(i));
42  assertEquals(-i, m.f3(i));
43}
44