v8/test/mjsunit/asm/infinite-loops-taken.js
neis 837900ef24 [tests] Fix bogus uses of assertThrows.
Some tests passed a string as second argument to assertThrows, expecting it to
be matched against the exception.  However, assertThrows simply ignored these.
(Some other tests actually seem to use that argument as a comment ...)

This CL
- changes assertThrows to fail if the second argument is not a function,
- adds assertThrowsEquals which compares the exception to a given value using
  assertEquals
- fixes some bogus tests that got exposed by this.

R=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1544793002

Cr-Commit-Position: refs/heads/master@{#33159}
2016-01-07 14:49:21 +00:00

42 lines
865 B
JavaScript

// 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();
assertThrowsEquals(function() { m.w0(counter(5)) }, error);
assertThrowsEquals(function() { m.w1(counter(5)) }, error);
assertThrowsEquals(function() { m.w2(counter(5)) }, error);
assertEquals(111, m.w3(counter(5)));