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 engine.test_support; | 5 library engine.test_support; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator; | 9 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 int _modificationStamp = 0; | 551 int _modificationStamp = 0; |
552 bool exists2 = true; | 552 bool exists2 = true; |
553 | 553 |
554 /** | 554 /** |
555 * A flag indicating whether an exception should be generated when an attempt | 555 * A flag indicating whether an exception should be generated when an attempt |
556 * is made to access the contents of this source. | 556 * is made to access the contents of this source. |
557 */ | 557 */ |
558 bool generateExceptionOnRead = false; | 558 bool generateExceptionOnRead = false; |
559 | 559 |
560 @override | 560 @override |
561 int get modificationStamp => generateExceptionOnRead ? -1 : _modificationStamp
; | 561 int get modificationStamp => |
| 562 generateExceptionOnRead ? -1 : _modificationStamp; |
562 | 563 |
563 /** | 564 /** |
564 * The number of times that the contents of this source have been requested. | 565 * The number of times that the contents of this source have been requested. |
565 */ | 566 */ |
566 int readCount = 0; | 567 int readCount = 0; |
567 | 568 |
568 TestSource([this._name = '/test.dart', this._contents]); | 569 TestSource([this._name = '/test.dart', this._contents]); |
569 | 570 |
570 TimestampedData<String> get contents { | 571 TimestampedData<String> get contents { |
571 readCount++; | 572 readCount++; |
572 if (generateExceptionOnRead) { | 573 if (generateExceptionOnRead) { |
573 String msg = "I/O Exception while getting the contents of " + _name; | 574 String msg = "I/O Exception while getting the contents of " + _name; |
574 throw new Exception(msg); | 575 throw new Exception(msg); |
575 } | 576 } |
576 return new TimestampedData<String>(0, _contents); | 577 return new TimestampedData<String>(0, _contents); |
577 } | 578 } |
| 579 |
578 String get encoding { | 580 String get encoding { |
579 throw new UnsupportedOperationException(); | 581 throw new UnsupportedOperationException(); |
580 } | 582 } |
| 583 |
581 String get fullName { | 584 String get fullName { |
582 return _name; | 585 return _name; |
583 } | 586 } |
| 587 |
584 int get hashCode => 0; | 588 int get hashCode => 0; |
585 bool get isInSystemLibrary { | 589 bool get isInSystemLibrary { |
586 return false; | 590 return false; |
587 } | 591 } |
| 592 |
588 String get shortName { | 593 String get shortName { |
589 return _name; | 594 return _name; |
590 } | 595 } |
| 596 |
591 Uri get uri { | 597 Uri get uri { |
592 throw new UnsupportedOperationException(); | 598 throw new UnsupportedOperationException(); |
593 } | 599 } |
| 600 |
594 UriKind get uriKind { | 601 UriKind get uriKind { |
595 throw new UnsupportedOperationException(); | 602 throw new UnsupportedOperationException(); |
596 } | 603 } |
| 604 |
597 bool operator ==(Object other) { | 605 bool operator ==(Object other) { |
598 if (other is TestSource) { | 606 if (other is TestSource) { |
599 return other._name == _name; | 607 return other._name == _name; |
600 } | 608 } |
601 return false; | 609 return false; |
602 } | 610 } |
| 611 |
603 bool exists() => exists2; | 612 bool exists() => exists2; |
604 void getContentsToReceiver(Source_ContentReceiver receiver) { | 613 void getContentsToReceiver(Source_ContentReceiver receiver) { |
605 throw new UnsupportedOperationException(); | 614 throw new UnsupportedOperationException(); |
606 } | 615 } |
| 616 |
607 Source resolve(String uri) { | 617 Source resolve(String uri) { |
608 throw new UnsupportedOperationException(); | 618 throw new UnsupportedOperationException(); |
609 } | 619 } |
| 620 |
610 Uri resolveRelativeUri(Uri uri) { | 621 Uri resolveRelativeUri(Uri uri) { |
611 return new Uri(scheme: 'file', path: _name).resolveUri(uri); | 622 return new Uri(scheme: 'file', path: _name).resolveUri(uri); |
612 } | 623 } |
| 624 |
613 void setContents(String value) { | 625 void setContents(String value) { |
614 generateExceptionOnRead = false; | 626 generateExceptionOnRead = false; |
615 _modificationStamp = new DateTime.now().millisecondsSinceEpoch; | 627 _modificationStamp = new DateTime.now().millisecondsSinceEpoch; |
616 _contents = value; | 628 _contents = value; |
617 } | 629 } |
| 630 |
618 @override | 631 @override |
619 String toString() => '$_name'; | 632 String toString() => '$_name'; |
620 } | 633 } |
621 | 634 |
622 class TestSourceWithUri extends TestSource { | 635 class TestSourceWithUri extends TestSource { |
623 final Uri uri; | 636 final Uri uri; |
624 | 637 |
625 TestSourceWithUri(String path, this.uri, [String content]) | 638 TestSourceWithUri(String path, this.uri, [String content]) |
626 : super(path, content); | 639 : super(path, content); |
627 | 640 |
(...skipping 12 matching lines...) Expand all Loading... |
640 if (other is TestSource) { | 653 if (other is TestSource) { |
641 return other.uri == uri; | 654 return other.uri == uri; |
642 } | 655 } |
643 return false; | 656 return false; |
644 } | 657 } |
645 | 658 |
646 Uri resolveRelativeUri(Uri uri) { | 659 Uri resolveRelativeUri(Uri uri) { |
647 return this.uri.resolveUri(uri); | 660 return this.uri.resolveUri(uri); |
648 } | 661 } |
649 } | 662 } |
OLD | NEW |