| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.ast_test; | 8 library engine.ast_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | 10 import 'package:analyzer/src/generated/java_core.dart'; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 461 |
| 462 void test_unary_negated_integer() { | 462 void test_unary_negated_integer() { |
| 463 Object value = _getConstantValue("-42"); | 463 Object value = _getConstantValue("-42"); |
| 464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); | 464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); |
| 465 expect(value as int, -42); | 465 expect(value as int, -42); |
| 466 } | 466 } |
| 467 | 467 |
| 468 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour
ce).accept(new ConstantEvaluator()); | 468 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour
ce).accept(new ConstantEvaluator()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 class ConstructorDeclarationTest extends EngineTestCase { |
| 472 void test_firstTokenAfterCommentAndMetadata_externalOnly() { |
| 473 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); |
| 474 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( |
| 475 null, |
| 476 null, |
| 477 AstFactory.identifier3('int'), |
| 478 null, |
| 479 null, |
| 480 null, |
| 481 null); |
| 482 declaration.externalKeyword = externalKeyword; |
| 483 expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword); |
| 484 } |
| 485 |
| 486 void test_firstTokenAfterCommentAndMetadata_constOnly() { |
| 487 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( |
| 488 Keyword.CONST, |
| 489 null, |
| 490 AstFactory.identifier3('int'), |
| 491 null, |
| 492 null, |
| 493 null, |
| 494 null); |
| 495 expect(declaration.firstTokenAfterCommentAndMetadata, declaration.constKeywo
rd); |
| 496 } |
| 497 |
| 498 void test_firstTokenAfterCommentAndMetadata_factoryOnly() { |
| 499 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( |
| 500 null, |
| 501 Keyword.FACTORY, |
| 502 AstFactory.identifier3('int'), |
| 503 null, |
| 504 null, |
| 505 null, |
| 506 null); |
| 507 expect(declaration.firstTokenAfterCommentAndMetadata, declaration.factoryKey
word); |
| 508 } |
| 509 |
| 510 void test_firstTokenAfterCommentAndMetadata_all_inverted() { |
| 511 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); |
| 512 externalKeyword.offset = 14; |
| 513 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( |
| 514 Keyword.CONST, |
| 515 Keyword.FACTORY, |
| 516 AstFactory.identifier3('int'), |
| 517 null, |
| 518 null, |
| 519 null, |
| 520 null); |
| 521 declaration.externalKeyword = externalKeyword; |
| 522 declaration.constKeyword.offset = 8; |
| 523 Token factoryKeyword = declaration.factoryKeyword; |
| 524 factoryKeyword.offset = 0; |
| 525 expect(declaration.firstTokenAfterCommentAndMetadata, factoryKeyword); |
| 526 } |
| 527 |
| 528 void test_firstTokenAfterCommentAndMetadata_all_normal() { |
| 529 Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); |
| 530 token.offset = 0; |
| 531 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( |
| 532 Keyword.CONST, |
| 533 Keyword.FACTORY, |
| 534 AstFactory.identifier3('int'), |
| 535 null, |
| 536 null, |
| 537 null, |
| 538 null); |
| 539 declaration.externalKeyword = token; |
| 540 declaration.constKeyword.offset = 9; |
| 541 declaration.factoryKeyword.offset = 15; |
| 542 expect(declaration.firstTokenAfterCommentAndMetadata, token); |
| 543 } |
| 544 } |
| 545 |
| 471 class IndexExpressionTest extends EngineTestCase { | 546 class IndexExpressionTest extends EngineTestCase { |
| 472 void test_inGetterContext_assignment_compound_left() { | 547 void test_inGetterContext_assignment_compound_left() { |
| 473 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); | 548 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); |
| 474 // a[b] += c | 549 // a[b] += c |
| 475 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id
entifier3("c")); | 550 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id
entifier3("c")); |
| 476 expect(expression.inGetterContext(), isTrue); | 551 expect(expression.inGetterContext(), isTrue); |
| 477 } | 552 } |
| 478 | 553 |
| 479 void test_inGetterContext_assignment_simple_left() { | 554 void test_inGetterContext_assignment_simple_left() { |
| 480 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); | 555 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie
r3("a"), AstFactory.identifier3("b")); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 expect(list[0], same(firstNode)); | 697 expect(list[0], same(firstNode)); |
| 623 expect(list[1], same(secondNode)); | 698 expect(list[1], same(secondNode)); |
| 624 expect(list[2], same(thirdNode)); | 699 expect(list[2], same(thirdNode)); |
| 625 expect(list[3], same(fourthNode)); | 700 expect(list[3], same(fourthNode)); |
| 626 expect(firstNode.parent, same(parent)); | 701 expect(firstNode.parent, same(parent)); |
| 627 expect(secondNode.parent, same(parent)); | 702 expect(secondNode.parent, same(parent)); |
| 628 expect(thirdNode.parent, same(parent)); | 703 expect(thirdNode.parent, same(parent)); |
| 629 expect(fourthNode.parent, same(parent)); | 704 expect(fourthNode.parent, same(parent)); |
| 630 } | 705 } |
| 631 | 706 |
| 632 void test_create() { | |
| 633 AstNode owner = AstFactory.argumentList(); | |
| 634 NodeList<AstNode> list = NodeList.create(owner); | |
| 635 expect(list, isNotNull); | |
| 636 expect(list, hasLength(0)); | |
| 637 expect(list.owner, same(owner)); | |
| 638 } | |
| 639 | |
| 640 void test_creation() { | 707 void test_creation() { |
| 641 AstNode owner = AstFactory.argumentList(); | 708 AstNode owner = AstFactory.argumentList(); |
| 642 NodeList<AstNode> list = new NodeList<AstNode>(owner); | 709 NodeList<AstNode> list = new NodeList<AstNode>(owner); |
| 643 expect(list, isNotNull); | 710 expect(list, isNotNull); |
| 644 expect(list, hasLength(0)); | 711 expect(list, hasLength(0)); |
| 645 expect(list.owner, same(owner)); | 712 expect(list.owner, same(owner)); |
| 646 } | 713 } |
| 647 | 714 |
| 648 void test_get_negative() { | 715 void test_get_negative() { |
| 649 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); | 716 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 PREFIXED_RIGHT, | 2705 PREFIXED_RIGHT, |
| 2639 PROPERTY_LEFT, | 2706 PROPERTY_LEFT, |
| 2640 PROPERTY_RIGHT, | 2707 PROPERTY_RIGHT, |
| 2641 NONE]; | 2708 NONE]; |
| 2642 | 2709 |
| 2643 const WrapperKind(String name, int ordinal) : super(name, ordinal); | 2710 const WrapperKind(String name, int ordinal) : super(name, ordinal); |
| 2644 } | 2711 } |
| 2645 | 2712 |
| 2646 main() { | 2713 main() { |
| 2647 groupSep = ' | '; | 2714 groupSep = ' | '; |
| 2648 runReflectiveTests(ConstantEvaluatorTest); | |
| 2649 runReflectiveTests(NodeLocatorTest); | |
| 2650 runReflectiveTests(ToSourceVisitorTest); | |
| 2651 runReflectiveTests(BreadthFirstVisitorTest); | 2715 runReflectiveTests(BreadthFirstVisitorTest); |
| 2652 runReflectiveTests(ClassDeclarationTest); | 2716 runReflectiveTests(ClassDeclarationTest); |
| 2653 runReflectiveTests(ClassTypeAliasTest); | 2717 runReflectiveTests(ClassTypeAliasTest); |
| 2718 runReflectiveTests(ConstantEvaluatorTest); |
| 2719 runReflectiveTests(ConstructorDeclarationTest); |
| 2654 runReflectiveTests(IndexExpressionTest); | 2720 runReflectiveTests(IndexExpressionTest); |
| 2655 runReflectiveTests(NodeListTest); | 2721 runReflectiveTests(NodeListTest); |
| 2722 runReflectiveTests(NodeLocatorTest); |
| 2656 runReflectiveTests(SimpleIdentifierTest); | 2723 runReflectiveTests(SimpleIdentifierTest); |
| 2657 runReflectiveTests(SimpleStringLiteralTest); | 2724 runReflectiveTests(SimpleStringLiteralTest); |
| 2658 runReflectiveTests(StringInterpolationTest); | 2725 runReflectiveTests(StringInterpolationTest); |
| 2726 runReflectiveTests(ToSourceVisitorTest); |
| 2659 runReflectiveTests(VariableDeclarationTest); | 2727 runReflectiveTests(VariableDeclarationTest); |
| 2660 } | 2728 } |
| OLD | NEW |