2dcd56ef43
There are far too many files here to review everyone carefully. Spot checking most of the diffs look good as test code is generally written with less care than application code so lots of ugly formatting get through. If people notice files where the automated formatting bothers them feel free to comment indicating file names and I'll move spaces within comments to make the formatting cleaner and use comments to force block formatting as I have done for other case where formatting looked bad. BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2771453003 .
76 lines
1.7 KiB
Dart
76 lines
1.7 KiB
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
// Dart test program for testing try/catch statement without any exceptions
|
|
// being thrown.
|
|
// VMOptions=--optimization-counter-threshold=100 --no-background-compilation --enable-inlining-annotations
|
|
|
|
// Test optional parameters updated inside try-catch
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
const noInline = "NeverInline";
|
|
|
|
@noInline
|
|
m1(int b) {
|
|
if (b == 1) throw 123;
|
|
}
|
|
|
|
@noInline
|
|
m2(int b) {
|
|
if (b == 2) throw 456;
|
|
}
|
|
|
|
@noInline
|
|
test1(int b, [int state = 0]) {
|
|
try {
|
|
state++;
|
|
m1(b);
|
|
state++;
|
|
m2(b);
|
|
state++;
|
|
} on dynamic catch (e, s) {
|
|
if (b == 1 && state != 1) throw "fail1";
|
|
if (b == 2 && state != 2) throw "fail2";
|
|
if (b == 3 && state != 3) throw "fail3";
|
|
if (s is! StackTrace) throw "fail4";
|
|
return e;
|
|
}
|
|
return "no throw";
|
|
}
|
|
|
|
@noInline
|
|
test2(int b, [int state]) {
|
|
state = 0;
|
|
try {
|
|
state++;
|
|
m1(b);
|
|
state++;
|
|
m2(b);
|
|
state++;
|
|
} on dynamic catch (e, s) {
|
|
if (b == 1 && state != 1) throw "fail1";
|
|
if (b == 2 && state != 2) throw "fail2";
|
|
if (b == 3 && state != 3) throw "fail3";
|
|
if (s is! StackTrace) throw "fail4";
|
|
return e;
|
|
}
|
|
return "no throw";
|
|
}
|
|
|
|
main() {
|
|
for (var i = 0; i < 300; i++) {
|
|
Expect.equals("no throw", test1(0));
|
|
}
|
|
Expect.equals("no throw", test1(0));
|
|
Expect.equals(123, test1(1));
|
|
Expect.equals(456, test1(2));
|
|
|
|
for (var i = 0; i < 300; i++) {
|
|
Expect.equals("no throw", test2(0));
|
|
}
|
|
Expect.equals("no throw", test2(0));
|
|
Expect.equals(123, test2(1));
|
|
Expect.equals(456, test2(2));
|
|
}
|