mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:33:28 +00:00
912005267d
Change-Id: I46be49b2effec3e38a3dc44cd45cfe736f77fa78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182680 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Stephen Adams <sra@google.com>
50 lines
1,016 B
Dart
50 lines
1,016 B
Dart
// Copyright (c) 2013, 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Regression test for Issue 12320, Issue 12363.
|
|
|
|
String log = '';
|
|
int? x;
|
|
|
|
void main() {
|
|
(run)(run);
|
|
// The little dance with passing [run] as an argument to confuse the optimizer
|
|
// so that [run] is not inlined. If [run] is inlined, the bug (Issue 12320)
|
|
// eliminates the following 'Expect', making the test appear to pass!
|
|
Expect.equals('[Foo][Foo 1][Bar][Foo][Foo 0]', log);
|
|
}
|
|
|
|
void run(f) {
|
|
if (f is! int) {
|
|
f(1);
|
|
} else {
|
|
x = f;
|
|
callFoo();
|
|
x = 2;
|
|
callBar();
|
|
callFoo();
|
|
}
|
|
}
|
|
|
|
void callFoo() {
|
|
log += '[Foo]';
|
|
switch (x) {
|
|
case 0:
|
|
log += '[Foo 0]';
|
|
break;
|
|
case 1:
|
|
log += '[Foo 1]';
|
|
break;
|
|
default:
|
|
throw 'invalid x';
|
|
}
|
|
}
|
|
|
|
void callBar() {
|
|
log += '[Bar]';
|
|
x = 0;
|
|
}
|