| 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 library test.computer.element; | 5 library test.computer.element; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/protocol_server.dart'; | 10 import 'package:analysis_server/src/protocol_server.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 runReflectiveTests(ElementKindTest); | 29 runReflectiveTests(ElementKindTest); |
| 30 runReflectiveTests(EnumTest); | 30 runReflectiveTests(EnumTest); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 class AnalysisErrorMock extends TypedMock implements engine.AnalysisError { | 34 class AnalysisErrorMock extends TypedMock implements engine.AnalysisError { |
| 35 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 35 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 36 } | 36 } |
| 37 | 37 |
| 38 | 38 |
| 39 @ReflectiveTestCase() | 39 @reflectiveTest |
| 40 class AnalysisErrorTest { | 40 class AnalysisErrorTest { |
| 41 engine.Source source = new MockSource(); | 41 engine.Source source = new MockSource(); |
| 42 engine.LineInfo lineInfo; | 42 engine.LineInfo lineInfo; |
| 43 engine.AnalysisError engineError = new AnalysisErrorMock(); | 43 engine.AnalysisError engineError = new AnalysisErrorMock(); |
| 44 | 44 |
| 45 void setUp() { | 45 void setUp() { |
| 46 // prepare Source | 46 // prepare Source |
| 47 when(source.fullName).thenReturn('foo.dart'); | 47 when(source.fullName).thenReturn('foo.dart'); |
| 48 // prepare LineInfo | 48 // prepare LineInfo |
| 49 lineInfo = new engine.LineInfo([0, 5, 9, 20]); | 49 lineInfo = new engine.LineInfo([0, 5, 9, 20]); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 LENGTH: 20, | 108 LENGTH: 20, |
| 109 START_LINE: -1, | 109 START_LINE: -1, |
| 110 START_COLUMN: -1 | 110 START_COLUMN: -1 |
| 111 }, | 111 }, |
| 112 MESSAGE: 'my message' | 112 MESSAGE: 'my message' |
| 113 }); | 113 }); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 @ReflectiveTestCase() | 118 @reflectiveTest |
| 119 class ElementKindTest { | 119 class ElementKindTest { |
| 120 void test_fromEngine() { | 120 void test_fromEngine() { |
| 121 expect( | 121 expect( |
| 122 newElementKind_fromEngine(engine.ElementKind.CLASS), | 122 newElementKind_fromEngine(engine.ElementKind.CLASS), |
| 123 ElementKind.CLASS); | 123 ElementKind.CLASS); |
| 124 expect( | 124 expect( |
| 125 newElementKind_fromEngine(engine.ElementKind.COMPILATION_UNIT), | 125 newElementKind_fromEngine(engine.ElementKind.COMPILATION_UNIT), |
| 126 ElementKind.COMPILATION_UNIT); | 126 ElementKind.COMPILATION_UNIT); |
| 127 expect( | 127 expect( |
| 128 newElementKind_fromEngine(engine.ElementKind.CONSTRUCTOR), | 128 newElementKind_fromEngine(engine.ElementKind.CONSTRUCTOR), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 void test_toString() { | 210 void test_toString() { |
| 211 expect(ElementKind.CLASS.toString(), 'ElementKind.CLASS'); | 211 expect(ElementKind.CLASS.toString(), 'ElementKind.CLASS'); |
| 212 expect( | 212 expect( |
| 213 ElementKind.COMPILATION_UNIT.toString(), | 213 ElementKind.COMPILATION_UNIT.toString(), |
| 214 'ElementKind.COMPILATION_UNIT'); | 214 'ElementKind.COMPILATION_UNIT'); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 @ReflectiveTestCase() | 219 @reflectiveTest |
| 220 class ElementTest extends AbstractContextTest { | 220 class ElementTest extends AbstractContextTest { |
| 221 engine.Element findElementInUnit(engine.CompilationUnit unit, String name, | 221 engine.Element findElementInUnit(engine.CompilationUnit unit, String name, |
| 222 [engine.ElementKind kind]) { | 222 [engine.ElementKind kind]) { |
| 223 return findChildElement(unit.element, name, kind); | 223 return findChildElement(unit.element, name, kind); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void test_fromElement_CLASS() { | 226 void test_fromElement_CLASS() { |
| 227 engine.Source source = addSource('/test.dart', ''' | 227 engine.Source source = addSource('/test.dart', ''' |
| 228 @deprecated | 228 @deprecated |
| 229 abstract class _MyClass {}'''); | 229 abstract class _MyClass {}'''); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 expect(location.length, 'mySetter'.length); | 406 expect(location.length, 'mySetter'.length); |
| 407 expect(location.startLine, 2); | 407 expect(location.startLine, 2); |
| 408 expect(location.startColumn, 7); | 408 expect(location.startColumn, 7); |
| 409 } | 409 } |
| 410 expect(element.parameters, '(String x)'); | 410 expect(element.parameters, '(String x)'); |
| 411 expect(element.returnType, isNull); | 411 expect(element.returnType, isNull); |
| 412 expect(element.flags, 0); | 412 expect(element.flags, 0); |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 @ReflectiveTestCase() | 416 @reflectiveTest |
| 417 class EnumTest { | 417 class EnumTest { |
| 418 void test_AnalysisErrorSeverity() { | 418 void test_AnalysisErrorSeverity() { |
| 419 new EnumTester<engine.ErrorSeverity, AnalysisErrorSeverity>().run( | 419 new EnumTester<engine.ErrorSeverity, AnalysisErrorSeverity>().run( |
| 420 (engine.ErrorSeverity engineErrorSeverity) => | 420 (engine.ErrorSeverity engineErrorSeverity) => |
| 421 new AnalysisErrorSeverity(engineErrorSeverity.name), | 421 new AnalysisErrorSeverity(engineErrorSeverity.name), |
| 422 exceptions: { | 422 exceptions: { |
| 423 engine.ErrorSeverity.NONE: null | 423 engine.ErrorSeverity.NONE: null |
| 424 }); | 424 }); |
| 425 } | 425 } |
| 426 | 426 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 ApiEnum apiValue = convert(engineValue); | 492 ApiEnum apiValue = convert(engineValue); |
| 493 expect(apiValue, equals(expectedResult)); | 493 expect(apiValue, equals(expectedResult)); |
| 494 } | 494 } |
| 495 } else { | 495 } else { |
| 496 ApiEnum apiValue = convert(engineValue); | 496 ApiEnum apiValue = convert(engineValue); |
| 497 expect(apiValue.name, equals(enumName)); | 497 expect(apiValue.name, equals(enumName)); |
| 498 } | 498 } |
| 499 }); | 499 }); |
| 500 } | 500 } |
| 501 } | 501 } |
| OLD | NEW |