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

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

Issue 296233002: Add a path.formatUri method and release path 1.2.0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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.posix_test; 5 library path.test.posix_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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 expect(context.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/')); 501 expect(context.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/'));
502 expect(context.toUri('/'), Uri.parse('file:///')); 502 expect(context.toUri('/'), Uri.parse('file:///'));
503 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); 503 expect(context.toUri('foo/bar'), Uri.parse('foo/bar'));
504 expect(context.toUri('/path/to/foo#bar'), 504 expect(context.toUri('/path/to/foo#bar'),
505 Uri.parse('file:///path/to/foo%23bar')); 505 Uri.parse('file:///path/to/foo%23bar'));
506 expect(context.toUri(r'/_{_}_`_^_ _"_%_'), 506 expect(context.toUri(r'/_{_}_`_^_ _"_%_'),
507 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_')); 507 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_'));
508 expect(context.toUri(r'_{_}_`_^_ _"_%_'), 508 expect(context.toUri(r'_{_}_`_^_ _"_%_'),
509 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); 509 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_'));
510 }); 510 });
511
512 group('formatUri', () {
513 test('with a file: URI', () {
514 expect(context.formatUri(Uri.parse('file:///root/path/a/b')), 'a/b');
Bob Nystrom 2014/05/23 21:57:52 The tests would be a bit cleaner if you passed a s
nweiz 2014/05/23 22:18:04 Done.
515 expect(context.formatUri(Uri.parse('file:///other/path/a/b')),
516 '/other/path/a/b');
517 expect(context.formatUri(Uri.parse('file:///root/other')), '../other');
518 });
519
520 test('with an http: URI', () {
521 expect(context.formatUri(Uri.parse('http://dartlang.org/a/b')),
522 'http://dartlang.org/a/b');
523 });
524
525 test('with a relative URI', () {
526 expect(context.formatUri(Uri.parse('a/b')), 'a/b');
527 });
528
529 test('with a root-relative URI', () {
530 expect(context.formatUri(Uri.parse('/a/b')), '/a/b');
531 });
532
533 test('with a String', () {
534 expect(context.formatUri('a/b'), 'a/b');
535 });
536 });
511 } 537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698