Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: tests/language/instanceof4_test.dart

Issue 10942006: Fix bad optimization of instance-of with uninstantiated types (issue 5216). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/instanceof4_test.dart
===================================================================
--- tests/language/instanceof4_test.dart (revision 0)
+++ tests/language/instanceof4_test.dart (revision 0)
@@ -0,0 +1,69 @@
+// 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.
+
+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());
+ Expect.isTrue(o.isNeitherListT());
+ for (var i = 0; i < 4000; 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());
+}
+
+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 < 4000; 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();
+}
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698