| OLD | NEW |
| 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 import 'package:unittest/unittest.dart'; | 5 import 'package:unittest/unittest.dart'; |
| 6 import 'package:path/path.dart' as path; | 6 import 'package:path/path.dart' as path; |
| 7 | 7 |
| 8 main() { | 8 main() { |
| 9 var context = new path.Context(style: path.Style.url, | 9 var context = new path.Context(style: path.Style.url, |
| 10 current: 'http://dartlang.org/root/path'); | 10 current: 'http://dartlang.org/root/path'); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 expect(context.withoutExtension('a/.'), 'a/.'); | 693 expect(context.withoutExtension('a/.'), 'a/.'); |
| 694 expect(context.withoutExtension('a/.b'), 'a/.b'); | 694 expect(context.withoutExtension('a/.b'), 'a/.b'); |
| 695 expect(context.withoutExtension('a.b/c'), 'a.b/c'); | 695 expect(context.withoutExtension('a.b/c'), 'a.b/c'); |
| 696 expect(context.withoutExtension(r'a.b\c'), r'a'); | 696 expect(context.withoutExtension(r'a.b\c'), r'a'); |
| 697 expect(context.withoutExtension(r'a/b\c'), r'a/b\c'); | 697 expect(context.withoutExtension(r'a/b\c'), r'a/b\c'); |
| 698 expect(context.withoutExtension(r'a/b\c.d'), r'a/b\c'); | 698 expect(context.withoutExtension(r'a/b\c.d'), r'a/b\c'); |
| 699 expect(context.withoutExtension('a/b.c/'), 'a/b/'); | 699 expect(context.withoutExtension('a/b.c/'), 'a/b/'); |
| 700 expect(context.withoutExtension('a/b.c//'), 'a/b//'); | 700 expect(context.withoutExtension('a/b.c//'), 'a/b//'); |
| 701 }); | 701 }); |
| 702 | 702 |
| 703 test('fromUri', () { | 703 group('fromUri', () { |
| 704 expect(context.fromUri(Uri.parse('http://dartlang.org/path/to/foo')), | 704 test('with a URI', () { |
| 705 'http://dartlang.org/path/to/foo'); | 705 expect(context.fromUri(Uri.parse('http://dartlang.org/path/to/foo')), |
| 706 expect(context.fromUri(Uri.parse('http://dartlang.org/path/to/foo/')), | 706 'http://dartlang.org/path/to/foo'); |
| 707 'http://dartlang.org/path/to/foo/'); | 707 expect(context.fromUri(Uri.parse('http://dartlang.org/path/to/foo/')), |
| 708 expect(context.fromUri(Uri.parse('file:///path/to/foo')), | 708 'http://dartlang.org/path/to/foo/'); |
| 709 'file:///path/to/foo'); | 709 expect(context.fromUri(Uri.parse('file:///path/to/foo')), |
| 710 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); | 710 'file:///path/to/foo'); |
| 711 expect(context.fromUri(Uri.parse('http://dartlang.org/path/to/foo%23bar')), | 711 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); |
| 712 'http://dartlang.org/path/to/foo%23bar'); | 712 expect(context.fromUri( |
| 713 // Since the resulting "path" is also a URL, special characters should | 713 Uri.parse('http://dartlang.org/path/to/foo%23bar')), |
| 714 // remain percent-encoded in the result. | 714 'http://dartlang.org/path/to/foo%23bar'); |
| 715 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), | 715 // Since the resulting "path" is also a URL, special characters should |
| 716 r'_%7B_%7D_%60_%5E_%20_%22_%25_'); | 716 // remain percent-encoded in the result. |
| 717 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), |
| 718 r'_%7B_%7D_%60_%5E_%20_%22_%25_'); |
| 719 }); |
| 720 |
| 721 test('with a string', () { |
| 722 expect(context.fromUri('http://dartlang.org/path/to/foo'), |
| 723 'http://dartlang.org/path/to/foo'); |
| 724 }); |
| 717 }); | 725 }); |
| 718 | 726 |
| 719 test('toUri', () { | 727 test('toUri', () { |
| 720 expect(context.toUri('http://dartlang.org/path/to/foo'), | 728 expect(context.toUri('http://dartlang.org/path/to/foo'), |
| 721 Uri.parse('http://dartlang.org/path/to/foo')); | 729 Uri.parse('http://dartlang.org/path/to/foo')); |
| 722 expect(context.toUri('http://dartlang.org/path/to/foo/'), | 730 expect(context.toUri('http://dartlang.org/path/to/foo/'), |
| 723 Uri.parse('http://dartlang.org/path/to/foo/')); | 731 Uri.parse('http://dartlang.org/path/to/foo/')); |
| 724 expect(context.toUri('file:///path/to/foo'), | 732 expect(context.toUri('file:///path/to/foo'), |
| 725 Uri.parse('file:///path/to/foo')); | 733 Uri.parse('file:///path/to/foo')); |
| 726 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); | 734 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); |
| 727 expect(context.toUri('http://dartlang.org/path/to/foo%23bar'), | 735 expect(context.toUri('http://dartlang.org/path/to/foo%23bar'), |
| 728 Uri.parse('http://dartlang.org/path/to/foo%23bar')); | 736 Uri.parse('http://dartlang.org/path/to/foo%23bar')); |
| 729 // Since the input path is also a URI, special characters should already | 737 // Since the input path is also a URI, special characters should already |
| 730 // be percent encoded there too. | 738 // be percent encoded there too. |
| 731 expect(context.toUri(r'http://foo.com/_%7B_%7D_%60_%5E_%20_%22_%25_'), | 739 expect(context.toUri(r'http://foo.com/_%7B_%7D_%60_%5E_%20_%22_%25_'), |
| 732 Uri.parse('http://foo.com/_%7B_%7D_%60_%5E_%20_%22_%25_')); | 740 Uri.parse('http://foo.com/_%7B_%7D_%60_%5E_%20_%22_%25_')); |
| 733 expect(context.toUri(r'_%7B_%7D_%60_%5E_%20_%22_%25_'), | 741 expect(context.toUri(r'_%7B_%7D_%60_%5E_%20_%22_%25_'), |
| 734 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); | 742 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); |
| 735 }); | 743 }); |
| 736 } | 744 } |
| OLD | NEW |