OLD | NEW |
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 import 'package:analysis_server/protocol/protocol_generated.dart'; | 5 import 'package:analysis_server/protocol/protocol_generated.dart'; |
6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
9 | 9 |
10 import '../support/integration_tests.dart'; | 10 import '../support/integration_tests.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 defineReflectiveSuite(() { | 13 defineReflectiveSuite(() { |
14 defineReflectiveTests(AnalysisErrorIntegrationTest); | 14 defineReflectiveTests(AnalysisErrorIntegrationTest); |
15 }); | 15 }); |
16 } | 16 } |
17 | 17 |
18 @reflectiveTest | 18 @reflectiveTest |
19 class AnalysisErrorIntegrationTest | 19 class AnalysisErrorIntegrationTest |
20 extends AbstractAnalysisServerIntegrationTest { | 20 extends AbstractAnalysisServerIntegrationTest { |
21 test_detect_simple_error() { | 21 test_detect_simple_error() { |
22 String pathname = sourcePath('test.dart'); | 22 String pathname = sourcePath('test.dart'); |
23 writeFile( | 23 writeFile(pathname, ''' |
24 pathname, | |
25 ''' | |
26 main() { | 24 main() { |
27 print(null) // parse error: missing ';' | 25 print(null) // parse error: missing ';' |
28 }'''); | 26 }'''); |
29 standardAnalysisSetup(); | 27 standardAnalysisSetup(); |
30 return analysisFinished.then((_) { | 28 return analysisFinished.then((_) { |
31 expect(currentAnalysisErrors[pathname], isList); | 29 expect(currentAnalysisErrors[pathname], isList); |
32 List<AnalysisError> errors = currentAnalysisErrors[pathname]; | 30 List<AnalysisError> errors = currentAnalysisErrors[pathname]; |
33 expect(errors, hasLength(1)); | 31 expect(errors, hasLength(1)); |
34 expect(errors[0].location.file, equals(pathname)); | 32 expect(errors[0].location.file, equals(pathname)); |
35 }); | 33 }); |
36 } | 34 } |
37 | 35 |
38 test_super_mixins_disabled() async { | 36 test_super_mixins_disabled() async { |
39 String pathname = sourcePath('test.dart'); | 37 String pathname = sourcePath('test.dart'); |
40 writeFile( | 38 writeFile(pathname, ''' |
41 pathname, | |
42 ''' | |
43 class Test extends Object with C { | 39 class Test extends Object with C { |
44 void foo() {} | 40 void foo() {} |
45 } | 41 } |
46 abstract class B { | 42 abstract class B { |
47 void foo() {} | 43 void foo() {} |
48 } | 44 } |
49 abstract class C extends B { | 45 abstract class C extends B { |
50 void bar() { | 46 void bar() { |
51 super.foo(); | 47 super.foo(); |
52 } | 48 } |
(...skipping 19 matching lines...) Expand all Loading... |
72 @failingTest | 68 @failingTest |
73 test_super_mixins_enabled() async { | 69 test_super_mixins_enabled() async { |
74 // We see errors here with the new driver (#28870). | 70 // We see errors here with the new driver (#28870). |
75 // Expected: empty | 71 // Expected: empty |
76 // Actual: [ | 72 // Actual: [ |
77 // AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","locatio
n":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQ
b/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"T
he class 'C' can't be used as a mixin because it extends a class other than Obje
ct.","correction":"","code":"mixin_inherits_from_not_object","hasFix":false}, | 73 // AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","locatio
n":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQ
b/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"T
he class 'C' can't be used as a mixin because it extends a class other than Obje
ct.","correction":"","code":"mixin_inherits_from_not_object","hasFix":false}, |
78 // AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","locatio
n":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQ
b/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"T
he class 'C' can't be used as a mixin because it references 'super'.","correctio
n":"","code":"mixin_references_super","hasFix":false} | 74 // AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","locatio
n":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQ
b/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"T
he class 'C' can't be used as a mixin because it references 'super'.","correctio
n":"","code":"mixin_references_super","hasFix":false} |
79 // ] | 75 // ] |
80 | 76 |
81 String pathname = sourcePath('test.dart'); | 77 String pathname = sourcePath('test.dart'); |
82 writeFile( | 78 writeFile(pathname, ''' |
83 pathname, | |
84 ''' | |
85 class Test extends Object with C { | 79 class Test extends Object with C { |
86 void foo() {} | 80 void foo() {} |
87 } | 81 } |
88 abstract class B { | 82 abstract class B { |
89 void foo() {} | 83 void foo() {} |
90 } | 84 } |
91 abstract class C extends B { | 85 abstract class C extends B { |
92 void bar() { | 86 void bar() { |
93 super.foo(); | 87 super.foo(); |
94 } | 88 } |
95 } | 89 } |
96 '''); | 90 '''); |
97 // ignore: deprecated_member_use | 91 // ignore: deprecated_member_use |
98 await sendAnalysisUpdateOptions( | 92 await sendAnalysisUpdateOptions( |
99 new AnalysisOptions()..enableSuperMixins = true); | 93 new AnalysisOptions()..enableSuperMixins = true); |
100 standardAnalysisSetup(); | 94 standardAnalysisSetup(); |
101 await analysisFinished; | 95 await analysisFinished; |
102 expect(currentAnalysisErrors[pathname], isList); | 96 expect(currentAnalysisErrors[pathname], isList); |
103 List<AnalysisError> errors = currentAnalysisErrors[pathname]; | 97 List<AnalysisError> errors = currentAnalysisErrors[pathname]; |
104 expect(errors, isEmpty); | 98 expect(errors, isEmpty); |
105 } | 99 } |
106 } | 100 } |
OLD | NEW |