blob: 65725117bd50069acad8326418f6e6e11a6ea38a [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 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 counter() {
6 var i = 100;
7 return function() {
8 if (i-- > 0) return i;
9 throw "done";
10 }
11}
12
13var c1 = counter();
14var c2 = counter();
15
16var f = (function() {
17 "use asm";
18 return function f(i) {
19 i = i|0;
20 do {
21 if (i > 0) c1();
22 else c2();
23 } while (true);
24 }
25})();
26
27assertThrows(function() { f(0); });
28assertThrows(function() { f(1); });
29
30var c3 = counter();
31
32var g = (function() {
33 "use asm";
34 return function g(i) {
35 i = i + 1;
36 do {
37 i = c3(i);
38 } while (true);
39 }
40})();
41
42assertThrows(function() { g(0); });
43assertThrows(function() { g(1); });