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

Unified Diff: dart/tests/corelib/src/IsOperatorBasicTypesTest.dart

Issue 9429047: Implement operator-is for interfaces' supertypes and String's supertypes. Also, improve stack trace… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 8 years, 10 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 | « dart/tests/co19/co19-leg.status ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/corelib/src/IsOperatorBasicTypesTest.dart
diff --git a/dart/tests/corelib/src/IsOperatorBasicTypesTest.dart b/dart/tests/corelib/src/IsOperatorBasicTypesTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..285c79346d539484f58ab0d8816d75ad7d7eeae3
--- /dev/null
+++ b/dart/tests/corelib/src/IsOperatorBasicTypesTest.dart
@@ -0,0 +1,71 @@
+// 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 the "is" type test operator.
+
+check(args) {
+ var list = args[0];
+ var string = args[1];
+ var nullObject = args[2];
+
+ Expect.isTrue(list is Object);
+ Expect.isTrue(list is List);
+ Expect.isTrue(list is Collection);
+ Expect.isTrue(list is Iterable);
+ Expect.isFalse(list is Comparable);
+ Expect.isFalse(list is Hashable);
+ Expect.isFalse(list is Pattern);
+ Expect.isFalse(list is String);
+
+ Expect.isFalse(list is !List);
+ Expect.isFalse(list is !Collection);
+ Expect.isFalse(list is !Iterable);
+ Expect.isTrue(list is !Comparable);
+ Expect.isTrue(list is !Hashable);
+ Expect.isTrue(list is !Pattern);
+ Expect.isTrue(list is !String);
+
+ Expect.isTrue(string is Object);
+ Expect.isFalse(string is List);
+ Expect.isFalse(string is Collection);
+ Expect.isFalse(string is Iterable);
+ Expect.isTrue(string is Comparable);
+ Expect.isTrue(string is Hashable);
+ Expect.isTrue(string is Pattern);
+ Expect.isTrue(string is String);
+
+ Expect.isTrue(string is !List);
+ Expect.isTrue(string is !Collection);
+ Expect.isTrue(string is !Iterable);
+ Expect.isFalse(string is !Comparable);
+ Expect.isFalse(string is !Hashable);
+ Expect.isFalse(string is !Pattern);
+ Expect.isFalse(string is !String);
+
+ Expect.isTrue(nullObject is Object);
+ Expect.isFalse(nullObject is List);
+ Expect.isFalse(nullObject is Collection);
+ Expect.isFalse(nullObject is Iterable);
+ Expect.isFalse(nullObject is Comparable);
+ Expect.isFalse(nullObject is Hashable);
+ Expect.isFalse(nullObject is Pattern);
+ Expect.isFalse(nullObject is String);
+
+ Expect.isTrue(nullObject is !List);
+ Expect.isTrue(nullObject is !Collection);
+ Expect.isTrue(nullObject is !Iterable);
+ Expect.isTrue(nullObject is !Comparable);
+ Expect.isTrue(nullObject is !Hashable);
+ Expect.isTrue(nullObject is !Pattern);
+ Expect.isTrue(nullObject is !String);
+}
+
+main() {
+ // Try to make it hard for an optimizing compiler to inline the
+ // tests.
+ check([[], 'string', null]);
+
+ // Try to make it even harder.
+ var string = new String.fromCharCodes([new Date.now().year % 100 + 1]);
+ check([string.charCodes(), string, null]);
+}
« no previous file with comments | « dart/tests/co19/co19-leg.status ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698