ref: refs/heads/master
commit 998cfedd820963754b0d1f1ac9928d3479a266c5
Author: Klaus Kämpf
Date: Tue Mar 17 21:14:09 2009 +0100
add 'equality' operator for Pool
And add testcases for Ruby, Python, Perl.
---
bindings/perl/tests/solvables.pl | 4 ++++
bindings/pool.i | 32 ++++++++++++++++++++++++++++++++
bindings/python/tests/solvable.py | 4 ++++
bindings/ruby/tests/solvable.rb | 7 +++++++
4 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/bindings/perl/tests/solvables.pl b/bindings/perl/tests/solvables.pl
index 31d6d7f..c4d3d55 100644
--- a/bindings/perl/tests/solvables.pl
+++ b/bindings/perl/tests/solvables.pl
@@ -29,6 +29,10 @@ foreach my $solvable ($pool->solvables()) {
$poolcount++;
}
+foreach my $solvable ($pool->solvables()) {
+ $solvable->pool() == $pool || die
+}
+
my $repocount = 0;
foreach my $solvable ($repo->solvables()) {
next if not defined $solvable;
diff --git a/bindings/pool.i b/bindings/pool.i
index 248f6a5..07c52e5 100644
--- a/bindings/pool.i
+++ b/bindings/pool.i
@@ -246,6 +246,38 @@ typedef struct _Pool {} Pool;
return xsolvable_new($self, SYSTEMSOLVABLE);
}
+ /*
+ * Pool equality
+ */
+
+#if defined(SWIGPERL)
+ /*
+ * :nodoc:
+ */
+ int __eq__( Pool *pool )
+#endif
+#if defined(SWIGRUBY)
+ %rename("==") equal;
+ /*
+ * Equality operator
+ *
+ */
+ int equal( Pool *pool )
+#endif
+
+#if defined(SWIGPYTHON)
+ /*
+ * :nodoc:
+ * Python treats 'eq' and 'ne' distinct.
+ */
+ int __ne__( Pool *pool )
+ { return $self != pool; }
+ int __eq__( Pool *pool )
+#endif
+ { return $self == pool; } /* common implementation */
+
+
+
/**************************
* Repo management
*/
diff --git a/bindings/python/tests/solvable.py b/bindings/python/tests/solvable.py
index def7350..d623760 100644
--- a/bindings/python/tests/solvable.py
+++ b/bindings/python/tests/solvable.py
@@ -60,6 +60,10 @@ class TestSequenceFunctions(unittest.TestCase):
solv = list(self.pool.providers( 'product:openSUSE' ))
assert len(solv) == 1, len(solv)
+ def test_iterate_pool(self):
+ for s in self.pool:
+ assert s.pool() == self.pool
+
def test_creation(self):
repo = self.pool.create_repo( 'test' )
assert repo
diff --git a/bindings/ruby/tests/solvable.rb b/bindings/ruby/tests/solvable.rb
index 8c06d9d..f73addf 100644
--- a/bindings/ruby/tests/solvable.rb
+++ b/bindings/ruby/tests/solvable.rb
@@ -43,6 +43,13 @@ class SolvableTest < Test::Unit::TestCase
break if i > 5
}
end
+
+ def test_iterate_pool
+ @pool.each do |s|
+ assert s.pool == @pool
+ end
+ end
+
def test_creation
repo = @pool.create_repo( 'test' )
assert repo
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org