| 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:test/test.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'; |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 var context = | 13 var context = |
| 14 new path.Context(style: path.Style.posix, current: '/root/path'); | 14 new path.Context(style: path.Style.posix, current: '/root/path'); |
| 15 | 15 |
| 16 test('separator', () { | 16 test('separator', () { |
| 17 expect(context.separator, '/'); | 17 expect(context.separator, '/'); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 test('simple cases', () { | 412 test('simple cases', () { |
| 413 expect(context.isWithin('foo/bar', 'foo/bar'), isFalse); | 413 expect(context.isWithin('foo/bar', 'foo/bar'), isFalse); |
| 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('complex cases', () { |
| 423 expect(context.isWithin('foo/./bar', 'foo/bar/baz'), isTrue); |
| 424 expect(context.isWithin('foo//bar', 'foo/bar/baz'), isTrue); |
| 425 expect(context.isWithin('foo/qux/../bar', 'foo/bar/baz'), isTrue); |
| 426 expect(context.isWithin('foo/bar', 'foo/bar/baz/../..'), isFalse); |
| 427 expect(context.isWithin('foo/bar', 'foo/bar///'), isFalse); |
| 428 expect(context.isWithin('foo/.bar', 'foo/.bar/baz'), isTrue); |
| 429 expect(context.isWithin('foo/./bar', 'foo/.bar/baz'), isFalse); |
| 430 expect(context.isWithin('foo/..bar', 'foo/..bar/baz'), isTrue); |
| 431 expect(context.isWithin('foo/bar', 'foo/bar/baz/..'), isFalse); |
| 432 expect(context.isWithin('foo/bar', 'foo/bar/baz/../qux'), isTrue); |
| 433 }); |
| 434 |
| 422 test('from a relative root', () { | 435 test('from a relative root', () { |
| 423 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); | 436 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); |
| 424 expect(r.isWithin('.', 'a/b/c'), isTrue); | 437 expect(r.isWithin('.', 'a/b/c'), isTrue); |
| 425 expect(r.isWithin('.', '../a/b/c'), isFalse); | 438 expect(r.isWithin('.', '../a/b/c'), isFalse); |
| 426 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse); | 439 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse); |
| 427 expect(r.isWithin('/', '/baz/bang'), isTrue); | 440 expect(r.isWithin('/', '/baz/bang'), isTrue); |
| 428 expect(r.isWithin('.', '/baz/bang'), isFalse); | 441 expect(r.isWithin('.', '/baz/bang'), isFalse); |
| 429 }); | 442 }); |
| 430 }); | 443 }); |
| 431 | 444 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 542 |
| 530 test('with a root-relative URI', () { | 543 test('with a root-relative URI', () { |
| 531 expect(context.prettyUri('/a/b'), '/a/b'); | 544 expect(context.prettyUri('/a/b'), '/a/b'); |
| 532 }); | 545 }); |
| 533 | 546 |
| 534 test('with a Uri object', () { | 547 test('with a Uri object', () { |
| 535 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); | 548 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); |
| 536 }); | 549 }); |
| 537 }); | 550 }); |
| 538 } | 551 } |
| OLD | NEW |