| 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/standard_ast_factory.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
| 10 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 11 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
| 11 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 12 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 12 import 'package:test/test.dart'; | 13 import 'package:test/test.dart'; |
| 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 14 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 14 | 15 |
| 15 import '../../generated/parser_test.dart' show ParserTestCase; | 16 import '../../generated/parser_test.dart' show ParserTestCase; |
| 16 import '../../generated/test_support.dart'; | 17 import '../../generated/test_support.dart'; |
| 17 | 18 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 declaration.operatorKeyword); | 359 declaration.operatorKeyword); |
| 359 } | 360 } |
| 360 } | 361 } |
| 361 | 362 |
| 362 @reflectiveTest | 363 @reflectiveTest |
| 363 class NodeListTest extends EngineTestCase { | 364 class NodeListTest extends EngineTestCase { |
| 364 void test_add() { | 365 void test_add() { |
| 365 AstNode parent = AstTestFactory.argumentList(); | 366 AstNode parent = AstTestFactory.argumentList(); |
| 366 AstNode firstNode = AstTestFactory.booleanLiteral(true); | 367 AstNode firstNode = AstTestFactory.booleanLiteral(true); |
| 367 AstNode secondNode = AstTestFactory.booleanLiteral(false); | 368 AstNode secondNode = AstTestFactory.booleanLiteral(false); |
| 368 NodeList<AstNode> list = new NodeList<AstNode>(parent); | 369 NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(parent); |
| 369 list.insert(0, secondNode); | 370 list.insert(0, secondNode); |
| 370 list.insert(0, firstNode); | 371 list.insert(0, firstNode); |
| 371 expect(list, hasLength(2)); | 372 expect(list, hasLength(2)); |
| 372 expect(list[0], same(firstNode)); | 373 expect(list[0], same(firstNode)); |
| 373 expect(list[1], same(secondNode)); | 374 expect(list[1], same(secondNode)); |
| 374 expect(firstNode.parent, same(parent)); | 375 expect(firstNode.parent, same(parent)); |
| 375 expect(secondNode.parent, same(parent)); | 376 expect(secondNode.parent, same(parent)); |
| 376 AstNode thirdNode = AstTestFactory.booleanLiteral(false); | 377 AstNode thirdNode = AstTestFactory.booleanLiteral(false); |
| 377 list.insert(1, thirdNode); | 378 list.insert(1, thirdNode); |
| 378 expect(list, hasLength(3)); | 379 expect(list, hasLength(3)); |
| 379 expect(list[0], same(firstNode)); | 380 expect(list[0], same(firstNode)); |
| 380 expect(list[1], same(thirdNode)); | 381 expect(list[1], same(thirdNode)); |
| 381 expect(list[2], same(secondNode)); | 382 expect(list[2], same(secondNode)); |
| 382 expect(firstNode.parent, same(parent)); | 383 expect(firstNode.parent, same(parent)); |
| 383 expect(secondNode.parent, same(parent)); | 384 expect(secondNode.parent, same(parent)); |
| 384 expect(thirdNode.parent, same(parent)); | 385 expect(thirdNode.parent, same(parent)); |
| 385 } | 386 } |
| 386 | 387 |
| 387 void test_add_negative() { | 388 void test_add_negative() { |
| 388 NodeList<AstNode> list = | 389 NodeList<AstNode> list = |
| 389 new NodeList<AstNode>(AstTestFactory.argumentList()); | 390 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 390 try { | 391 try { |
| 391 list.insert(-1, AstTestFactory.booleanLiteral(true)); | 392 list.insert(-1, AstTestFactory.booleanLiteral(true)); |
| 392 fail("Expected IndexOutOfBoundsException"); | 393 fail("Expected IndexOutOfBoundsException"); |
| 393 } on RangeError { | 394 } on RangeError { |
| 394 // Expected | 395 // Expected |
| 395 } | 396 } |
| 396 } | 397 } |
| 397 | 398 |
| 398 void test_add_tooBig() { | 399 void test_add_tooBig() { |
| 399 NodeList<AstNode> list = | 400 NodeList<AstNode> list = |
| 400 new NodeList<AstNode>(AstTestFactory.argumentList()); | 401 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 401 try { | 402 try { |
| 402 list.insert(1, AstTestFactory.booleanLiteral(true)); | 403 list.insert(1, AstTestFactory.booleanLiteral(true)); |
| 403 fail("Expected IndexOutOfBoundsException"); | 404 fail("Expected IndexOutOfBoundsException"); |
| 404 } on RangeError { | 405 } on RangeError { |
| 405 // Expected | 406 // Expected |
| 406 } | 407 } |
| 407 } | 408 } |
| 408 | 409 |
| 409 void test_addAll() { | 410 void test_addAll() { |
| 410 AstNode parent = AstTestFactory.argumentList(); | 411 AstNode parent = AstTestFactory.argumentList(); |
| 411 List<AstNode> firstNodes = new List<AstNode>(); | 412 List<AstNode> firstNodes = new List<AstNode>(); |
| 412 AstNode firstNode = AstTestFactory.booleanLiteral(true); | 413 AstNode firstNode = AstTestFactory.booleanLiteral(true); |
| 413 AstNode secondNode = AstTestFactory.booleanLiteral(false); | 414 AstNode secondNode = AstTestFactory.booleanLiteral(false); |
| 414 firstNodes.add(firstNode); | 415 firstNodes.add(firstNode); |
| 415 firstNodes.add(secondNode); | 416 firstNodes.add(secondNode); |
| 416 NodeList<AstNode> list = new NodeList<AstNode>(parent); | 417 NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(parent); |
| 417 list.addAll(firstNodes); | 418 list.addAll(firstNodes); |
| 418 expect(list, hasLength(2)); | 419 expect(list, hasLength(2)); |
| 419 expect(list[0], same(firstNode)); | 420 expect(list[0], same(firstNode)); |
| 420 expect(list[1], same(secondNode)); | 421 expect(list[1], same(secondNode)); |
| 421 expect(firstNode.parent, same(parent)); | 422 expect(firstNode.parent, same(parent)); |
| 422 expect(secondNode.parent, same(parent)); | 423 expect(secondNode.parent, same(parent)); |
| 423 List<AstNode> secondNodes = new List<AstNode>(); | 424 List<AstNode> secondNodes = new List<AstNode>(); |
| 424 AstNode thirdNode = AstTestFactory.booleanLiteral(true); | 425 AstNode thirdNode = AstTestFactory.booleanLiteral(true); |
| 425 AstNode fourthNode = AstTestFactory.booleanLiteral(false); | 426 AstNode fourthNode = AstTestFactory.booleanLiteral(false); |
| 426 secondNodes.add(thirdNode); | 427 secondNodes.add(thirdNode); |
| 427 secondNodes.add(fourthNode); | 428 secondNodes.add(fourthNode); |
| 428 list.addAll(secondNodes); | 429 list.addAll(secondNodes); |
| 429 expect(list, hasLength(4)); | 430 expect(list, hasLength(4)); |
| 430 expect(list[0], same(firstNode)); | 431 expect(list[0], same(firstNode)); |
| 431 expect(list[1], same(secondNode)); | 432 expect(list[1], same(secondNode)); |
| 432 expect(list[2], same(thirdNode)); | 433 expect(list[2], same(thirdNode)); |
| 433 expect(list[3], same(fourthNode)); | 434 expect(list[3], same(fourthNode)); |
| 434 expect(firstNode.parent, same(parent)); | 435 expect(firstNode.parent, same(parent)); |
| 435 expect(secondNode.parent, same(parent)); | 436 expect(secondNode.parent, same(parent)); |
| 436 expect(thirdNode.parent, same(parent)); | 437 expect(thirdNode.parent, same(parent)); |
| 437 expect(fourthNode.parent, same(parent)); | 438 expect(fourthNode.parent, same(parent)); |
| 438 } | 439 } |
| 439 | 440 |
| 440 void test_creation() { | 441 void test_creation() { |
| 441 AstNode owner = AstTestFactory.argumentList(); | 442 AstNode owner = AstTestFactory.argumentList(); |
| 442 NodeList<AstNode> list = new NodeList<AstNode>(owner); | 443 NodeList<AstNode> list = astFactory.nodeList/*<AstNode>*/(owner); |
| 443 expect(list, isNotNull); | 444 expect(list, isNotNull); |
| 444 expect(list, hasLength(0)); | 445 expect(list, hasLength(0)); |
| 445 expect(list.owner, same(owner)); | 446 expect(list.owner, same(owner)); |
| 446 } | 447 } |
| 447 | 448 |
| 448 void test_get_negative() { | 449 void test_get_negative() { |
| 449 NodeList<AstNode> list = | 450 NodeList<AstNode> list = |
| 450 new NodeList<AstNode>(AstTestFactory.argumentList()); | 451 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 451 try { | 452 try { |
| 452 list[-1]; | 453 list[-1]; |
| 453 fail("Expected IndexOutOfBoundsException"); | 454 fail("Expected IndexOutOfBoundsException"); |
| 454 } on RangeError { | 455 } on RangeError { |
| 455 // Expected | 456 // Expected |
| 456 } | 457 } |
| 457 } | 458 } |
| 458 | 459 |
| 459 void test_get_tooBig() { | 460 void test_get_tooBig() { |
| 460 NodeList<AstNode> list = | 461 NodeList<AstNode> list = |
| 461 new NodeList<AstNode>(AstTestFactory.argumentList()); | 462 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 462 try { | 463 try { |
| 463 list[1]; | 464 list[1]; |
| 464 fail("Expected IndexOutOfBoundsException"); | 465 fail("Expected IndexOutOfBoundsException"); |
| 465 } on RangeError { | 466 } on RangeError { |
| 466 // Expected | 467 // Expected |
| 467 } | 468 } |
| 468 } | 469 } |
| 469 | 470 |
| 470 void test_getBeginToken_empty() { | 471 void test_getBeginToken_empty() { |
| 471 NodeList<AstNode> list = | 472 NodeList<AstNode> list = |
| 472 new NodeList<AstNode>(AstTestFactory.argumentList()); | 473 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 473 expect(list.beginToken, isNull); | 474 expect(list.beginToken, isNull); |
| 474 } | 475 } |
| 475 | 476 |
| 476 void test_getBeginToken_nonEmpty() { | 477 void test_getBeginToken_nonEmpty() { |
| 477 NodeList<AstNode> list = | 478 NodeList<AstNode> list = |
| 478 new NodeList<AstNode>(AstTestFactory.argumentList()); | 479 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 479 AstNode node = AstTestFactory | 480 AstNode node = AstTestFactory |
| 480 .parenthesizedExpression(AstTestFactory.booleanLiteral(true)); | 481 .parenthesizedExpression(AstTestFactory.booleanLiteral(true)); |
| 481 list.add(node); | 482 list.add(node); |
| 482 expect(list.beginToken, same(node.beginToken)); | 483 expect(list.beginToken, same(node.beginToken)); |
| 483 } | 484 } |
| 484 | 485 |
| 485 void test_getEndToken_empty() { | 486 void test_getEndToken_empty() { |
| 486 NodeList<AstNode> list = | 487 NodeList<AstNode> list = |
| 487 new NodeList<AstNode>(AstTestFactory.argumentList()); | 488 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 488 expect(list.endToken, isNull); | 489 expect(list.endToken, isNull); |
| 489 } | 490 } |
| 490 | 491 |
| 491 void test_getEndToken_nonEmpty() { | 492 void test_getEndToken_nonEmpty() { |
| 492 NodeList<AstNode> list = | 493 NodeList<AstNode> list = |
| 493 new NodeList<AstNode>(AstTestFactory.argumentList()); | 494 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 494 AstNode node = AstTestFactory | 495 AstNode node = AstTestFactory |
| 495 .parenthesizedExpression(AstTestFactory.booleanLiteral(true)); | 496 .parenthesizedExpression(AstTestFactory.booleanLiteral(true)); |
| 496 list.add(node); | 497 list.add(node); |
| 497 expect(list.endToken, same(node.endToken)); | 498 expect(list.endToken, same(node.endToken)); |
| 498 } | 499 } |
| 499 | 500 |
| 500 void test_indexOf() { | 501 void test_indexOf() { |
| 501 List<AstNode> nodes = new List<AstNode>(); | 502 List<AstNode> nodes = new List<AstNode>(); |
| 502 AstNode firstNode = AstTestFactory.booleanLiteral(true); | 503 AstNode firstNode = AstTestFactory.booleanLiteral(true); |
| 503 AstNode secondNode = AstTestFactory.booleanLiteral(false); | 504 AstNode secondNode = AstTestFactory.booleanLiteral(false); |
| 504 AstNode thirdNode = AstTestFactory.booleanLiteral(true); | 505 AstNode thirdNode = AstTestFactory.booleanLiteral(true); |
| 505 AstNode fourthNode = AstTestFactory.booleanLiteral(false); | 506 AstNode fourthNode = AstTestFactory.booleanLiteral(false); |
| 506 nodes.add(firstNode); | 507 nodes.add(firstNode); |
| 507 nodes.add(secondNode); | 508 nodes.add(secondNode); |
| 508 nodes.add(thirdNode); | 509 nodes.add(thirdNode); |
| 509 NodeList<AstNode> list = | 510 NodeList<AstNode> list = |
| 510 new NodeList<AstNode>(AstTestFactory.argumentList()); | 511 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 511 list.addAll(nodes); | 512 list.addAll(nodes); |
| 512 expect(list, hasLength(3)); | 513 expect(list, hasLength(3)); |
| 513 expect(list.indexOf(firstNode), 0); | 514 expect(list.indexOf(firstNode), 0); |
| 514 expect(list.indexOf(secondNode), 1); | 515 expect(list.indexOf(secondNode), 1); |
| 515 expect(list.indexOf(thirdNode), 2); | 516 expect(list.indexOf(thirdNode), 2); |
| 516 expect(list.indexOf(fourthNode), -1); | 517 expect(list.indexOf(fourthNode), -1); |
| 517 expect(list.indexOf(null), -1); | 518 expect(list.indexOf(null), -1); |
| 518 } | 519 } |
| 519 | 520 |
| 520 void test_remove() { | 521 void test_remove() { |
| 521 List<AstNode> nodes = new List<AstNode>(); | 522 List<AstNode> nodes = new List<AstNode>(); |
| 522 AstNode firstNode = AstTestFactory.booleanLiteral(true); | 523 AstNode firstNode = AstTestFactory.booleanLiteral(true); |
| 523 AstNode secondNode = AstTestFactory.booleanLiteral(false); | 524 AstNode secondNode = AstTestFactory.booleanLiteral(false); |
| 524 AstNode thirdNode = AstTestFactory.booleanLiteral(true); | 525 AstNode thirdNode = AstTestFactory.booleanLiteral(true); |
| 525 nodes.add(firstNode); | 526 nodes.add(firstNode); |
| 526 nodes.add(secondNode); | 527 nodes.add(secondNode); |
| 527 nodes.add(thirdNode); | 528 nodes.add(thirdNode); |
| 528 NodeList<AstNode> list = | 529 NodeList<AstNode> list = |
| 529 new NodeList<AstNode>(AstTestFactory.argumentList()); | 530 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 530 list.addAll(nodes); | 531 list.addAll(nodes); |
| 531 expect(list, hasLength(3)); | 532 expect(list, hasLength(3)); |
| 532 expect(list.removeAt(1), same(secondNode)); | 533 expect(list.removeAt(1), same(secondNode)); |
| 533 expect(list, hasLength(2)); | 534 expect(list, hasLength(2)); |
| 534 expect(list[0], same(firstNode)); | 535 expect(list[0], same(firstNode)); |
| 535 expect(list[1], same(thirdNode)); | 536 expect(list[1], same(thirdNode)); |
| 536 } | 537 } |
| 537 | 538 |
| 538 void test_remove_negative() { | 539 void test_remove_negative() { |
| 539 NodeList<AstNode> list = | 540 NodeList<AstNode> list = |
| 540 new NodeList<AstNode>(AstTestFactory.argumentList()); | 541 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 541 try { | 542 try { |
| 542 list.removeAt(-1); | 543 list.removeAt(-1); |
| 543 fail("Expected IndexOutOfBoundsException"); | 544 fail("Expected IndexOutOfBoundsException"); |
| 544 } on RangeError { | 545 } on RangeError { |
| 545 // Expected | 546 // Expected |
| 546 } | 547 } |
| 547 } | 548 } |
| 548 | 549 |
| 549 void test_remove_tooBig() { | 550 void test_remove_tooBig() { |
| 550 NodeList<AstNode> list = | 551 NodeList<AstNode> list = |
| 551 new NodeList<AstNode>(AstTestFactory.argumentList()); | 552 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 552 try { | 553 try { |
| 553 list.removeAt(1); | 554 list.removeAt(1); |
| 554 fail("Expected IndexOutOfBoundsException"); | 555 fail("Expected IndexOutOfBoundsException"); |
| 555 } on RangeError { | 556 } on RangeError { |
| 556 // Expected | 557 // Expected |
| 557 } | 558 } |
| 558 } | 559 } |
| 559 | 560 |
| 560 void test_set() { | 561 void test_set() { |
| 561 List<AstNode> nodes = new List<AstNode>(); | 562 List<AstNode> nodes = new List<AstNode>(); |
| 562 AstNode firstNode = AstTestFactory.booleanLiteral(true); | 563 AstNode firstNode = AstTestFactory.booleanLiteral(true); |
| 563 AstNode secondNode = AstTestFactory.booleanLiteral(false); | 564 AstNode secondNode = AstTestFactory.booleanLiteral(false); |
| 564 AstNode thirdNode = AstTestFactory.booleanLiteral(true); | 565 AstNode thirdNode = AstTestFactory.booleanLiteral(true); |
| 565 nodes.add(firstNode); | 566 nodes.add(firstNode); |
| 566 nodes.add(secondNode); | 567 nodes.add(secondNode); |
| 567 nodes.add(thirdNode); | 568 nodes.add(thirdNode); |
| 568 NodeList<AstNode> list = | 569 NodeList<AstNode> list = |
| 569 new NodeList<AstNode>(AstTestFactory.argumentList()); | 570 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 570 list.addAll(nodes); | 571 list.addAll(nodes); |
| 571 expect(list, hasLength(3)); | 572 expect(list, hasLength(3)); |
| 572 AstNode fourthNode = AstTestFactory.integer(0); | 573 AstNode fourthNode = AstTestFactory.integer(0); |
| 573 list[1] = fourthNode; | 574 list[1] = fourthNode; |
| 574 expect(list, hasLength(3)); | 575 expect(list, hasLength(3)); |
| 575 expect(list[0], same(firstNode)); | 576 expect(list[0], same(firstNode)); |
| 576 expect(list[1], same(fourthNode)); | 577 expect(list[1], same(fourthNode)); |
| 577 expect(list[2], same(thirdNode)); | 578 expect(list[2], same(thirdNode)); |
| 578 } | 579 } |
| 579 | 580 |
| 580 void test_set_negative() { | 581 void test_set_negative() { |
| 581 AstNode node = AstTestFactory.booleanLiteral(true); | 582 AstNode node = AstTestFactory.booleanLiteral(true); |
| 582 NodeList<AstNode> list = | 583 NodeList<AstNode> list = |
| 583 new NodeList<AstNode>(AstTestFactory.argumentList()); | 584 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 584 try { | 585 try { |
| 585 list[-1] = node; | 586 list[-1] = node; |
| 586 fail("Expected IndexOutOfBoundsException"); | 587 fail("Expected IndexOutOfBoundsException"); |
| 587 } on RangeError { | 588 } on RangeError { |
| 588 // Expected | 589 // Expected |
| 589 } | 590 } |
| 590 } | 591 } |
| 591 | 592 |
| 592 void test_set_tooBig() { | 593 void test_set_tooBig() { |
| 593 AstNode node = AstTestFactory.booleanLiteral(true); | 594 AstNode node = AstTestFactory.booleanLiteral(true); |
| 594 NodeList<AstNode> list = | 595 NodeList<AstNode> list = |
| 595 new NodeList<AstNode>(AstTestFactory.argumentList()); | 596 astFactory.nodeList/*<AstNode>*/(AstTestFactory.argumentList()); |
| 596 try { | 597 try { |
| 597 list[1] = node; | 598 list[1] = node; |
| 598 fail("Expected IndexOutOfBoundsException"); | 599 fail("Expected IndexOutOfBoundsException"); |
| 599 } on RangeError { | 600 } on RangeError { |
| 600 // Expected | 601 // Expected |
| 601 } | 602 } |
| 602 } | 603 } |
| 603 } | 604 } |
| 604 | 605 |
| 605 @reflectiveTest | 606 @reflectiveTest |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 parent = parent.parent; | 789 parent = parent.parent; |
| 789 } | 790 } |
| 790 return child; | 791 return child; |
| 791 } | 792 } |
| 792 } | 793 } |
| 793 | 794 |
| 794 @reflectiveTest | 795 @reflectiveTest |
| 795 class SimpleStringLiteralTest extends ParserTestCase { | 796 class SimpleStringLiteralTest extends ParserTestCase { |
| 796 void test_contentsEnd() { | 797 void test_contentsEnd() { |
| 797 expect( | 798 expect( |
| 798 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") | 799 astFactory |
| 800 .simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") |
| 799 .contentsEnd, | 801 .contentsEnd, |
| 800 2); | 802 2); |
| 801 expect( | 803 expect( |
| 802 new SimpleStringLiteral(TokenFactory.tokenFromString('"X"'), "X") | 804 astFactory |
| 805 .simpleStringLiteral(TokenFactory.tokenFromString('"X"'), "X") |
| 803 .contentsEnd, | 806 .contentsEnd, |
| 804 2); | 807 2); |
| 805 | 808 |
| 806 expect( | 809 expect( |
| 807 new SimpleStringLiteral(TokenFactory.tokenFromString('"""X"""'), "X") | 810 astFactory |
| 811 .simpleStringLiteral(TokenFactory.tokenFromString('"""X"""'), "X") |
| 808 .contentsEnd, | 812 .contentsEnd, |
| 809 4); | 813 4); |
| 810 expect( | 814 expect( |
| 811 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") | 815 astFactory |
| 816 .simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") |
| 812 .contentsEnd, | 817 .contentsEnd, |
| 813 4); | 818 4); |
| 814 expect( | 819 expect( |
| 815 new SimpleStringLiteral( | 820 astFactory |
| 821 .simpleStringLiteral( |
| 816 TokenFactory.tokenFromString("''' \nX'''"), "X") | 822 TokenFactory.tokenFromString("''' \nX'''"), "X") |
| 817 .contentsEnd, | 823 .contentsEnd, |
| 818 7); | 824 7); |
| 819 | 825 |
| 820 expect( | 826 expect( |
| 821 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") | 827 astFactory |
| 828 .simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") |
| 822 .contentsEnd, | 829 .contentsEnd, |
| 823 3); | 830 3); |
| 824 expect( | 831 expect( |
| 825 new SimpleStringLiteral(TokenFactory.tokenFromString('r"X"'), "X") | 832 astFactory |
| 833 .simpleStringLiteral(TokenFactory.tokenFromString('r"X"'), "X") |
| 826 .contentsEnd, | 834 .contentsEnd, |
| 827 3); | 835 3); |
| 828 | 836 |
| 829 expect( | 837 expect( |
| 830 new SimpleStringLiteral(TokenFactory.tokenFromString('r"""X"""'), "X") | 838 astFactory |
| 839 .simpleStringLiteral(TokenFactory.tokenFromString('r"""X"""'), "X") |
| 831 .contentsEnd, | 840 .contentsEnd, |
| 832 5); | 841 5); |
| 833 expect( | 842 expect( |
| 834 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") | 843 astFactory |
| 844 .simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") |
| 835 .contentsEnd, | 845 .contentsEnd, |
| 836 5); | 846 5); |
| 837 expect( | 847 expect( |
| 838 new SimpleStringLiteral( | 848 astFactory |
| 849 .simpleStringLiteral( |
| 839 TokenFactory.tokenFromString("r''' \nX'''"), "X") | 850 TokenFactory.tokenFromString("r''' \nX'''"), "X") |
| 840 .contentsEnd, | 851 .contentsEnd, |
| 841 8); | 852 8); |
| 842 } | 853 } |
| 843 | 854 |
| 844 void test_contentsOffset() { | 855 void test_contentsOffset() { |
| 845 expect( | 856 expect( |
| 846 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") | 857 astFactory |
| 858 .simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") |
| 847 .contentsOffset, | 859 .contentsOffset, |
| 848 1); | 860 1); |
| 849 expect( | 861 expect( |
| 850 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") | 862 astFactory |
| 863 .simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") |
| 851 .contentsOffset, | 864 .contentsOffset, |
| 852 1); | 865 1); |
| 853 expect( | 866 expect( |
| 854 new SimpleStringLiteral( | 867 astFactory |
| 868 .simpleStringLiteral( |
| 855 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") | 869 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") |
| 856 .contentsOffset, | 870 .contentsOffset, |
| 857 3); | 871 3); |
| 858 expect( | 872 expect( |
| 859 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") | 873 astFactory |
| 874 .simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") |
| 860 .contentsOffset, | 875 .contentsOffset, |
| 861 3); | 876 3); |
| 862 expect( | 877 expect( |
| 863 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") | 878 astFactory |
| 879 .simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") |
| 864 .contentsOffset, | 880 .contentsOffset, |
| 865 2); | 881 2); |
| 866 expect( | 882 expect( |
| 867 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") | 883 astFactory |
| 884 .simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") |
| 868 .contentsOffset, | 885 .contentsOffset, |
| 869 2); | 886 2); |
| 870 expect( | 887 expect( |
| 871 new SimpleStringLiteral( | 888 astFactory |
| 889 .simpleStringLiteral( |
| 872 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") | 890 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") |
| 873 .contentsOffset, | 891 .contentsOffset, |
| 874 4); | 892 4); |
| 875 expect( | 893 expect( |
| 876 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") | 894 astFactory |
| 895 .simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") |
| 877 .contentsOffset, | 896 .contentsOffset, |
| 878 4); | 897 4); |
| 879 // leading whitespace | 898 // leading whitespace |
| 880 expect( | 899 expect( |
| 881 new SimpleStringLiteral( | 900 astFactory |
| 901 .simpleStringLiteral( |
| 882 TokenFactory.tokenFromString("''' \ \nX''"), "X") | 902 TokenFactory.tokenFromString("''' \ \nX''"), "X") |
| 883 .contentsOffset, | 903 .contentsOffset, |
| 884 6); | 904 6); |
| 885 expect( | 905 expect( |
| 886 new SimpleStringLiteral( | 906 astFactory |
| 907 .simpleStringLiteral( |
| 887 TokenFactory.tokenFromString('r""" \ \nX"""'), "X") | 908 TokenFactory.tokenFromString('r""" \ \nX"""'), "X") |
| 888 .contentsOffset, | 909 .contentsOffset, |
| 889 7); | 910 7); |
| 890 } | 911 } |
| 891 | 912 |
| 892 void test_isMultiline() { | 913 void test_isMultiline() { |
| 893 expect( | 914 expect( |
| 894 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") | 915 astFactory |
| 916 .simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") |
| 895 .isMultiline, | 917 .isMultiline, |
| 896 isFalse); | 918 isFalse); |
| 897 expect( | 919 expect( |
| 898 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") | 920 astFactory |
| 921 .simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") |
| 899 .isMultiline, | 922 .isMultiline, |
| 900 isFalse); | 923 isFalse); |
| 901 expect( | 924 expect( |
| 902 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") | 925 astFactory |
| 926 .simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") |
| 903 .isMultiline, | 927 .isMultiline, |
| 904 isFalse); | 928 isFalse); |
| 905 expect( | 929 expect( |
| 906 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") | 930 astFactory |
| 931 .simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") |
| 907 .isMultiline, | 932 .isMultiline, |
| 908 isFalse); | 933 isFalse); |
| 909 expect( | 934 expect( |
| 910 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") | 935 astFactory |
| 936 .simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") |
| 911 .isMultiline, | 937 .isMultiline, |
| 912 isTrue); | 938 isTrue); |
| 913 expect( | 939 expect( |
| 914 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") | 940 astFactory |
| 941 .simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") |
| 915 .isMultiline, | 942 .isMultiline, |
| 916 isTrue); | 943 isTrue); |
| 917 expect( | 944 expect( |
| 918 new SimpleStringLiteral( | 945 astFactory |
| 946 .simpleStringLiteral( |
| 919 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") | 947 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") |
| 920 .isMultiline, | 948 .isMultiline, |
| 921 isTrue); | 949 isTrue); |
| 922 expect( | 950 expect( |
| 923 new SimpleStringLiteral( | 951 astFactory |
| 952 .simpleStringLiteral( |
| 924 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") | 953 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") |
| 925 .isMultiline, | 954 .isMultiline, |
| 926 isTrue); | 955 isTrue); |
| 927 } | 956 } |
| 928 | 957 |
| 929 void test_isRaw() { | 958 void test_isRaw() { |
| 930 expect( | 959 expect( |
| 931 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isRaw, | 960 astFactory |
| 932 isFalse); | 961 .simpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X") |
| 933 expect( | |
| 934 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") | |
| 935 .isRaw, | 962 .isRaw, |
| 936 isFalse); | 963 isFalse); |
| 937 expect( | 964 expect( |
| 938 new SimpleStringLiteral( | 965 astFactory |
| 966 .simpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X") |
| 967 .isRaw, |
| 968 isFalse); |
| 969 expect( |
| 970 astFactory |
| 971 .simpleStringLiteral( |
| 939 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") | 972 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X") |
| 940 .isRaw, | 973 .isRaw, |
| 941 isFalse); | 974 isFalse); |
| 942 expect( | 975 expect( |
| 943 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") | 976 astFactory |
| 977 .simpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") |
| 944 .isRaw, | 978 .isRaw, |
| 945 isFalse); | 979 isFalse); |
| 946 expect( | 980 expect( |
| 947 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") | 981 astFactory |
| 982 .simpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X") |
| 948 .isRaw, | 983 .isRaw, |
| 949 isTrue); | 984 isTrue); |
| 950 expect( | 985 expect( |
| 951 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") | 986 astFactory |
| 987 .simpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X") |
| 952 .isRaw, | 988 .isRaw, |
| 953 isTrue); | 989 isTrue); |
| 954 expect( | 990 expect( |
| 955 new SimpleStringLiteral( | 991 astFactory |
| 992 .simpleStringLiteral( |
| 956 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") | 993 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X") |
| 957 .isRaw, | 994 .isRaw, |
| 958 isTrue); | 995 isTrue); |
| 959 expect( | 996 expect( |
| 960 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") | 997 astFactory |
| 998 .simpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X") |
| 961 .isRaw, | 999 .isRaw, |
| 962 isTrue); | 1000 isTrue); |
| 963 } | 1001 } |
| 964 | 1002 |
| 965 void test_isSingleQuoted() { | 1003 void test_isSingleQuoted() { |
| 966 // ' | 1004 // ' |
| 967 { | 1005 { |
| 968 var token = TokenFactory.tokenFromString("'X'"); | 1006 var token = TokenFactory.tokenFromString("'X'"); |
| 969 var node = new SimpleStringLiteral(token, null); | 1007 var node = astFactory.simpleStringLiteral(token, null); |
| 970 expect(node.isSingleQuoted, isTrue); | 1008 expect(node.isSingleQuoted, isTrue); |
| 971 } | 1009 } |
| 972 // ''' | 1010 // ''' |
| 973 { | 1011 { |
| 974 var token = TokenFactory.tokenFromString("'''X'''"); | 1012 var token = TokenFactory.tokenFromString("'''X'''"); |
| 975 var node = new SimpleStringLiteral(token, null); | 1013 var node = astFactory.simpleStringLiteral(token, null); |
| 976 expect(node.isSingleQuoted, isTrue); | 1014 expect(node.isSingleQuoted, isTrue); |
| 977 } | 1015 } |
| 978 // " | 1016 // " |
| 979 { | 1017 { |
| 980 var token = TokenFactory.tokenFromString('"X"'); | 1018 var token = TokenFactory.tokenFromString('"X"'); |
| 981 var node = new SimpleStringLiteral(token, null); | 1019 var node = astFactory.simpleStringLiteral(token, null); |
| 982 expect(node.isSingleQuoted, isFalse); | 1020 expect(node.isSingleQuoted, isFalse); |
| 983 } | 1021 } |
| 984 // """ | 1022 // """ |
| 985 { | 1023 { |
| 986 var token = TokenFactory.tokenFromString('"""X"""'); | 1024 var token = TokenFactory.tokenFromString('"""X"""'); |
| 987 var node = new SimpleStringLiteral(token, null); | 1025 var node = astFactory.simpleStringLiteral(token, null); |
| 988 expect(node.isSingleQuoted, isFalse); | 1026 expect(node.isSingleQuoted, isFalse); |
| 989 } | 1027 } |
| 990 } | 1028 } |
| 991 | 1029 |
| 992 void test_isSingleQuoted_raw() { | 1030 void test_isSingleQuoted_raw() { |
| 993 // r' | 1031 // r' |
| 994 { | 1032 { |
| 995 var token = TokenFactory.tokenFromString("r'X'"); | 1033 var token = TokenFactory.tokenFromString("r'X'"); |
| 996 var node = new SimpleStringLiteral(token, null); | 1034 var node = astFactory.simpleStringLiteral(token, null); |
| 997 expect(node.isSingleQuoted, isTrue); | 1035 expect(node.isSingleQuoted, isTrue); |
| 998 } | 1036 } |
| 999 // r''' | 1037 // r''' |
| 1000 { | 1038 { |
| 1001 var token = TokenFactory.tokenFromString("r'''X'''"); | 1039 var token = TokenFactory.tokenFromString("r'''X'''"); |
| 1002 var node = new SimpleStringLiteral(token, null); | 1040 var node = astFactory.simpleStringLiteral(token, null); |
| 1003 expect(node.isSingleQuoted, isTrue); | 1041 expect(node.isSingleQuoted, isTrue); |
| 1004 } | 1042 } |
| 1005 // r" | 1043 // r" |
| 1006 { | 1044 { |
| 1007 var token = TokenFactory.tokenFromString('r"X"'); | 1045 var token = TokenFactory.tokenFromString('r"X"'); |
| 1008 var node = new SimpleStringLiteral(token, null); | 1046 var node = astFactory.simpleStringLiteral(token, null); |
| 1009 expect(node.isSingleQuoted, isFalse); | 1047 expect(node.isSingleQuoted, isFalse); |
| 1010 } | 1048 } |
| 1011 // r""" | 1049 // r""" |
| 1012 { | 1050 { |
| 1013 var token = TokenFactory.tokenFromString('r"""X"""'); | 1051 var token = TokenFactory.tokenFromString('r"""X"""'); |
| 1014 var node = new SimpleStringLiteral(token, null); | 1052 var node = astFactory.simpleStringLiteral(token, null); |
| 1015 expect(node.isSingleQuoted, isFalse); | 1053 expect(node.isSingleQuoted, isFalse); |
| 1016 } | 1054 } |
| 1017 } | 1055 } |
| 1018 | 1056 |
| 1019 void test_simple() { | 1057 void test_simple() { |
| 1020 Token token = TokenFactory.tokenFromString("'value'"); | 1058 Token token = TokenFactory.tokenFromString("'value'"); |
| 1021 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value"); | 1059 SimpleStringLiteral stringLiteral = |
| 1060 astFactory.simpleStringLiteral(token, "value"); |
| 1022 expect(stringLiteral.literal, same(token)); | 1061 expect(stringLiteral.literal, same(token)); |
| 1023 expect(stringLiteral.beginToken, same(token)); | 1062 expect(stringLiteral.beginToken, same(token)); |
| 1024 expect(stringLiteral.endToken, same(token)); | 1063 expect(stringLiteral.endToken, same(token)); |
| 1025 expect(stringLiteral.value, "value"); | 1064 expect(stringLiteral.value, "value"); |
| 1026 } | 1065 } |
| 1027 } | 1066 } |
| 1028 | 1067 |
| 1029 @reflectiveTest | 1068 @reflectiveTest |
| 1030 class StringInterpolationTest extends ParserTestCase { | 1069 class StringInterpolationTest extends ParserTestCase { |
| 1031 void test_contentsOffsetEnd() { | 1070 void test_contentsOffsetEnd() { |
| 1032 AstTestFactory.interpolationExpression(AstTestFactory.identifier3('bb')); | 1071 AstTestFactory.interpolationExpression(AstTestFactory.identifier3('bb')); |
| 1033 // 'a${bb}ccc' | 1072 // 'a${bb}ccc' |
| 1034 { | 1073 { |
| 1035 var ae = AstTestFactory.interpolationString("'a", "a"); | 1074 var ae = AstTestFactory.interpolationString("'a", "a"); |
| 1036 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); | 1075 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); |
| 1037 var cElement = new InterpolationString(cToken, 'ccc'); | 1076 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1038 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1077 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1039 expect(node.contentsOffset, 1); | 1078 expect(node.contentsOffset, 1); |
| 1040 expect(node.contentsEnd, 10 + 4 - 1); | 1079 expect(node.contentsEnd, 10 + 4 - 1); |
| 1041 } | 1080 } |
| 1042 // '''a${bb}ccc''' | 1081 // '''a${bb}ccc''' |
| 1043 { | 1082 { |
| 1044 var ae = AstTestFactory.interpolationString("'''a", "a"); | 1083 var ae = AstTestFactory.interpolationString("'''a", "a"); |
| 1045 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); | 1084 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); |
| 1046 var cElement = new InterpolationString(cToken, 'ccc'); | 1085 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1047 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1086 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1048 expect(node.contentsOffset, 3); | 1087 expect(node.contentsOffset, 3); |
| 1049 expect(node.contentsEnd, 10 + 4 - 1); | 1088 expect(node.contentsEnd, 10 + 4 - 1); |
| 1050 } | 1089 } |
| 1051 // """a${bb}ccc""" | 1090 // """a${bb}ccc""" |
| 1052 { | 1091 { |
| 1053 var ae = AstTestFactory.interpolationString('"""a', "a"); | 1092 var ae = AstTestFactory.interpolationString('"""a', "a"); |
| 1054 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); | 1093 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); |
| 1055 var cElement = new InterpolationString(cToken, 'ccc'); | 1094 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1056 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1095 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1057 expect(node.contentsOffset, 3); | 1096 expect(node.contentsOffset, 3); |
| 1058 expect(node.contentsEnd, 10 + 4 - 1); | 1097 expect(node.contentsEnd, 10 + 4 - 1); |
| 1059 } | 1098 } |
| 1060 // r'a${bb}ccc' | 1099 // r'a${bb}ccc' |
| 1061 { | 1100 { |
| 1062 var ae = AstTestFactory.interpolationString("r'a", "a"); | 1101 var ae = AstTestFactory.interpolationString("r'a", "a"); |
| 1063 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); | 1102 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); |
| 1064 var cElement = new InterpolationString(cToken, 'ccc'); | 1103 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1065 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1104 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1066 expect(node.contentsOffset, 2); | 1105 expect(node.contentsOffset, 2); |
| 1067 expect(node.contentsEnd, 10 + 4 - 1); | 1106 expect(node.contentsEnd, 10 + 4 - 1); |
| 1068 } | 1107 } |
| 1069 // r'''a${bb}ccc''' | 1108 // r'''a${bb}ccc''' |
| 1070 { | 1109 { |
| 1071 var ae = AstTestFactory.interpolationString("r'''a", "a"); | 1110 var ae = AstTestFactory.interpolationString("r'''a", "a"); |
| 1072 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); | 1111 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); |
| 1073 var cElement = new InterpolationString(cToken, 'ccc'); | 1112 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1074 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1113 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1075 expect(node.contentsOffset, 4); | 1114 expect(node.contentsOffset, 4); |
| 1076 expect(node.contentsEnd, 10 + 4 - 1); | 1115 expect(node.contentsEnd, 10 + 4 - 1); |
| 1077 } | 1116 } |
| 1078 // r"""a${bb}ccc""" | 1117 // r"""a${bb}ccc""" |
| 1079 { | 1118 { |
| 1080 var ae = AstTestFactory.interpolationString('r"""a', "a"); | 1119 var ae = AstTestFactory.interpolationString('r"""a', "a"); |
| 1081 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); | 1120 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); |
| 1082 var cElement = new InterpolationString(cToken, 'ccc'); | 1121 var cElement = astFactory.interpolationString(cToken, 'ccc'); |
| 1083 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); | 1122 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]); |
| 1084 expect(node.contentsOffset, 4); | 1123 expect(node.contentsOffset, 4); |
| 1085 expect(node.contentsEnd, 10 + 4 - 1); | 1124 expect(node.contentsEnd, 10 + 4 - 1); |
| 1086 } | 1125 } |
| 1087 } | 1126 } |
| 1088 | 1127 |
| 1089 void test_isMultiline() { | 1128 void test_isMultiline() { |
| 1090 var b = AstTestFactory | 1129 var b = AstTestFactory |
| 1091 .interpolationExpression(AstTestFactory.identifier3('bb')); | 1130 .interpolationExpression(AstTestFactory.identifier3('bb')); |
| 1092 // ' | 1131 // ' |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 } | 1196 } |
| 1158 } | 1197 } |
| 1159 } | 1198 } |
| 1160 | 1199 |
| 1161 @reflectiveTest | 1200 @reflectiveTest |
| 1162 class VariableDeclarationTest extends ParserTestCase { | 1201 class VariableDeclarationTest extends ParserTestCase { |
| 1163 void test_getDocumentationComment_onGrandParent() { | 1202 void test_getDocumentationComment_onGrandParent() { |
| 1164 VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a"); | 1203 VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a"); |
| 1165 TopLevelVariableDeclaration decl = | 1204 TopLevelVariableDeclaration decl = |
| 1166 AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); | 1205 AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); |
| 1167 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 1206 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
| 1168 expect(varDecl.documentationComment, isNull); | 1207 expect(varDecl.documentationComment, isNull); |
| 1169 decl.documentationComment = comment; | 1208 decl.documentationComment = comment; |
| 1170 expect(varDecl.documentationComment, isNotNull); | 1209 expect(varDecl.documentationComment, isNotNull); |
| 1171 expect(decl.documentationComment, isNotNull); | 1210 expect(decl.documentationComment, isNotNull); |
| 1172 } | 1211 } |
| 1173 | 1212 |
| 1174 void test_getDocumentationComment_onNode() { | 1213 void test_getDocumentationComment_onNode() { |
| 1175 VariableDeclaration decl = AstTestFactory.variableDeclaration("a"); | 1214 VariableDeclaration decl = AstTestFactory.variableDeclaration("a"); |
| 1176 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 1215 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
| 1177 decl.documentationComment = comment; | 1216 decl.documentationComment = comment; |
| 1178 expect(decl.documentationComment, isNotNull); | 1217 expect(decl.documentationComment, isNotNull); |
| 1179 } | 1218 } |
| 1180 } | 1219 } |
| 1181 | 1220 |
| 1182 class _AssignmentKind { | 1221 class _AssignmentKind { |
| 1183 static const _AssignmentKind BINARY = const _AssignmentKind('BINARY', 0); | 1222 static const _AssignmentKind BINARY = const _AssignmentKind('BINARY', 0); |
| 1184 | 1223 |
| 1185 static const _AssignmentKind COMPOUND_LEFT = | 1224 static const _AssignmentKind COMPOUND_LEFT = |
| 1186 const _AssignmentKind('COMPOUND_LEFT', 1); | 1225 const _AssignmentKind('COMPOUND_LEFT', 1); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 final int ordinal; | 1301 final int ordinal; |
| 1263 | 1302 |
| 1264 const _WrapperKind(this.name, this.ordinal); | 1303 const _WrapperKind(this.name, this.ordinal); |
| 1265 | 1304 |
| 1266 int get hashCode => ordinal; | 1305 int get hashCode => ordinal; |
| 1267 | 1306 |
| 1268 int compareTo(_WrapperKind other) => ordinal - other.ordinal; | 1307 int compareTo(_WrapperKind other) => ordinal - other.ordinal; |
| 1269 | 1308 |
| 1270 String toString() => name; | 1309 String toString() => name; |
| 1271 } | 1310 } |
| OLD | NEW |