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

Side by Side Diff: pkg/path/test/windows_test.dart

Issue 203673003: Allow [path.fromUri] to take a string as well as a URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 path.test.windows_test; 5 library path.test.windows_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:path/path.dart' as path; 8 import 'package:path/path.dart' as path;
9 9
10 import 'utils.dart'; 10 import 'utils.dart';
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 expect(context.withoutExtension(r'a\.'), r'a\.'); 583 expect(context.withoutExtension(r'a\.'), r'a\.');
584 expect(context.withoutExtension(r'a\.b'), r'a\.b'); 584 expect(context.withoutExtension(r'a\.b'), r'a\.b');
585 expect(context.withoutExtension(r'a.b\c'), r'a.b\c'); 585 expect(context.withoutExtension(r'a.b\c'), r'a.b\c');
586 expect(context.withoutExtension(r'a/b.c/d'), r'a/b.c/d'); 586 expect(context.withoutExtension(r'a/b.c/d'), r'a/b.c/d');
587 expect(context.withoutExtension(r'a\b/c'), r'a\b/c'); 587 expect(context.withoutExtension(r'a\b/c'), r'a\b/c');
588 expect(context.withoutExtension(r'a\b/c.d'), r'a\b/c'); 588 expect(context.withoutExtension(r'a\b/c.d'), r'a\b/c');
589 expect(context.withoutExtension(r'a.b/c'), r'a.b/c'); 589 expect(context.withoutExtension(r'a.b/c'), r'a.b/c');
590 expect(context.withoutExtension(r'a\b.c\'), r'a\b\'); 590 expect(context.withoutExtension(r'a\b.c\'), r'a\b\');
591 }); 591 });
592 592
593 test('fromUri', () { 593 group('fromUri', () {
594 expect(context.fromUri(Uri.parse('file:///C:/path/to/foo')), 594 test('with a URI', () {
595 r'C:\path\to\foo'); 595 expect(context.fromUri(Uri.parse('file:///C:/path/to/foo')),
596 expect(context.fromUri(Uri.parse('file://server/share/path/to/foo')), 596 r'C:\path\to\foo');
597 r'\\server\share\path\to\foo'); 597 expect(context.fromUri(Uri.parse('file://server/share/path/to/foo')),
598 expect(context.fromUri(Uri.parse('file:///C:/')), r'C:\'); 598 r'\\server\share\path\to\foo');
599 expect(context.fromUri(Uri.parse('file://server/share')), 599 expect(context.fromUri(Uri.parse('file:///C:/')), r'C:\');
600 r'\\server\share'); 600 expect(context.fromUri(Uri.parse('file://server/share')),
601 expect(context.fromUri(Uri.parse('foo/bar')), r'foo\bar'); 601 r'\\server\share');
602 expect(context.fromUri(Uri.parse('/C:/path/to/foo')), r'C:\path\to\foo'); 602 expect(context.fromUri(Uri.parse('foo/bar')), r'foo\bar');
603 expect(context.fromUri(Uri.parse('///C:/path/to/foo')), r'C:\path\to\foo'); 603 expect(context.fromUri(Uri.parse('/C:/path/to/foo')), r'C:\path\to\foo');
604 expect(context.fromUri(Uri.parse('//server/share/path/to/foo')), 604 expect(context.fromUri(Uri.parse('///C:/path/to/foo')),
605 r'\\server\share\path\to\foo'); 605 r'C:\path\to\foo');
606 expect(context.fromUri(Uri.parse('file:///C:/path/to/foo%23bar')), 606 expect(context.fromUri(Uri.parse('//server/share/path/to/foo')),
607 r'C:\path\to\foo#bar'); 607 r'\\server\share\path\to\foo');
608 expect(context.fromUri(Uri.parse('file://server/share/path/to/foo%23bar')), 608 expect(context.fromUri(Uri.parse('file:///C:/path/to/foo%23bar')),
609 r'\\server\share\path\to\foo#bar'); 609 r'C:\path\to\foo#bar');
610 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), 610 expect(context.fromUri(
611 r'_{_}_`_^_ _"_%_'); 611 Uri.parse('file://server/share/path/to/foo%23bar')),
612 expect(() => context.fromUri(Uri.parse('http://dartlang.org')), 612 r'\\server\share\path\to\foo#bar');
613 throwsArgumentError); 613 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')),
614 r'_{_}_`_^_ _"_%_');
615 expect(() => context.fromUri(Uri.parse('http://dartlang.org')),
616 throwsArgumentError);
617 });
618
619 test('with a string', () {
620 expect(context.fromUri('file:///C:/path/to/foo'), r'C:\path\to\foo');
621 });
614 }); 622 });
615 623
616 test('toUri', () { 624 test('toUri', () {
617 expect(context.toUri(r'C:\path\to\foo'), 625 expect(context.toUri(r'C:\path\to\foo'),
618 Uri.parse('file:///C:/path/to/foo')); 626 Uri.parse('file:///C:/path/to/foo'));
619 expect(context.toUri(r'C:\path\to\foo\'), 627 expect(context.toUri(r'C:\path\to\foo\'),
620 Uri.parse('file:///C:/path/to/foo/')); 628 Uri.parse('file:///C:/path/to/foo/'));
621 expect(context.toUri(r'C:\'), Uri.parse('file:///C:/')); 629 expect(context.toUri(r'C:\'), Uri.parse('file:///C:/'));
622 expect(context.toUri(r'\\server\share'), Uri.parse('file://server/share')); 630 expect(context.toUri(r'\\server\share'), Uri.parse('file://server/share'));
623 expect(context.toUri(r'\\server\share\'), 631 expect(context.toUri(r'\\server\share\'),
624 Uri.parse('file://server/share/')); 632 Uri.parse('file://server/share/'));
625 expect(context.toUri(r'foo\bar'), Uri.parse('foo/bar')); 633 expect(context.toUri(r'foo\bar'), Uri.parse('foo/bar'));
626 expect(context.toUri(r'C:\path\to\foo#bar'), 634 expect(context.toUri(r'C:\path\to\foo#bar'),
627 Uri.parse('file:///C:/path/to/foo%23bar')); 635 Uri.parse('file:///C:/path/to/foo%23bar'));
628 expect(context.toUri(r'\\server\share\path\to\foo#bar'), 636 expect(context.toUri(r'\\server\share\path\to\foo#bar'),
629 Uri.parse('file://server/share/path/to/foo%23bar')); 637 Uri.parse('file://server/share/path/to/foo%23bar'));
630 expect(context.toUri(r'C:\_{_}_`_^_ _"_%_'), 638 expect(context.toUri(r'C:\_{_}_`_^_ _"_%_'),
631 Uri.parse('file:///C:/_%7B_%7D_%60_%5E_%20_%22_%25_')); 639 Uri.parse('file:///C:/_%7B_%7D_%60_%5E_%20_%22_%25_'));
632 expect(context.toUri(r'_{_}_`_^_ _"_%_'), 640 expect(context.toUri(r'_{_}_`_^_ _"_%_'),
633 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); 641 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_'));
634 }); 642 });
635 } 643 }
OLDNEW
« no previous file with comments | « pkg/path/test/url_test.dart ('k') | sdk/lib/_internal/pub/lib/src/barback/build_environment.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698