Skip to content

Commit dff7bc6

Browse files
jhischwern
authored andcommitted
import Set-Scalar 1.11 from CPAN
git-cpan-module: Set-Scalar git-cpan-version: 1.11 git-cpan-authorid: JHI git-cpan-file: authors/id/J/JH/JHI/Set-Scalar-1.11.tar.gz
1 parent b23b506 commit dff7bc6

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Wed Oct 10 17:31:12 2001 Jarkko Hietaniemi <jhi@alpha.hut.fi>
2+
3+
* In boolean contexts the string representation of sets
4+
is not the best possible one, reported by Dan Berger.
5+
Now the size of the set is returned in boolean contexts.
6+
7+
* Released as 1.11.
8+
19
Fri Aug 3 15:42:38 2001 Jarkko Hietaniemi <jhi@alpha.hut.fi>
210

311
* 1.10: Added COPYRIGHT and LICENSE.

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lib/Set/Scalar/Virtual.pm
1212
README
1313
t/basic.t
1414
t/basic_overload.t
15+
t/boolean.t
1516
t/compare.t
1617
t/difference.t
1718
t/intersection.t

lib/Set/Scalar.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local $^W = 1;
55

66
use vars qw($VERSION @ISA);
77

8-
$VERSION = '1.10';
8+
$VERSION = '1.11';
99

1010
@ISA = qw(Set::Scalar::Real Set::Scalar::Null Set::Scalar::Base);
1111

@@ -168,6 +168,13 @@ These methods have operator overloads:
168168
169169
$cmp = $s <=> $t;
170170
171+
In Boolean contexts such as
172+
173+
if ($set) { ... }
174+
175+
the size of the C<$set> is tested, so empty sets test as false,
176+
and non-empty sets as true.
177+
171178
=head1 AUTHOR
172179
173180
Jarkko Hietaniemi <jhi@iki.fi>

lib/Set/Scalar/Base.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ use overload
3232
'<' => \&is_proper_subset,
3333
'>' => \&is_proper_superset,
3434
'<=' => \&is_subset,
35-
'>=' => \&is_superset;
35+
'>=' => \&is_superset,
36+
'bool' => \&size;
3637

3738
use constant OVERLOAD_BINARY_2ND_ARG => 1;
3839
use constant OVERLOAD_BINARY_REVERSED => 2;

t/boolean.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use Set::Scalar;
2+
3+
print "1..2\n";
4+
5+
my @a = qw(One Two Three);
6+
my @b = qw(Four Five Six);
7+
8+
my $ssa = Set::Scalar->new(@a);
9+
my $ssb = Set::Scalar->new(@b);
10+
11+
print "not " unless $ssa;
12+
print "ok 1\n";
13+
14+
print "not " if $ssa->intersection($ssb);
15+
print "ok 2\n";
16+

0 commit comments

Comments
 (0)