branch: elpa/parseclj
commit 2d10ef3742a154383ba0a312eabf123dd909931f
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
Travis CI / test setup
---
.travis.yml | 9 +++++++++
bin/run-tests | 2 ++
clj-parse.el | 28 ++++++++++++++++++----------
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..434e4e6d0e
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,9 @@
+language: emacs-lisp
+before_install:
+ - sudo add-apt-repository -y ppa:ubuntu-elisp
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq emacs-snapshot
+
+script:
+ - make cask
+ - make test
diff --git a/bin/run-tests b/bin/run-tests
new file mode 100755
index 0000000000..2171b799f7
--- /dev/null
+++ b/bin/run-tests
@@ -0,0 +1,2 @@
+#!/bin/sh
+emacs -batch -l ert -l clj-parse.el -f ert-run-tests-batch-and-exit
\ No newline at end of file
diff --git a/clj-parse.el b/clj-parse.el
index d7bb094690..631df0d663 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -4,7 +4,7 @@
;; Author: Arne Brasseur <[email protected]>
;; Keywords: lisp
-;; Package-Requires: ((dash "") (let-alist ""))
+;; Package-Requires: ((let-alist ""))
;; This program is free software; you can redistribute it and/or modify it
under
;; the terms of the Mozilla Public License Version 2.0
@@ -23,6 +23,12 @@
;;; Code:
+;; for (case ...)
+(eval-when-compile (require 'cl))
+
+;; Before emacs 25.1 it's an ELPA package
+(require 'let-alist)
+
(defun clj-parse ()
(clj-parse* 'clj-parse-elisp-reducer))
@@ -36,8 +42,8 @@
(let ((stack nil)
(token (clj-lex-next)))
(while (not (eq (alist-get 'type token) :eof))
- ;;(prin1 (alist-get 'type token))
- (print token)
+ ;; (prin1 (alist-get 'type token))
+ ;; (print token)
;; (print stack)
(let-alist token
(case .type
@@ -52,7 +58,7 @@
(while (not (and (listp (car stack)) (eq (alist-get 'type (car
stack)) :lparen)))
(push (pop stack) list))
(pop stack) ;; :lparen
- (print list)
+ ;; (print list)
(push (funcall reducer :list list) stack)))))
(setq token (clj-lex-next)))
stack))
@@ -70,10 +76,11 @@
(defun clj-lex-number ()
(let* ((pos (point)))
- (while (or (<= ?0 (char-after (point)) ?9)
- (eq (char-after (point)) ?.)
- (eq (char-after (point)) ?M)
- (eq (char-after (point)) ?r))
+ (while (and (char-after (point))
+ (or (<= ?0 (char-after (point)) ?9)
+ (eq (char-after (point)) ?.)
+ (eq (char-after (point)) ?M)
+ (eq (char-after (point)) ?r)))
(right-char))
(let* ((num-str (buffer-substring-no-properties pos (point))))
;; TODO handle radix, bignuM
@@ -112,12 +119,12 @@
(with-temp-buffer
(insert "()")
(goto-char 1)
- (should (equal (clj-parse) '())))
+ (should (equal (clj-parse) '(()))))
(with-temp-buffer
(insert "(1)")
(goto-char 1)
- (should (equal (clj-parse) '(1)))))
+ (should (equal (clj-parse) '((1))))))
(ert-deftest clj-lex-next-test ()
(with-temp-buffer
@@ -144,3 +151,4 @@
(provide 'clj-parse)
;;; clj-parse.el ends here
+123