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

Side by Side Diff: pkg/analyzer/test/generated/compile_time_error_code_test.dart

Issue 3003363002: Report compile time errors when assert initializers fail. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.compile_time_error_code_test; 5 library analyzer.test.generated.compile_time_error_code_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/src/error/codes.dart'; 10 import 'package:analyzer/src/error/codes.dart';
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 m() {} 1113 m() {}
1114 } 1114 }
1115 final a = const A(); 1115 final a = const A();
1116 const C = a.m;'''); 1116 const C = a.m;''');
1117 await computeAnalysisResult(source); 1117 await computeAnalysisResult(source);
1118 assertErrors(source, 1118 assertErrors(source,
1119 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1119 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
1120 verify([source]); 1120 verify([source]);
1121 } 1121 }
1122 1122
1123 test_constEvalThrowsException_assertInitializer_false() async {
1124 resetWith(
1125 options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
1126 Source source = addSource(r'''
1127 class A {
1128 const A(int p) : assert(p != 0);
1129 }
1130 const a = const A(0);
1131 ''');
1132 await computeAnalysisResult(source);
1133 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_ASSERT_FALSE]);
1134 verify([source]);
1135 }
1136
1137 test_constEvalThrowsException_assertInitializer_notBool() async {
1138 resetWith(
1139 options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
1140 Source source = addSource(r'''
1141 class A<T> {
1142 const A(T p) : assert(p);
1143 }
1144 const a = const A(0);
1145 ''');
1146 await computeAnalysisResult(source);
1147 assertErrors(
1148 source, [CompileTimeErrorCode.CONST_EVAL_THROWS_ASSERT_NOT_BOOL]);
1149 verify([source]);
1150 }
1151
1123 test_constEvalThrowsException_binaryMinus_null() async { 1152 test_constEvalThrowsException_binaryMinus_null() async {
1124 await _check_constEvalThrowsException_binary_null("null - 5", false); 1153 await _check_constEvalThrowsException_binary_null("null - 5", false);
1125 await _check_constEvalThrowsException_binary_null("5 - null", true); 1154 await _check_constEvalThrowsException_binary_null("5 - null", true);
1126 } 1155 }
1127 1156
1128 test_constEvalThrowsException_binaryPlus_null() async { 1157 test_constEvalThrowsException_binaryPlus_null() async {
1129 await _check_constEvalThrowsException_binary_null("null + 5", false); 1158 await _check_constEvalThrowsException_binary_null("null + 5", false);
1130 await _check_constEvalThrowsException_binary_null("5 + null", true); 1159 await _check_constEvalThrowsException_binary_null("5 + null", true);
1131 } 1160 }
1132 1161
(...skipping 5481 matching lines...) Expand 10 before | Expand all | Expand 10 after
6614 int _x; 6643 int _x;
6615 } 6644 }
6616 '''); 6645 ''');
6617 Source source = addSource(testCode); 6646 Source source = addSource(testCode);
6618 await computeAnalysisResult(source); 6647 await computeAnalysisResult(source);
6619 assertErrors( 6648 assertErrors(
6620 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]); 6649 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
6621 verify([source]); 6650 verify([source]);
6622 } 6651 }
6623 } 6652 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698