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

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

Issue 1418973002: Error reporting for spans. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 engine.all_the_rest_test; 5 library engine.all_the_rest_test;
6 6
7 import 'package:analyzer/file_system/physical_file_system.dart'; 7 import 'package:analyzer/file_system/physical_file_system.dart';
8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 13 matching lines...) Expand all
24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 24 import 'package:analyzer/src/generated/testing/ast_factory.dart';
25 import 'package:analyzer/src/generated/testing/element_factory.dart'; 25 import 'package:analyzer/src/generated/testing/element_factory.dart';
26 import 'package:analyzer/src/generated/testing/html_factory.dart'; 26 import 'package:analyzer/src/generated/testing/html_factory.dart';
27 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 27 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
28 import 'package:analyzer/src/generated/testing/token_factory.dart'; 28 import 'package:analyzer/src/generated/testing/token_factory.dart';
29 import 'package:analyzer/src/generated/utilities_collection.dart'; 29 import 'package:analyzer/src/generated/utilities_collection.dart';
30 import 'package:analyzer/src/generated/utilities_dart.dart'; 30 import 'package:analyzer/src/generated/utilities_dart.dart';
31 import 'package:analyzer/src/task/dart.dart'; 31 import 'package:analyzer/src/task/dart.dart';
32 import 'package:path/path.dart'; 32 import 'package:path/path.dart';
33 import 'package:unittest/unittest.dart'; 33 import 'package:unittest/unittest.dart';
34 import 'package:yaml/yaml.dart';
34 35
35 import '../reflective_tests.dart'; 36 import '../reflective_tests.dart';
36 import '../utils.dart'; 37 import '../utils.dart';
37 import 'engine_test.dart'; 38 import 'engine_test.dart';
38 import 'parser_test.dart'; 39 import 'parser_test.dart';
39 import 'resolver_test.dart'; 40 import 'resolver_test.dart';
40 import 'test_support.dart'; 41 import 'test_support.dart';
41 42
42 main() { 43 main() {
43 initializeTestEnvironment(); 44 initializeTestEnvironment();
(...skipping 7248 matching lines...) Expand 10 before | Expand all | Expand 10 after
7292 * @param typeName the name of the type to be created 7293 * @param typeName the name of the type to be created
7293 * @return the type that was created 7294 * @return the type that was created
7294 */ 7295 */
7295 InterfaceType createType(String fileName, String typeName) { 7296 InterfaceType createType(String fileName, String typeName) {
7296 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName); 7297 CompilationUnitElementImpl unit = ElementFactory.compilationUnit(fileName);
7297 ClassElementImpl element = ElementFactory.classElement2(typeName); 7298 ClassElementImpl element = ElementFactory.classElement2(typeName);
7298 unit.types = <ClassElement>[element]; 7299 unit.types = <ClassElement>[element];
7299 return element.type; 7300 return element.type;
7300 } 7301 }
7301 7302
7303 void test_reportErrorForSpan() {
7304 GatheringErrorListener listener = new GatheringErrorListener();
7305 ErrorReporter reporter = new ErrorReporter(
7306 listener,
7307 new NonExistingSource(
Brian Wilkerson 2015/10/22 00:13:00 It's not a problem for this test because you're no
7308 '/test.yaml', toUri('/test.yaml'), UriKind.FILE_URI));
7309
7310 var src = '''
7311 foo: bar
7312 zap: baz
7313 ''';
7314
7315 YamlMap node = loadYamlNode(src);
7316 YamlNode bazNode = node.nodes['zap'];
scheglov 2015/10/21 23:47:21 I think YAML adds extra complexity here. Why not c
pquitslund 2015/10/21 23:56:57 Mainly because I want to ensure that the spans tha
Brian Wilkerson 2015/10/22 00:13:00 Technically, testing whether the yaml parser produ
7317 reporter.reportErrorForSpan(AnalysisOptionsWarningCode.UNSUPPORTED_OPTION,
7318 bazNode.span, ['test', 'zap']);
7319 expect(listener.errors, hasLength(1));
7320 expect(listener.errors.first.offset, src.indexOf('baz'));
7321 expect(listener.errors.first.length, 'baz'.length);
7322 }
7323
7302 void test_creation() { 7324 void test_creation() {
7303 GatheringErrorListener listener = new GatheringErrorListener(); 7325 GatheringErrorListener listener = new GatheringErrorListener();
7304 TestSource source = new TestSource(); 7326 TestSource source = new TestSource();
7305 expect(new ErrorReporter(listener, source), isNotNull); 7327 expect(new ErrorReporter(listener, source), isNotNull);
7306 } 7328 }
7307 7329
7308 void test_reportErrorForElement_named() { 7330 void test_reportErrorForElement_named() {
7309 DartType type = createType("/test1.dart", "A"); 7331 DartType type = createType("/test1.dart", "A");
7310 ClassElement element = type.element; 7332 ClassElement element = type.element;
7311 GatheringErrorListener listener = new GatheringErrorListener(); 7333 GatheringErrorListener listener = new GatheringErrorListener();
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after
9391 if (_expectedExternalScriptName == null) { 9413 if (_expectedExternalScriptName == null) {
9392 expect(scriptSource, isNull, reason: "script $scriptIndex"); 9414 expect(scriptSource, isNull, reason: "script $scriptIndex");
9393 } else { 9415 } else {
9394 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9416 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9395 String actualExternalScriptName = scriptSource.shortName; 9417 String actualExternalScriptName = scriptSource.shortName;
9396 expect(actualExternalScriptName, _expectedExternalScriptName, 9418 expect(actualExternalScriptName, _expectedExternalScriptName,
9397 reason: "script $scriptIndex"); 9419 reason: "script $scriptIndex");
9398 } 9420 }
9399 } 9421 }
9400 } 9422 }
OLDNEW
« pkg/analyzer/lib/src/generated/error.dart ('K') | « pkg/analyzer/lib/src/generated/error.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698