v8/test/mjsunit/harmony/optional-catch-binding-breaks.js
Sathya Gunasekaran 779c080895 [ESNext] Implement optional catch binding
This is just a rebased version of
https://chromium-review.googlesource.com/c/v8/v8/+/571453 with
no functional changes

Bug: v8:6889
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ia082cc09ca527505b288ac88e68e0b74eae94765
Reviewed-on: https://chromium-review.googlesource.com/849423
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50417}
2018-01-08 18:09:34 +00:00

66 lines
1.2 KiB
JavaScript

// Copyright 2017 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.
// Flags: --harmony-optional-catch-binding
let state = 'initial';
x: try {
throw new Error('caught');
state = 'unreachable';
} catch {
assertEquals(state, 'initial');
state = 'caught';
break x;
state = 'unreachable';
}
assertEquals(state, 'caught');
state = 'initial';
x: try {
throw new Error('caught');
state = 'unreachable';
} catch {
assertEquals(state, 'initial');
state = 'caught';
break x;
state = 'unreachable';
} finally {
assertEquals(state, 'caught');
state = 'finally';
}
assertEquals(state, 'finally');
state = 'initial';
x: {
y: try {
throw new Error('caught');
state = 'unreachable';
} catch {
assertEquals(state, 'initial');
state = 'caught';
break x;
state = 'unreachable';
} finally {
assertEquals(state, 'caught');
state = 'finally';
break y;
state = 'unreachable';
}
assertEquals(state, 'finally');
state = 'after block';
}
assertEquals(state, 'after block');
do {
try {
throw new Error();
} catch {
break;
}
assertUnreachable();
} while(false);