dart-sdk/tests/language/instanceof4_test.dart
Jacob Richman 88eb557b65 Fix warnings_checker.dart handling of multitests
Update all tests

Support //# multitests for better dartfmt compatibility and fewer multitest false positives

All files under tests were manually updated with

find . -iregex '.*\.dart$' -print0 | xargs -0 perl -pi -e 's/(\S\s+)\/\/\/ /$1\/\/# /'

For now both old and new styles are allowed to accommodate CO19 tests.

R=efortuna@google.com
BUG=

Review-Url: https://codereview.chromium.org/2765693002 .
Review-Url: https://codereview.chromium.org/2765893003 .
2017-03-21 17:29:56 -07:00

73 lines
2.1 KiB
Dart

// Copyright (c) 2012, 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 the instanceof operation.
// Regression test for issue 5216.
// VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-compilation
import "package:expect/expect.dart";
class Foo<T> {
bool isT() => "a string" is T;
bool isNotT() => "a string" is! T;
bool isListT() => [0, 1, 2] is List<T>;
bool isNotListT() => [0, 1, 2] is! List<T>;
bool isAlsoListT() => <int>[0, 1, 2] is List<T>;
bool isNeitherListT() => <int>[0, 1, 2] is! List<T>;
}
testFooString() {
var o = new Foo<String>();
Expect.isTrue(o.isT());
Expect.isTrue(!o.isNotT());
Expect.isTrue(o.isListT());
Expect.isTrue(!o.isNotListT());
Expect.isTrue(!o.isAlsoListT()); // //# 01: ok
Expect.isTrue(o.isNeitherListT()); // //# 01: ok
for (var i = 0; i < 20; i++) {
// Make sure methods are optimized.
o.isT();
o.isNotT();
o.isListT();
o.isNotListT();
o.isAlsoListT(); // //# 01: ok
o.isNeitherListT(); // //# 01: ok
}
Expect.isTrue(o.isT(), "1");
Expect.isTrue(!o.isNotT(), "2");
Expect.isTrue(o.isListT(), "3");
Expect.isTrue(!o.isNotListT(), "4");
Expect.isTrue(!o.isAlsoListT(), "5"); // //# 01: ok
Expect.isTrue(o.isNeitherListT(), "6"); // //# 01: ok
}
testFooInt() {
var o = new Foo<int>();
Expect.isTrue(!o.isT());
Expect.isTrue(o.isNotT());
Expect.isTrue(o.isListT());
Expect.isTrue(!o.isNotListT());
Expect.isTrue(o.isAlsoListT());
Expect.isTrue(!o.isNeitherListT());
for (var i = 0; i < 20; i++) {
// Make sure methods are optimized.
o.isT();
o.isNotT();
o.isListT();
o.isNotListT();
o.isAlsoListT();
o.isNeitherListT();
}
Expect.isTrue(!o.isT());
Expect.isTrue(o.isNotT());
Expect.isTrue(o.isListT());
Expect.isTrue(!o.isNotListT());
Expect.isTrue(o.isAlsoListT());
Expect.isTrue(!o.isNeitherListT());
}
main() {
testFooString();
testFooInt();
}