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

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

Issue 23533040: Check for non-final field in the face of const constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 3 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 | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/compiler/dart2js/type_checker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/resolver_test.dart
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index 0a1a9dd41bf06e39267fd30dc1848a3bb56d49b7..cd4e373a3cb3ec16adcd997c312c8baaf4eed9a5 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -79,6 +79,7 @@ main() {
testOverrideHashCodeCheck();
testSupertypeOrder();
testConstructorArgumentMismatch();
+ testConstConstructorAndNonFinalFields();
}
testSupertypeOrder() {
@@ -846,6 +847,7 @@ List<String> asSortedStrings(Link link) {
Future compileScript(String source) {
Uri uri = new Uri(scheme: 'source');
MockCompiler compiler = compilerFor(source, uri);
+ compiler.diagnosticHandler = createHandler(compiler, source);
return compiler.runCompiler(uri).then((_) {
return compiler;
});
@@ -926,3 +928,49 @@ testOverrideHashCodeCheck() {
Expect.equals(0, compiler.errors.length);
}));
}
+
+testConstConstructorAndNonFinalFields() {
+ void expect(compiler, List errors, List warnings) {
+ Expect.equals(errors.length, compiler.errors.length);
+ for (int i = 0 ; i < errors.length ; i++) {
+ Expect.equals(errors[i], compiler.errors[i].message.kind);
+ }
+ Expect.equals(warnings.length, compiler.warnings.length);
+ for (int i = 0 ; i < warnings.length ; i++) {
+ Expect.equals(warnings[i], compiler.warnings[i].message.kind);
+ }
+ }
+
+ final script1 = r"""
+ class A {
+ var a;
+ const A(this.a);
+ }
+ main() {
+ new A(0);
+ }""";
+ asyncTest(() => compileScript(script1).then((compiler) {
+ expect(compiler,
+ [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
+ [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
+ }));
+
+ final script2 = r"""
+ class A {
+ var a;
+ var b;
+ const A(this.a, this.b);
+ const A.named(this.a, this.b);
+ }
+ main() {
+ new A(0, 1);
+ }""";
+ asyncTest(() => compileScript(script2).then((compiler) {
+ expect(compiler,
+ [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
+ [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
+ MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
+ MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
+ MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
+ }));
+}
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/compiler/dart2js/type_checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698