emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 5fd179d 4/6: Add load-relative and cl-lib dependencies. Ad


From: Rocky Bernstein
Subject: [elpa] master 5fd179d 4/6: Add load-relative and cl-lib dependencies. Add test file.
Date: Sun, 19 May 2019 22:00:02 -0400 (EDT)

branch: master
commit 5fd179d0045ee95784beafe5799f69c9a92bd6da
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Add load-relative and cl-lib dependencies. Add test file.
---
 realgud-ipdb.el |  2 +-
 test/gcd.py     | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/realgud-ipdb.el b/realgud-ipdb.el
index 1d60553..120eb18 100644
--- a/realgud-ipdb.el
+++ b/realgud-ipdb.el
@@ -2,7 +2,7 @@
 
 ;; Author: Rocky Bernstein
 ;; Version: 1.0.0
-;; Package-Requires: ((realgud "1.4.5") (emacs "24"))
+;; Package-Requires: ((realgud "1.4.5") (load-relative "1.2") (cl-lib "0.5") 
(emacs "24"))
 ;; URL: http://github.com/rocky/realgud-ipdb
 ;; Compatibility: GNU Emacs 24.x
 
diff --git a/test/gcd.py b/test/gcd.py
new file mode 100755
index 0000000..e64f284
--- /dev/null
+++ b/test/gcd.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+"""Greatest Common Divisor
+
+Some characterstics of this program used for testing check_args() does
+not have a 'return' statement.
+
+check_args() raises an uncaught exception when given the wrong number
+of parameters.
+
+"""
+import sys
+
+def check_args():
+    if len(sys.argv) != 3:
+        # Rather than use sys.exit let's just raise an error
+        raise Exception("Need to give two numbers")
+    for i in range(2):
+        try:
+            sys.argv[i+1] = int(sys.argv[i+1])
+        except ValueError:
+            print("** Expecting an integer, got: %s" % repr(sys.argv[i]))
+            sys.exit(2)
+
+def gcd(a,b):
+    """ GCD. We assume positive numbers"""
+
+    # Make: a <= b
+    if a > b:
+       (a, b) = (b, a)
+
+    if a <= 0:
+        return None
+    if a == 1 or b-a == 0:
+        return a
+    return gcd(b-a, a)
+
+if __name__=='__main__':
+    check_args()
+
+    (a, b) = sys.argv[1:3]
+    print("The GCD of %d and %d is %d" % (a, b, gcd(a, b)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]