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

Unified Diff: tests/corelib/list_contains_argument_order_test.dart

Issue 17830002: Test equality argument order in iterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
Index: tests/corelib/list_contains_argument_order_test.dart
diff --git a/tests/corelib/list_contains_argument_order_test.dart b/tests/corelib/list_contains_argument_order_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..85f97825101aaa6467ea789344f3c91d691ecbd1
--- /dev/null
+++ b/tests/corelib/list_contains_argument_order_test.dart
@@ -0,0 +1,42 @@
+import "package:expect/expect.dart";
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Add missing copyright header (remember to update y
zarah 2013/06/26 09:08:34 Done.
+
+bool a;
+
+class A {
+ bool operator ==(A other) {
+ a = true;
+ return false;
+ }
+}
+
+class B {
+ bool operator ==(B other) {
+ throw new Exception('Bad equality order.');
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Change line to: Expect.fail("Bad equality order."
zarah 2013/06/26 09:08:34 Done.
+ }
+}
+
+main() {
+ var list = <A>[new A() ];
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Add space between '[' and 'new'.
zarah 2013/06/26 09:08:34 Done.
+ var list2 = new List<A>(1);
Lasse Reichstein Nielsen 2013/06/26 08:26:59 You can use cascade notation to initialize on the
zarah 2013/06/26 09:08:34 Done.
+ list2[0] = new A();
+ var list3 = new List<A>();
+ list3.add(new A());
+ var list4 = <A>[new A() ];
+ var iterable = list.map((x) => x);
+ var iterable2 = list.take(1);
Lasse Reichstein Nielsen 2013/06/26 08:26:59 If you want to do this for each iterable, do it in
zarah 2013/06/26 09:08:34 Done.
+ var iterable3 = list2.map((x) => x);
+ var iterable4 = list2.take(1);
+ var iterable5 = list3.map((x) => x);
+ var iterable6 = list3.take(1);
+ var iterable7 = list4.map((x) => x);
+ var iterable8 = list4.take(1);
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Try a Set, Map.keys, and Map.values as well: va
zarah 2013/06/26 09:08:34 Done.
+
+ var iterables =
+ [list, list2, list3, list4, iterable, iterable2, iterable3,
+ iterable4, iterable5, iterable6, iterable7, iterable8];
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Now that you can have each iterable created on a s
zarah 2013/06/26 09:08:34 Done.
+ for (var iterable in iterables) {
+ a = false;
Lasse Reichstein Nielsen 2013/06/26 08:26:59 Indentation is off-by-one (should be indented one
zarah 2013/06/26 09:08:34 Done.
+ iterable.contains(new B());
+ Expect.isTrue(a);
+ }
+}
« sdk/lib/_collection_dev/iterable.dart ('K') | « sdk/lib/_collection_dev/iterable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698