================
@@ -322,8 +342,34 @@ def getDwarfVersion():
     return "0"
 
 
+def isExpectedVersion(
+    actual_version: str, required_version: str, operator: str
+) -> bool:
+    """Returns True if actual_version matches the required_version given the 
operator.
+    Any operator other than the following defaults to an equality test:
+        '>', '>=', "=>", '<', '<=', '=<', '!=', "!" or 'not'
+
+    Example:
+      - actual_version='1.2.0', required_version='1.0.0', operator='>=' 
returns True
+    """
+    actual_version_ = version.parse(actual_version)
+    required_version_ = version.parse(required_version)
+
+    if operator == ">":
+        return actual_version_ > required_version_
+    if operator == ">=" or operator == "=>":
+        return actual_version_ >= required_version_
+    if operator == "<":
+        return actual_version_ < required_version_
+    if operator == "<=" or operator == "=<":
+        return actual_version_ <= required_version_
+    if operator == "!=" or operator == "!" or operator == "not":
+        return actual_version not in required_version
+    return actual_version in required_version
+
+
 def expectedCompilerVersion(compiler_version):
-    """Returns True iff compiler_version[1] matches the current compiler 
version.
+    """Returns True if compiler_version[1] matches the current compiler 
version.
----------------
DavidSpickett wrote:

iff "if and only if" is technically fine but I'm fine changing it given that 
"if x then y" in a programming sense is using the iff meaning anyway.

https://github.com/llvm/llvm-project/pull/172838
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to