Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: pkg/analyzer/test/file_system/memory_file_system_test.dart

Issue 1831133005: Consolidate duplicate code for resloving URIs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Sort Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.file_system.memory_file_system_test; 5 library analyzer.test.file_system.memory_file_system_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
11 import 'package:analyzer/file_system/memory_file_system.dart'; 11 import 'package:analyzer/file_system/memory_file_system.dart';
12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
13 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer/src/generated/utilities_dart.dart';
14 import 'package:path/path.dart'; 15 import 'package:path/path.dart';
15 import 'package:unittest/unittest.dart'; 16 import 'package:unittest/unittest.dart';
16 import 'package:watcher/watcher.dart'; 17 import 'package:watcher/watcher.dart';
17 18
18 import '../reflective_tests.dart'; 19 import '../reflective_tests.dart';
19 import '../utils.dart'; 20 import '../utils.dart';
20 21
21 main() { 22 main() {
22 initializeTestEnvironment(); 23 initializeTestEnvironment();
23 runReflectiveTests(FileSystemExceptionTest); 24 runReflectiveTests(FileSystemExceptionTest);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 396
396 void test_fullName() { 397 void test_fullName() {
397 expect(source.fullName, '/foo/test.dart'); 398 expect(source.fullName, '/foo/test.dart');
398 } 399 }
399 400
400 void test_hashCode() { 401 void test_hashCode() {
401 source.hashCode; 402 source.hashCode;
402 } 403 }
403 404
404 void test_resolveRelative() { 405 void test_resolveRelative() {
405 Uri relative = source.resolveRelativeUri(new Uri.file('bar/baz.dart')); 406 Uri relative = resolveRelativeUri(source.uri, new Uri.file('bar/baz.dart'));
406 expect(relative.path, '/foo/bar/baz.dart'); 407 expect(relative.path, '/foo/bar/baz.dart');
407 } 408 }
408 409
409 void test_resolveRelative_dart() { 410 void test_resolveRelative_dart() {
410 File file = provider.newFile('/sdk/lib/core/core.dart', ''); 411 File file = provider.newFile('/sdk/lib/core/core.dart', '');
411 Source source = file.createSource(Uri.parse('dart:core')); 412 Source source = file.createSource(Uri.parse('dart:core'));
412 Uri resolved = source.resolveRelativeUri(Uri.parse('int.dart')); 413 Uri resolved = resolveRelativeUri(source.uri, Uri.parse('int.dart'));
413 expect(resolved.toString(), 'dart:core/int.dart'); 414 expect(resolved.toString(), 'dart:core/int.dart');
414 } 415 }
415 416
416 void test_shortName() { 417 void test_shortName() {
417 expect(source.shortName, 'test.dart'); 418 expect(source.shortName, 'test.dart');
418 } 419 }
419 } 420 }
420 421
421 @reflectiveTest 422 @reflectiveTest
422 class MemoryFileSourceNotExistingTest { 423 class MemoryFileSourceNotExistingTest {
(...skipping 21 matching lines...) Expand all
444 445
445 void test_fullName() { 446 void test_fullName() {
446 expect(source.fullName, '/foo/test.dart'); 447 expect(source.fullName, '/foo/test.dart');
447 } 448 }
448 449
449 void test_modificationStamp() { 450 void test_modificationStamp() {
450 expect(source.modificationStamp, -1); 451 expect(source.modificationStamp, -1);
451 } 452 }
452 453
453 void test_resolveRelative() { 454 void test_resolveRelative() {
454 Uri relative = source.resolveRelativeUri(new Uri.file('bar/baz.dart')); 455 Uri relative = resolveRelativeUri(source.uri, new Uri.file('bar/baz.dart'));
455 expect(relative.path, '/foo/bar/baz.dart'); 456 expect(relative.path, '/foo/bar/baz.dart');
456 } 457 }
457 458
458 void test_shortName() { 459 void test_shortName() {
459 expect(source.shortName, 'test.dart'); 460 expect(source.shortName, 'test.dart');
460 } 461 }
461 } 462 }
462 463
463 @reflectiveTest 464 @reflectiveTest
464 class MemoryResourceProviderTest { 465 class MemoryResourceProviderTest {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 return new Future.delayed(Duration.ZERO, computation); 639 return new Future.delayed(Duration.ZERO, computation);
639 } 640 }
640 641
641 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { 642 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
642 Folder folder = provider.getResource(path); 643 Folder folder = provider.getResource(path);
643 var changesReceived = <WatchEvent>[]; 644 var changesReceived = <WatchEvent>[];
644 folder.changes.listen(changesReceived.add); 645 folder.changes.listen(changesReceived.add);
645 return test(changesReceived); 646 return test(changesReceived);
646 } 647 }
647 } 648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698