summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/versions.py3
-rw-r--r--lib/spack/spack/version.py4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/spack/spack/test/versions.py b/lib/spack/spack/test/versions.py
index ce222c5ea2..a33f7e08f7 100644
--- a/lib/spack/spack/test/versions.py
+++ b/lib/spack/spack/test/versions.py
@@ -373,6 +373,9 @@ def test_intersect_with_containment():
check_intersection('1.6:1.6.5', ':1.6.5', '1.6')
check_intersection('1.6:1.6.5', '1.6', ':1.6.5')
+ check_intersection('11.2', '11', '11.2')
+ check_intersection('11.2', '11.2', '11')
+
def test_union_with_containment():
check_union(':1.6', '1.6.5', ':1.6')
diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py
index 321a03efc7..82c0afd53e 100644
--- a/lib/spack/spack/version.py
+++ b/lib/spack/spack/version.py
@@ -372,8 +372,10 @@ class Version(object):
@coerced
def intersection(self, other):
- if self == other:
+ if self in other: # also covers `self == other`
return self
+ elif other in self:
+ return other
else:
return VersionList()