| 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 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 expect(context.isWithin('foo/bar', 'foo/bar/baz'), isTrue); | 414 expect(context.isWithin('foo/bar', 'foo/bar/baz'), isTrue); |
| 415 expect(context.isWithin('foo/bar', 'foo/baz'), isFalse); | 415 expect(context.isWithin('foo/bar', 'foo/baz'), isFalse); |
| 416 expect(context.isWithin('foo/bar', '../path/foo/bar/baz'), isTrue); | 416 expect(context.isWithin('foo/bar', '../path/foo/bar/baz'), isTrue); |
| 417 expect(context.isWithin('/', '/foo/bar'), isTrue); | 417 expect(context.isWithin('/', '/foo/bar'), isTrue); |
| 418 expect(context.isWithin('baz', '/root/path/baz/bang'), isTrue); | 418 expect(context.isWithin('baz', '/root/path/baz/bang'), isTrue); |
| 419 expect(context.isWithin('baz', '/root/path/bang/baz'), isFalse); | 419 expect(context.isWithin('baz', '/root/path/bang/baz'), isFalse); |
| 420 }); | 420 }); |
| 421 | 421 |
| 422 test('from a relative root', () { | 422 test('from a relative root', () { |
| 423 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); | 423 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); |
| 424 expect(context.isWithin('.', 'a/b/c'), isTrue); | 424 expect(r.isWithin('.', 'a/b/c'), isTrue); |
| 425 expect(context.isWithin('.', '../a/b/c'), isFalse); | 425 expect(r.isWithin('.', '../a/b/c'), isFalse); |
| 426 expect(context.isWithin('.', '../../a/foo/b/c'), isFalse); | 426 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse); |
| 427 expect(context.isWithin('/', '/baz/bang'), isTrue); | 427 expect(r.isWithin('/', '/baz/bang'), isTrue); |
| 428 expect(context.isWithin('.', '/baz/bang'), isFalse); | 428 expect(r.isWithin('.', '/baz/bang'), isFalse); |
| 429 }); | 429 }); |
| 430 }); | 430 }); |
| 431 | 431 |
| 432 group('absolute', () { | 432 group('absolute', () { |
| 433 test('allows up to seven parts', () { | 433 test('allows up to seven parts', () { |
| 434 expect(context.absolute('a'), '/root/path/a'); | 434 expect(context.absolute('a'), '/root/path/a'); |
| 435 expect(context.absolute('a', 'b'), '/root/path/a/b'); | 435 expect(context.absolute('a', 'b'), '/root/path/a/b'); |
| 436 expect(context.absolute('a', 'b', 'c'), '/root/path/a/b/c'); | 436 expect(context.absolute('a', 'b', 'c'), '/root/path/a/b/c'); |
| 437 expect(context.absolute('a', 'b', 'c', 'd'), '/root/path/a/b/c/d'); | 437 expect(context.absolute('a', 'b', 'c', 'd'), '/root/path/a/b/c/d'); |
| 438 expect(context.absolute('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e'); | 438 expect(context.absolute('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e'); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 528 |
| 529 test('with a root-relative URI', () { | 529 test('with a root-relative URI', () { |
| 530 expect(context.prettyUri('/a/b'), '/a/b'); | 530 expect(context.prettyUri('/a/b'), '/a/b'); |
| 531 }); | 531 }); |
| 532 | 532 |
| 533 test('with a Uri object', () { | 533 test('with a Uri object', () { |
| 534 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); | 534 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); |
| 535 }); | 535 }); |
| 536 }); | 536 }); |
| 537 } | 537 } |
| OLD | NEW |