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

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

Issue 15759011: Type check field initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test added. Created 7 years, 7 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/compiler/dart2js/patch_test.dart
diff --git a/tests/compiler/dart2js/patch_test.dart b/tests/compiler/dart2js/patch_test.dart
index b0cec7d48b0bb2c248063549512ef8909acc60c5..f476e1e77b9cd2167e8692c742aadb8180f4a7ae 100644
--- a/tests/compiler/dart2js/patch_test.dart
+++ b/tests/compiler/dart2js/patch_test.dart
@@ -719,16 +719,33 @@ testPatchAndSelector() {
}
void testAnalyzeAllInjectedMembers() {
- String patchText = """
- void method() {
- String s = 0;
- }
- """;
- var compiler = applyPatch('', patchText, analyzeAll: true, analyzeOnly: true);
- compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')];
- compiler.runCompiler(null);
- compareWarningKinds(patchText,
- [MessageKind.NOT_ASSIGNABLE], compiler.warnings);
+ void expect(String patchText, [expectedWarnings]) {
+ if (expectedWarnings == null) expectedWarnings = [];
+ if (expectedWarnings is! List) expectedWarnings = [expectedWarnings];
+
+ var compiler = applyPatch('', patchText,
+ analyzeAll: true, analyzeOnly: true);
+ compiler.librariesToAnalyzeWhenRun = [Uri.parse('dart:core')];
+ compiler.runCompiler(null);
+ compareWarningKinds(patchText, expectedWarnings, compiler.warnings);
+ }
+
+ expect('String s = 0;', MessageKind.NOT_ASSIGNABLE);
+ expect('void method() { String s = 0; }', MessageKind.NOT_ASSIGNABLE);
+ expect('''
+ class Class {
+ String s = 0;
+ }
+ ''',
+ MessageKind.NOT_ASSIGNABLE);
+ expect('''
+ class Class {
+ void method() {
+ String s = 0;
+ }
+ }
+ ''',
+ MessageKind.NOT_ASSIGNABLE);
}
void testTypecheckPatchedMembers() {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/typechecker.dart ('k') | tests/compiler/dart2js/type_checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698