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

Side by Side Diff: pkg/pathos/test/pathos_posix_test.dart

Issue 15967012: Make pathos run in the browser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bug fix. Created 7 years, 6 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 pathos_posix_test; 5 library pathos_posix_test;
6 6
7 import 'dart:io' as io;
8
9 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
10 import 'package:pathos/path.dart' as path; 8 import 'package:pathos/path.dart' as path;
11 9
12 main() { 10 main() {
13 var builder = new path.Builder(style: path.Style.posix, root: '/root/path'); 11 var builder = new path.Builder(style: path.Style.posix, root: '/root/path');
14 12
15 if (new path.Builder().style == path.Style.posix) { 13 if (new path.Builder().style == path.Style.posix) {
16 group('absolute', () { 14 group('absolute', () {
17 expect(path.absolute('a/b.txt'), path.join(path.current, 'a/b.txt')); 15 expect(path.absolute('a/b.txt'), path.join(path.current, 'a/b.txt'));
18 expect(path.absolute('/a/b.txt'), '/a/b.txt'); 16 expect(path.absolute('/a/b.txt'), '/a/b.txt');
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 test('given relative path', () { 291 test('given relative path', () {
294 // The path is considered relative to the root, so it basically just 292 // The path is considered relative to the root, so it basically just
295 // normalizes. 293 // normalizes.
296 expect(builder.relative(''), '.'); 294 expect(builder.relative(''), '.');
297 expect(builder.relative('.'), '.'); 295 expect(builder.relative('.'), '.');
298 expect(builder.relative('a'), 'a'); 296 expect(builder.relative('a'), 'a');
299 expect(builder.relative('a/b.txt'), 'a/b.txt'); 297 expect(builder.relative('a/b.txt'), 'a/b.txt');
300 expect(builder.relative('../a/b.txt'), '../a/b.txt'); 298 expect(builder.relative('../a/b.txt'), '../a/b.txt');
301 expect(builder.relative('a/./b/../c.txt'), 'a/c.txt'); 299 expect(builder.relative('a/./b/../c.txt'), 'a/c.txt');
302 }); 300 });
301
302 // Regression
303 test('from root-only path', () {
304 expect(builder.relative('/', from: '/'), '.');
305 expect(builder.relative('/root/path', from: '/'), 'root/path');
306 });
303 }); 307 });
304 308
305 group('from relative root', () { 309 group('from relative root', () {
306 var r = new path.Builder(style: path.Style.posix, root: 'foo/bar'); 310 var r = new path.Builder(style: path.Style.posix, root: 'foo/bar');
307 311
308 test('given absolute path', () { 312 test('given absolute path', () {
309 expect(r.relative('/'), equals('/')); 313 expect(r.relative('/'), equals('/'));
310 expect(r.relative('/a/b'), equals('/a/b')); 314 expect(r.relative('/a/b'), equals('/a/b'));
311 }); 315 });
312 316
(...skipping 24 matching lines...) Expand all
337 }); 341 });
338 342
339 test('with a root parameter and a relative root', () { 343 test('with a root parameter and a relative root', () {
340 var r = new path.Builder(style: path.Style.posix, root: 'relative/root'); 344 var r = new path.Builder(style: path.Style.posix, root: 'relative/root');
341 expect(r.relative('/foo/bar/baz', from: '/foo/bar'), equals('baz')); 345 expect(r.relative('/foo/bar/baz', from: '/foo/bar'), equals('baz'));
342 expect(() => r.relative('..', from: '/foo/bar'), throwsArgumentError); 346 expect(() => r.relative('..', from: '/foo/bar'), throwsArgumentError);
343 expect(r.relative('/foo/bar/baz', from: 'foo/bar'), 347 expect(r.relative('/foo/bar/baz', from: 'foo/bar'),
344 equals('/foo/bar/baz')); 348 equals('/foo/bar/baz'));
345 expect(r.relative('..', from: 'foo/bar'), equals('../../..')); 349 expect(r.relative('..', from: 'foo/bar'), equals('../../..'));
346 }); 350 });
351
352 test('from a . root', () {
353 var r = new path.Builder(style: path.Style.posix, root: '.');
354 expect(r.relative('/foo/bar/baz'), equals('/foo/bar/baz'));
355 expect(r.relative('foo/bar/baz'), equals('foo/bar/baz'));
356 });
347 }); 357 });
348 358
349 group('resolve', () { 359 group('resolve', () {
350 test('allows up to seven parts', () { 360 test('allows up to seven parts', () {
351 expect(builder.resolve('a'), '/root/path/a'); 361 expect(builder.resolve('a'), '/root/path/a');
352 expect(builder.resolve('a', 'b'), '/root/path/a/b'); 362 expect(builder.resolve('a', 'b'), '/root/path/a/b');
353 expect(builder.resolve('a', 'b', 'c'), '/root/path/a/b/c'); 363 expect(builder.resolve('a', 'b', 'c'), '/root/path/a/b/c');
354 expect(builder.resolve('a', 'b', 'c', 'd'), '/root/path/a/b/c/d'); 364 expect(builder.resolve('a', 'b', 'c', 'd'), '/root/path/a/b/c/d');
355 expect(builder.resolve('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e'); 365 expect(builder.resolve('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e');
356 expect(builder.resolve('a', 'b', 'c', 'd', 'e', 'f'), 366 expect(builder.resolve('a', 'b', 'c', 'd', 'e', 'f'),
(...skipping 26 matching lines...) Expand all
383 expect(builder.withoutExtension('a/.'), 'a/.'); 393 expect(builder.withoutExtension('a/.'), 'a/.');
384 expect(builder.withoutExtension('a/.b'), 'a/.b'); 394 expect(builder.withoutExtension('a/.b'), 'a/.b');
385 expect(builder.withoutExtension('a.b/c'), 'a.b/c'); 395 expect(builder.withoutExtension('a.b/c'), 'a.b/c');
386 expect(builder.withoutExtension(r'a.b\c'), r'a'); 396 expect(builder.withoutExtension(r'a.b\c'), r'a');
387 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c'); 397 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c');
388 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c'); 398 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c');
389 expect(builder.withoutExtension('a/b.c/'), 'a/b/'); 399 expect(builder.withoutExtension('a/b.c/'), 'a/b/');
390 expect(builder.withoutExtension('a/b.c//'), 'a/b//'); 400 expect(builder.withoutExtension('a/b.c//'), 'a/b//');
391 }); 401 });
392 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698