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

Unified Diff: tests/language/list_literal3_test.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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 | « tests/language/if_and_test.dart ('k') | tests/language/ordered_maps_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/list_literal3_test.dart
diff --git a/tests/language/list_literal3_test.dart b/tests/language/list_literal3_test.dart
index 497aee43d6cc0f68846a281428ae1f086479b76b..1d657e322b047244f8c3f7352ca315d466a9d0a9 100644
--- a/tests/language/list_literal3_test.dart
+++ b/tests/language/list_literal3_test.dart
@@ -11,52 +11,34 @@ class ListLiteral3Test {
List<String> joke = const ["knock", "knock"];
// Elements of canonical lists are canonicalized.
- Expect.equals(true, joke === canonicalJoke);
- Expect.equals(true, joke[0] === joke[1]);
- Expect.equals(true, joke[0] === canonicalJoke[0]);
+ Expect.identical(joke, canonicalJoke);
+ Expect.identical(joke[0], joke[1]);
+ Expect.identical(joke[0], canonicalJoke[0]);
// Lists from literals are immutable.
- bool caughtException = false;
- try {
- joke[0] = "sock";
- } on UnsupportedError catch (e) {
- caughtException = true;
- }
- Expect.equals(true, caughtException);
- Expect.equals(true, joke[0] === joke[1]);
+ Expect.throws(() { joke[0] = "sock"; }, (e) => e is UnsupportedError);
+ Expect.identical(joke[0], joke[1]);
// Make sure lists allocated at runtime are mutable and are
// not canonicalized.
List<String> lame_joke = ["knock", "knock"]; // Invokes operator new.
- Expect.equals(true, joke[1] === lame_joke[1]);
+ Expect.identical(joke[1], lame_joke[1]);
// Operator new creates a mutable list.
- Expect.equals(false, joke === lame_joke);
+ Expect.equals(false, identical(joke, lame_joke));
lame_joke[1] = "who";
- Expect.equals(true, "who" === lame_joke[1]);
+ Expect.identical("who", lame_joke[1]);
// Elements of canonical lists are canonicalized.
List<List<int>> a = const <List<int>>[ const [1, 2], const [1, 2]];
- Expect.equals(true, a[0] === a[1]);
- Expect.equals(true, a[0][0] === a[1][0]);
- try {
- caughtException = false;
- a[0][0] = 42;
- } on UnsupportedError catch (e) {
- caughtException = true;
- }
- Expect.equals(true, caughtException);
+ Expect.identical(a[0], a[1]);
+ Expect.identical(a[0][0], a[1][0]);
+ Expect.throws(() { a[0][0] = 42; }, (e) => e is UnsupportedError);
List<List<double>> b = const [ const [1.0, 2.0], const [1.0, 2.0]];
- Expect.equals(true, b[0] === b[1]);
- Expect.equals(true, b[0][0] === 1.0);
- Expect.equals(true, b[0][0] === b[1][0]);
- try {
- caughtException = false;
- b[0][0] = 42.0;
- } on UnsupportedError catch (e) {
- caughtException = true;
- }
- Expect.equals(true, caughtException);
+ Expect.identical(b[0], b[1]);
+ Expect.equals(true, b[0][0] == 1.0);
+ Expect.identical(b[0][0], b[1][0]);
+ Expect.throws(() { b[0][0] = 42.0; }, (e) => e is UnsupportedError);
}
}
« no previous file with comments | « tests/language/if_and_test.dart ('k') | tests/language/ordered_maps_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698