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