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

Unified Diff: tests/compiler/dart2js/type_checker_test.dart

Issue 21292003: Handle int/double case expression types correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_checker_test.dart
diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
index f0f61fda245bc344c8714674069ce08d66c533c0..e543480a07e257a566731408dc1f5d767582218f 100644
--- a/tests/compiler/dart2js/type_checker_test.dart
+++ b/tests/compiler/dart2js/type_checker_test.dart
@@ -140,10 +140,19 @@ testSwitch() {
analyze("switch (0) { case 1: break; case 2: break; }");
analyze("switch (0) { case 1: int i = ''; break; case 2: break; }",
NOT_ASSIGNABLE);
- analyze("switch (0) { case '': break; case 2: break; }",
+ analyze("switch (0) { case '': break; }",
NOT_ASSIGNABLE);
analyze("switch ('') { case 1: break; case 2: break; }",
[NOT_ASSIGNABLE, NOT_ASSIGNABLE]);
+
+ analyze("switch (0.5) { case 0.5: break; case 1.5: break; }",
+ [], []);
+ analyze("switch (1.0) { case 1.0: break; case 1.5: break; }",
+ [], []);
+ analyze("switch (null) { case 1.0: break; case 2: break; }",
+ [MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
+ MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE],
+ [MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL]);
}
testOperators() {
@@ -1543,9 +1552,11 @@ api.DiagnosticHandler createHandler(String text) {
};
}
-analyze(String text, [expectedWarnings]) {
+analyze(String text, [expectedWarnings, expectedErrors]) {
if (expectedWarnings == null) expectedWarnings = [];
if (expectedWarnings is !List) expectedWarnings = [expectedWarnings];
+ if (expectedErrors == null) expectedErrors = [];
+ if (expectedErrors is !List) expectedErrors = [expectedErrors];
compiler.diagnosticHandler = createHandler(text);
@@ -1562,8 +1573,10 @@ analyze(String text, [expectedWarnings]) {
TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
types);
compiler.clearWarnings();
+ compiler.clearErrors();
checker.analyze(node);
compareWarningKinds(text, expectedWarnings, compiler.warnings);
+ compareWarningKinds(text, expectedErrors, compiler.errors);
compiler.diagnosticHandler = null;
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698