Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Path-Class CPAN distribution.

Maintainer(s)' notes

I prefer that bugs & patches are filed on GitHub rather than on RT: https://github.com/kenahoo/Path-Class/issues. Thanks.

Report information
The Basics
Id: 24071
Status: resolved
Priority: 0/
Queue: Path-Class

People
Owner: Nobody in particular
Requestors: CLKAO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



The following test fails on win32. --- #!perl use Test::More tests => 1; use Path::Class; my ($me, $other) = map { Path::Class::Dir->new_foreign('Unix', $_) } qw(/ /A); ok($me->subsumes($other));
Subject: subsumes doesn't respect foreign path::class objects
attached is the patch fixing this issue.
只在 Path-Class-0.15 存在:blib 只在 Path-Class-0.15 存在:cover_db diff -ru Path-Class-0.15.orig/lib/Path/Class/Dir.pm Path-Class-0.15/lib/Path/Class/Dir.pm --- Path-Class-0.15.orig/lib/Path/Class/Dir.pm 2006-12-24 20:19:22.000000000 +0800 +++ Path-Class-0.15/lib/Path/Class/Dir.pm 2006-12-24 20:20:32.000000000 +0800 @@ -195,7 +195,7 @@ my ($self, $other) = @_; die "No second entity given to subsumes()" unless $other; - $other = ref($self)->new($other) unless UNIVERSAL::isa($other, __PACKAGE__); + $other = $self->new($other) unless UNIVERSAL::isa($other, __PACKAGE__); $other = $other->dir unless $other->is_dir; if ($self->is_absolute) { @@ -212,7 +212,7 @@ } # The root dir subsumes everything - return 1 if $self eq ref($self)->new(''); + return 1 if $self eq $self->new(''); my $i = 0; while ($i <= $#{ $self->{dirs} }) { 只在 Path-Class-0.15 存在:Makefile 只在 Path-Class-0.15 存在:pm_to_blib
From: KWILLIAMS [...] cpan.org
Thanks for the patch. I actually had to modify it a bit to also get Win32 foreign paths to work correctly on Unix: Index: Changes ========================================================= ========== RCS file: /Users/ken/src/CVS-repository/modules/Path-Class/Changes,v retrieving revision 1.53 diff -u -r1.53 Changes --- Changes 27 Nov 2006 01:22:41 -0000 1.53 +++ Changes 25 Dec 2006 02:16:50 -0000 @@ -8,6 +8,9 @@ - Fixed a typo in the synopsis for Path::Class::Dir - 'MacOS' should have been 'Mac' in the example for foreign_dir(). [Chris Dolan] + - subsumes() was not respecting the 'foreign'-ness of its arguments, + now it does. [Chia-liang Kao] + 0.15 Thu Dec 15 20:11:38 CST 2005 - Fixed an important edge case in subsumes() - subsumes('/', '/foo') Index: lib/Path/Class/Dir.pm ========================================================= ========== RCS file: /Users/ken/src/CVS-repository/modules/Path-Class/lib/Path/Class/Dir.pm,v retrieving revision 1.31 diff -u -r1.31 Dir.pm --- lib/Path/Class/Dir.pm 27 Nov 2006 01:22:41 -0000 1.31 +++ lib/Path/Class/Dir.pm 25 Dec 2006 02:13:17 -0000 @@ -195,7 +195,7 @@ my ($self, $other) = @_; die "No second entity given to subsumes()" unless $other; - $other = ref($self)->new($other) unless UNIVERSAL::isa($other, __PACKAGE__); + $other = $self->new($other) unless UNIVERSAL::isa($other, __PACKAGE__); $other = $other->dir unless $other->is_dir; if ($self->is_absolute) { @@ -211,8 +211,9 @@ return 0 unless $other->volume eq $self->volume; } - # The root dir subsumes everything - return 1 if $self eq ref($self)->new(''); + # The root dir subsumes everything (but ignore the volume because + # we've already checked that) + return 1 if "@{$self->{dirs}}" eq "@{$self->new('')->{dirs}}"; my $i = 0; while ($i <= $#{ $self->{dirs} }) { Index: t/02-foreign.t ========================================================= ========== RCS file: /Users/ken/src/CVS-repository/modules/Path-Class/t/02-foreign.t,v retrieving revision 1.5 diff -u -r1.5 02-foreign.t --- t/02-foreign.t 30 May 2005 04:11:59 -0000 1.5 +++ t/02-foreign.t 25 Dec 2006 02:15:08 -0000 @@ -1,6 +1,6 @@ use Test; use strict; -BEGIN { plan tests => 23 }; +BEGIN { plan tests => 29 }; use Path::Class qw(file dir foreign_file foreign_dir); ok(1); @@ -36,6 +36,15 @@ skip "skip Can't test VMS code on other platforms", 1; } +{ + # subsumes() should respect foreignness + my ($me, $other) = map { Path::Class::Dir->new_foreign('Unix', $_) } qw(/ /Foo); + ok($me->subsumes($other)); + + ($me, $other) = map { Path::Class::Dir->new_foreign('Win32', $_) } qw(C:\ C:\Foo); + ok($me->subsumes($other)); +} + # Note that "\\" and '\\' are each a single backslash $dir = foreign_dir('Win32', 'C:\\'); ok $dir, 'C:\\';