Skip to content
Snippets Groups Projects
Commit ca1d3aa1 authored by David Byers's avatar David Byers
Browse files

Packaging cleanup

parent 534c08bd
No related branches found
No related tags found
No related merge requests found
2020-07-22 David Byers <david.byers@liu.se> 2020-07-22 David Byers <david.byers@liu.se>
Fix test cases:
* test/olctest.el: Use keyword args in test cases.
Clean up for melpa:
* olc.el: Use #' instead of ' in a few places. Enable lexical
binding.
Rename some functions: Rename some functions:
* olc.el (olc-shorten-compound): Renamed from olc-shorten-geo to * olc.el (olc-shorten-compound): Renamed from olc-shorten-geo to
better match Google's terminology in their plus codes api. better match Google's terminology in their plus codes api.
......
;; -*-coding: utf-8;-*- ;;; olc.el --- Open location code library -*-lexical-binding: t;-*-
;;; olc.el --- Open location code library
;; Copyright (C) 2020 David Byers ;; Copyright (C) 2020 David Byers
;; ;;
...@@ -350,7 +348,7 @@ values cannot (legally) be encoded to the selected length." ...@@ -350,7 +348,7 @@ values cannot (legally) be encoded to the selected length."
(nconc (make-list (max 0 (- 8 len)) ?0) (nconc (make-list (max 0 (- 8 len)) ?0)
(when truncate (list ?+))))) (when truncate (list ?+)))))
(apply 'string code))) (apply #'string code)))
(defun olc-decode (code) (defun olc-decode (code)
...@@ -476,7 +474,7 @@ faster. ...@@ -476,7 +474,7 @@ faster.
(lon . ,(olc-area-lon area)) (lon . ,(olc-area-lon area))
(zoom . ,zoom) (zoom . ,zoom)
(format . "json")) (format . "json"))
:parser 'json-read :parser #'json-read
:sync t))) :sync t)))
(tmp-code (tmp-code
(when resp (when resp
...@@ -576,7 +574,7 @@ full open location code." ...@@ -576,7 +574,7 @@ full open location code."
:params `((q . ,reference) :params `((q . ,reference)
(format . "json") (format . "json")
(limit . 1)) (limit . 1))
:parser 'json-read :parser #'json-read
:sync t))) :sync t)))
(when (eq 200 (request-response-status-code resp)) (when (eq 200 (request-response-status-code resp))
(let ((data (elt (request-response-data resp) 0))) (let ((data (elt (request-response-data resp) 0)))
......
;;;; -*-coding: utf-8;-*- ;;;; -*-coding: utf-8; lexical-binding: t;-*-
;;;; ;;;;
;;;; Copyright (C) 2020 David Byers ;;;; Copyright (C) 2020 David Byers
;;;; ;;;;
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
(olctest-run-csv ("encoding.csv" case) (olctest-run-csv ("encoding.csv" case)
(let ((code (olc-encode (alist-get 'latitude case) (let ((code (olc-encode (alist-get 'latitude case)
(alist-get 'longitude case) (alist-get 'longitude case)
(alist-get 'length case)))) :len (alist-get 'length case))))
(unless (string= code (alist-get 'expected case)) (unless (string= code (alist-get 'expected case))
(olctest-record-failure case (alist-get 'expected case) code))))) (olctest-record-failure case (alist-get 'expected case) code)))))
...@@ -190,14 +190,14 @@ ...@@ -190,14 +190,14 @@
(lon (alist-get 'lon case)) (lon (alist-get 'lon case))
(len (alist-get 'len case)) (len (alist-get 'len case))
(shortcode (alist-get 'exp case)) (shortcode (alist-get 'exp case))
(actual (olc-shorten fullcode lat lon len))) (actual (olc-shorten fullcode lat lon :limit len)))
(unless (string= actual shortcode) (unless (string= actual shortcode)
(olctest-record-failure case shortcode actual))))) (olctest-record-failure case shortcode actual)))))
(defun olctest-run-all () (defun olctest-run-all ()
"Run all tests." "Run all tests."
(and (olctest-decode)q (and (olctest-decode)
(olctest-encode) (olctest-encode)
(olctest-shortcodes) (olctest-shortcodes)
(olctest-validity) (olctest-validity)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment