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

Unified Diff: tests/corelib/map_to_string_test.dart

Issue 18837002: Move toString() to collection classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 7 years, 5 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/map_to_string_test.dart
diff --git a/tests/corelib/map_to_string_test.dart b/tests/corelib/map_to_string_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2200a0309bcb360fb22d060441f76fce1b58db6a
--- /dev/null
+++ b/tests/corelib/map_to_string_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2013, 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";
+
+void main() {
+ Map m = new Map();
+
+ m[0] = 0;
+ m[1] = 1;
+ m[2] = m;
+
+ Expect.equals('{0: 0, 1: 1, 2: {...}}', m.toString());
+
+ m[1] = new ThrowOnToString();
+ Expect.throws(m.toString, (e) => e == "Bad!");
+ m[1] = 1;
+ Expect.equals('{0: 0, 1: 1, 2: {...}}', m.toString());
+}
+
+class ThrowOnToString {
+
+ String toString() {
+ throw "Bad!";
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698