aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-13 02:07:43 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-13 02:07:43 +0000
commit6355c676f48506ecb730acb200085f7b211e08c4 (patch)
tree8173b74b21d1445997159adc9a5cca261d9c8892 /test
parent4cf7825918bfb60e2d1d1ce1dd342665f1161fa2 (diff)
parentcfd909e8524c37ac3bc94bec56c4e577b2c33d2d (diff)
Merge branch 'master' into sx-question-mode
Diffstat (limited to 'test')
-rw-r--r--test/tests.el84
1 files changed, 41 insertions, 43 deletions
diff --git a/test/tests.el b/test/tests.el
index 2864428..6a48257 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -1,41 +1,49 @@
-(defun -stack--nuke ()
+(defun -sx--nuke ()
(interactive)
(mapatoms
(lambda (symbol)
- (if (string-prefix-p "stack-" (symbol-name symbol))
+ (if (string-prefix-p "sx-" (symbol-name symbol))
(unintern symbol)))))
;;; Tests
-(defvar stack-test-data-dir
+(defvar sx-test-data-dir
(expand-file-name
"data-samples/"
- (or (file-name-directory load-file-name) "./"))
- "")
+ (or (file-name-directory load-file-name) "./")))
-(defun stack-test-sample-data (method &optional directory)
+(defun sx-test-sample-data (method &optional directory)
(let ((file (concat (when directory (concat directory "/"))
- stack-test-data-dir
+ sx-test-data-dir
method ".el")))
(when (file-exists-p file)
(with-temp-buffer
(insert-file-contents file)
(read (buffer-string))))))
+(defmacro line-should-match (regexp)
+ ""
+ `(let ((line (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
+ (message "Line here is: %S" line)
+ (should (string-match ,regexp line))))
+
(setq
sx-request-remaining-api-requests-message-threshold 50000
debug-on-error t
sx-request-silent-p nil
user-emacs-directory "."
- stack-test-data-questions
- (stack-test-sample-data "questions")
- stack-test-data-sites
- (stack-test-sample-data "sites"))
+ sx-test-data-questions
+ (sx-test-sample-data "questions")
+ sx-test-data-sites
+ (sx-test-sample-data "sites"))
(setq package-user-dir
(expand-file-name (format "../../.cask/%s/elpa" emacs-version)
- stack-test-data-dir))
+ sx-test-data-dir))
(package-initialize)
+
(require 'cl-lib)
(require 'sx)
(require 'sx-question)
@@ -55,7 +63,7 @@
(sx-request-make "questions" '(()))))
(ert-deftest test-tree-filter ()
- "`stack-core-filter-data'"
+ "`sx-core-filter-data'"
;; flat
(should
(equal
@@ -89,35 +97,9 @@
((1 . alpha) (2 . beta))]
'(1 2 3)))))
-(ert-deftest test-filters ()
- (let ((stack-cache-directory (make-temp-file "stack-test" t)))
- (should-error (sx-filter-store "names must be symbols"
- "this is a filter"))
- ;; basic use
- (should (equal '((test . "filter"))
- (sx-filter-store 'test "filter")))
- ;; aggregation
- (should (equal '((test2 . "filter2") (test . "filter"))
- (sx-filter-store 'test2 "filter2")))
- ;; mutation
- (should (equal '((test2 . "filter2") (test . "filter-test"))
- (sx-filter-store 'test "filter-test")))
- ;; clean up (note: the file should exist)
- (delete-file
- (sx-cache-get-file-name
- sx-filter-cache-file))))
-
-(defmacro line-should-match (regexp)
- ""
- `(let ((line (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position))))
- (message "Line here is: %S" line)
- (should (string-match ,regexp line))))
-
(ert-deftest question-list-display ()
(cl-letf (((symbol-function #'sx-request-make)
- (lambda (&rest _) stack-test-data-questions)))
+ (lambda (&rest _) sx-test-data-questions)))
(list-questions nil)
(switch-to-buffer "*question-list*")
(goto-char (point-min))
@@ -127,10 +109,26 @@
(sx-question-list-next 5)
(line-should-match
"^\\s-+0\\s-+1\\s-+Babel doesn&#39;t wrap results in verbatim [ 0-9]+[ydhms] ago\\s-+\\[org-mode\\]")
- ;; ;; Use this when we have a real stack-question buffer.
- ;; (call-interactively 'stack-question-list-display-question)
- ;; (should (equal (buffer-name) "*stack-question*"))
+ ;; ;; Use this when we have a real sx-question buffer.
+ ;; (call-interactively 'sx-question-list-display-question)
+ ;; (should (equal (buffer-name) "*sx-question*"))
(switch-to-buffer "*question-list*")
(sx-question-list-previous 4)
(line-should-match
"^\\s-+2\\s-+1\\s-+&quot;Making tag completion table&quot; Freezes/Blocks -- how to disable [ 0-9]+[ydhms] ago\\s-+\\[autocomplete\\]")))
+
+(ert-deftest macro-test--sx-assoc-let ()
+ "Tests macro expansion for `sx-assoc-let'"
+ (should
+ (equal '(let ((.test (cdr (assoc 'test data))))
+ .test)
+ (macroexpand
+ '(sx-assoc-let data
+ .test))))
+ (should
+ (equal '(let ((.test-one (cdr (assoc 'test-one data)))
+ (.test-two (cdr (assoc 'test-two data))))
+ (cons .test-one .test-two))
+ (macroexpand
+ '(sx-assoc-let data
+ (cons .test-one .test-two))))))