| 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 analyzer.test.dart.ast.ast_test; | 5 library analyzer.test.dart.ast.ast_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/src/dart/ast/token.dart'; | 9 import 'package:analyzer/src/dart/ast/token.dart'; |
| 10 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 10 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 11 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 11 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 12 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
| 13 | 13 |
| 14 import '../../generated/parser_test.dart' show ParserTestCase; | 14 import '../../generated/parser_test.dart' show ParserTestCase; |
| 15 import '../../generated/test_support.dart'; | 15 import '../../generated/test_support.dart'; |
| 16 import '../../reflective_tests.dart'; | 16 import '../../reflective_tests.dart'; |
| 17 import '../../utils.dart'; | 17 import '../../utils.dart'; |
| 18 | 18 |
| 19 main() { | 19 main() { |
| 20 initializeTestEnvironment(); | 20 initializeTestEnvironment(); |
| 21 runReflectiveTests(ClassDeclarationTest); | 21 runReflectiveTests(ClassDeclarationTest); |
| 22 runReflectiveTests(ClassTypeAliasTest); | 22 runReflectiveTests(ClassTypeAliasTest); |
| 23 runReflectiveTests(ConstructorDeclarationTest); | 23 runReflectiveTests(ConstructorDeclarationTest); |
| 24 runReflectiveTests(FieldFormalParameterTest); | 24 runReflectiveTests(FieldFormalParameterTest); |
| 25 runReflectiveTests(IndexExpressionTest); | 25 runReflectiveTests(IndexExpressionTest); |
| 26 runReflectiveTests(MethodDeclarationTest); |
| 26 runReflectiveTests(NodeListTest); | 27 runReflectiveTests(NodeListTest); |
| 27 runReflectiveTests(SimpleIdentifierTest); | 28 runReflectiveTests(SimpleIdentifierTest); |
| 28 runReflectiveTests(SimpleStringLiteralTest); | 29 runReflectiveTests(SimpleStringLiteralTest); |
| 29 runReflectiveTests(StringInterpolationTest); | 30 runReflectiveTests(StringInterpolationTest); |
| 30 runReflectiveTests(VariableDeclarationTest); | 31 runReflectiveTests(VariableDeclarationTest); |
| 31 } | 32 } |
| 32 | 33 |
| 33 @reflectiveTest | 34 @reflectiveTest |
| 34 class ClassDeclarationTest extends ParserTestCase { | 35 class ClassDeclarationTest extends ParserTestCase { |
| 35 void test_getConstructor() { | 36 void test_getConstructor() { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 void test_inSetterContext_prefix_plusPlus() { | 299 void test_inSetterContext_prefix_plusPlus() { |
| 299 IndexExpression expression = AstFactory.indexExpression( | 300 IndexExpression expression = AstFactory.indexExpression( |
| 300 AstFactory.identifier3("a"), AstFactory.identifier3("b")); | 301 AstFactory.identifier3("a"), AstFactory.identifier3("b")); |
| 301 // ++a[b] | 302 // ++a[b] |
| 302 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); | 303 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); |
| 303 expect(expression.inSetterContext(), isTrue); | 304 expect(expression.inSetterContext(), isTrue); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 | 307 |
| 307 @reflectiveTest | 308 @reflectiveTest |
| 309 class MethodDeclarationTest extends EngineTestCase { |
| 310 void test_firstTokenAfterCommentAndMetadata_external() { |
| 311 MethodDeclaration declaration = |
| 312 AstFactory.methodDeclaration4(external: true, name: 'm'); |
| 313 expect(declaration.firstTokenAfterCommentAndMetadata, |
| 314 declaration.externalKeyword); |
| 315 } |
| 316 |
| 317 void test_firstTokenAfterCommentAndMetadata_external_getter() { |
| 318 MethodDeclaration declaration = AstFactory.methodDeclaration4( |
| 319 external: true, property: Keyword.GET, name: 'm'); |
| 320 expect(declaration.firstTokenAfterCommentAndMetadata, |
| 321 declaration.externalKeyword); |
| 322 } |
| 323 |
| 324 void test_firstTokenAfterCommentAndMetadata_external_operator() { |
| 325 MethodDeclaration declaration = AstFactory.methodDeclaration4( |
| 326 external: true, operator: true, name: 'm'); |
| 327 expect(declaration.firstTokenAfterCommentAndMetadata, |
| 328 declaration.externalKeyword); |
| 329 } |
| 330 |
| 331 void test_firstTokenAfterCommentAndMetadata_getter() { |
| 332 MethodDeclaration declaration = |
| 333 AstFactory.methodDeclaration4(property: Keyword.GET, name: 'm'); |
| 334 expect(declaration.firstTokenAfterCommentAndMetadata, |
| 335 declaration.propertyKeyword); |
| 336 } |
| 337 |
| 338 void test_firstTokenAfterCommentAndMetadata_operator() { |
| 339 MethodDeclaration declaration = |
| 340 AstFactory.methodDeclaration4(operator: true, name: 'm'); |
| 341 expect(declaration.firstTokenAfterCommentAndMetadata, |
| 342 declaration.operatorKeyword); |
| 343 } |
| 344 } |
| 345 |
| 346 @reflectiveTest |
| 308 class NodeListTest extends EngineTestCase { | 347 class NodeListTest extends EngineTestCase { |
| 309 void test_add() { | 348 void test_add() { |
| 310 AstNode parent = AstFactory.argumentList(); | 349 AstNode parent = AstFactory.argumentList(); |
| 311 AstNode firstNode = AstFactory.booleanLiteral(true); | 350 AstNode firstNode = AstFactory.booleanLiteral(true); |
| 312 AstNode secondNode = AstFactory.booleanLiteral(false); | 351 AstNode secondNode = AstFactory.booleanLiteral(false); |
| 313 NodeList<AstNode> list = new NodeList<AstNode>(parent); | 352 NodeList<AstNode> list = new NodeList<AstNode>(parent); |
| 314 list.insert(0, secondNode); | 353 list.insert(0, secondNode); |
| 315 list.insert(0, firstNode); | 354 list.insert(0, firstNode); |
| 316 expect(list, hasLength(2)); | 355 expect(list, hasLength(2)); |
| 317 expect(list[0], same(firstNode)); | 356 expect(list[0], same(firstNode)); |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 final int ordinal; | 1338 final int ordinal; |
| 1300 | 1339 |
| 1301 const _WrapperKind(this.name, this.ordinal); | 1340 const _WrapperKind(this.name, this.ordinal); |
| 1302 | 1341 |
| 1303 int get hashCode => ordinal; | 1342 int get hashCode => ordinal; |
| 1304 | 1343 |
| 1305 int compareTo(_WrapperKind other) => ordinal - other.ordinal; | 1344 int compareTo(_WrapperKind other) => ordinal - other.ordinal; |
| 1306 | 1345 |
| 1307 String toString() => name; | 1346 String toString() => name; |
| 1308 } | 1347 } |
| OLD | NEW |