Skip to content

Commit

Permalink
[vm] Add test for certain cases of unreachable code
Browse files Browse the repository at this point in the history
This is the follow-up for dart-lang/sdk@1d10e03.

Change-Id: Ifd35acb08904d34010ede0fe609076424d146374
Reviewed-on: https://dart-review.googlesource.com/c/81331
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
  • Loading branch information
alexmarkov authored and commit-bot@chromium.org committed Oct 24, 2018
1 parent daae20d commit 3e750a7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/language_2/vm/unreachable_code_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2018, 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.

// Verifies that VM is able to handle certain cases of unreachable code.

// VMOptions=--no_background_compilation --optimization_counter_threshold=10

import "package:expect/expect.dart";

class A {
dynamic next;
}

test1(A arg1, bool arg2, bool arg3) {
assert(arg1.next == (arg2 ?? arg3));
}

test2(A arg1, bool arg2, bool arg3) {
print(((throw 'Error') as dynamic).next == (arg2 ?? arg3));
}

void doTests() {
test1(new A(), null, null);
Expect.throws(() {
test2(new A(), null, null);
});
}

void main() {
for (int i = 0; i < 20; i++) {
doTests();
}
}

0 comments on commit 3e750a7

Please sign in to comment.