mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
dfa7916418
R=bkonyi@google.com Change-Id: I2f455fd681b66c43cbcd873f3d3d278a5ff5c843 Reviewed-on: https://dart-review.googlesource.com/12762 Commit-Queue: Terry Lucas <terry@google.com> Reviewed-by: Terry Lucas <terry@google.com>
99 lines
1.9 KiB
Dart
99 lines
1.9 KiB
Dart
// Copyright (c) 2014, 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';
|
|
|
|
var global = 0;
|
|
|
|
bar() {
|
|
global += 1;
|
|
}
|
|
|
|
baz() {
|
|
global += 100;
|
|
}
|
|
|
|
foo(x, y, z) {
|
|
if ((x ? false : true) ? y : z) {
|
|
bar();
|
|
bar();
|
|
} else {
|
|
baz();
|
|
baz();
|
|
}
|
|
}
|
|
|
|
foo2(x, y, z) {
|
|
return (x ? false : true) ? y : z;
|
|
}
|
|
|
|
foo3(x, y, z) {
|
|
if (x ? (z ? false : true) : (y ? false : true)) {
|
|
baz();
|
|
baz();
|
|
} else {
|
|
bar();
|
|
bar();
|
|
}
|
|
}
|
|
|
|
main() {
|
|
foo(true, true, true);
|
|
Expect.equals(2, global);
|
|
|
|
foo(true, true, false);
|
|
Expect.equals(202, global);
|
|
|
|
foo(true, false, true);
|
|
Expect.equals(204, global);
|
|
|
|
foo(true, false, false);
|
|
Expect.equals(404, global);
|
|
|
|
foo(false, true, true);
|
|
Expect.equals(406, global);
|
|
|
|
foo(false, true, false);
|
|
Expect.equals(408, global);
|
|
|
|
foo(false, false, true);
|
|
Expect.equals(608, global);
|
|
|
|
foo(false, false, false);
|
|
Expect.equals(808, global);
|
|
|
|
Expect.equals(true, foo2(true, true, true));
|
|
Expect.equals(false, foo2(true, true, false));
|
|
Expect.equals(true, foo2(true, false, true));
|
|
Expect.equals(false, foo2(true, false, false));
|
|
Expect.equals(true, foo2(false, true, true));
|
|
Expect.equals(true, foo2(false, true, false));
|
|
Expect.equals(false, foo2(false, false, true));
|
|
Expect.equals(false, foo2(false, false, false));
|
|
|
|
global = 0;
|
|
foo3(true, true, true);
|
|
Expect.equals(2, global);
|
|
|
|
foo3(true, true, false);
|
|
Expect.equals(202, global);
|
|
|
|
foo3(true, false, true);
|
|
Expect.equals(204, global);
|
|
|
|
foo3(true, false, false);
|
|
Expect.equals(404, global);
|
|
|
|
foo3(false, true, true);
|
|
Expect.equals(406, global);
|
|
|
|
foo3(false, true, false);
|
|
Expect.equals(408, global);
|
|
|
|
foo3(false, false, true);
|
|
Expect.equals(608, global);
|
|
|
|
foo3(false, false, false);
|
|
Expect.equals(808, global);
|
|
}
|