summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/asm/infinite-loops-taken.js
blob: d136c62469b7c910e563d7aa8a1603867afd22ce (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
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var error = "error";
function counter(x) {
  return (function() { if (x-- == 0) throw error;});
}

function Module() {
  "use asm";

  function w0(f) {
    while (1) f();
    return 108;
  }

  function w1(f) {
    if (1) while (1) f();
    return 109;
  }

  function w2(f) {
    if (1) while (1) f();
    else while (1) f();
    return 110;
  }

  function w3(f) {
    if (0) while (1) f();
    return 111;
  }

  return { w0: w0, w1: w1, w2: w2, w3: w3 };
}

var m = Module();
assertThrows(function() { m.w0(counter(5)) }, error);
assertThrows(function() { m.w1(counter(5)) }, error);
assertThrows(function() { m.w2(counter(5)) }, error);
assertEquals(111, m.w3(counter(5)));