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

Unified Diff: tests/language_2/if_null_precedence_test.dart

Issue 3003933002: Migrate block 116. (Closed)
Patch Set: Created 3 years, 4 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/language_2/if_null_precedence_test.dart
diff --git a/tests/language/if_null_precedence_test.dart b/tests/language_2/if_null_precedence_test.dart
similarity index 50%
rename from tests/language/if_null_precedence_test.dart
rename to tests/language_2/if_null_precedence_test.dart
index 95dcb5bb8078090879938e5ee59f96f9c2449e54..e404d49d500a32585fb0ddb4b9e07774a2c8ac51 100644
--- a/tests/language/if_null_precedence_test.dart
+++ b/tests/language_2/if_null_precedence_test.dart
@@ -6,19 +6,6 @@
import "package:expect/expect.dart";
-assertionError(e) => e is AssertionError;
-
-// Determine whether the VM is running in checked mode.
-bool get checkedMode {
- try {
- var x = 'foo';
- int y = x;
- return false;
- } catch (_) {
- return true;
- }
-}
-
main() {
// Make sure the "none" test fails if "??" is not implemented. This makes
// status files easier to maintain.
@@ -26,39 +13,28 @@ main() {
// "a ?? b ?? c" should be legal, and should evaluate to the first non-null
// value (or null if there are no non-null values).
- Expect.equals(1, 1 ?? 2 ?? 3); //# 01: ok
- Expect.equals(2, null ?? 2 ?? 3); //# 02: ok
- Expect.equals(3, null ?? null ?? 3); //# 03: ok
- Expect.equals(null, null ?? null ?? null); //# 04: ok
+ Expect.equals(1, 1 ?? 2 ?? 3);
+ Expect.equals(2, null ?? 2 ?? 3);
+ Expect.equals(3, null ?? null ?? 3);
+ Expect.equals(null, null ?? null ?? null);
// "a ?? b ? c : d" should parse as "(a ?? b) ? c : d", therefore provided
// that a is true, b need not be a bool. An incorrect parse of
// "a ?? (b ? c : d)" would require b to be a bool to avoid a static type
// warning.
- Expect.equals(2, true ?? 1 ? 2 : 3); //# 05: ok
+ Expect.equals(2, true ?? 1 ? 2 : 3);
Lasse Reichstein Nielsen 2017/08/29 07:43:40 Should this be a type problem in Dart 2? Or is it
Bob Nystrom 2017/08/30 18:21:23 Yes, I believe that's right. You get Object as the
// "a ?? b || c" should parse as "a ?? (b || c)", therefore it's a static
// type warning if b doesn't have type bool. An incorrect parse of
// "(a ?? b) || c" would allow b to have any type provided that a is bool.
- Expect.equals(false, false ?? 1 || true); //# 06: static type warning
+ false ?? 1 || true; //# 06: compile-time error
// "a || b ?? c" should parse as "(a || b) ?? c", therefore it is a static
// type warning if b doesn't have type bool. An incorrect parse of
// "a || (b ?? c)" would allow b to have any type provided that c is bool.
- if (checkedMode) {
- Expect.throws(() => false || 1 ?? true, assertionError); //# 07: static type warning
- } else {
- Expect.equals(false, false || 1 ?? true); // //# 07: continued
- }
+ false || 1 ?? true; //# 07: compile-time error
- if (checkedMode) {
- // An incorrect parse of "a || (b ?? c)" would result in no checked-mode
- // error.
- Expect.throws(() => false || null ?? true, assertionError); //# 08: ok
- } else {
- // An incorrect parse of "a || (b ?? c)" would result in c being evaluated.
- int i = 0; // //# 08: continued
- Expect.equals(false, false || null ?? i++ == 0); // //# 08: continued
- Expect.equals(0, i); // //# 08: continued
- }
+ // An incorrect parse of "a || (b ?? c)" would result in no checked-mode
+ // error.
+ Expect.throwsAssertionError(() => false || null ?? true);
}

Powered by Google App Engine
This is Rietveld 408576698