summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Sutton <danielsutton01@gmail.com>2017-06-25 08:38:50 -0500
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2017-07-15 10:33:18 +0300
commit644b37c919a72103bafa8a4c9383e6b746d1573d (patch)
tree7c07fbff03ea320ba3f2e9bc1a33984361499f5a /test
parentcb4ed93b144ad60937251cf6bffc5f1efe8fb4a9 (diff)
Show only or hide when on stackframe lines
In order to add "positive" filters, we must only show or hide when we're actually on a stackframe line. This method takes a very naive way of starting at the top of the buffer and considering whether to hide all lines. The other lines just don't have any 'flags properties so they never come up as needing to be hidden in the `(seq-intersection filters flags)` part, so hide is always false on them. But if we want to show _only_ those lines with a particular flag this hides the cause line and any other lines that don't have flags at all.
Diffstat (limited to 'test')
-rw-r--r--test/cider-stacktrace-tests.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/cider-stacktrace-tests.el b/test/cider-stacktrace-tests.el
index b4c754d9..9431b2e9 100644
--- a/test/cider-stacktrace-tests.el
+++ b/test/cider-stacktrace-tests.el
@@ -83,3 +83,34 @@
(cider-stacktrace-promote-error "x")
:test 'equal)
:not :to-be-truthy)))
+
+(defun cider--testing-dict (names &optional stipulated)
+ (let ((numeric? (lambda (sym) (member sym '(line column)))))
+ (apply #'nrepl-dict
+ (append (mapcan (lambda (name) (list (symbol-name name)
+ (if (funcall numeric? name)
+ 4
+ (symbol-name name))))
+ names)
+ stipulated))))
+
+(defun cider--frame-of-type (flags)
+ (cider--testing-dict '(file class method name var ns fn line column path)
+ (list "flags" (mapcar #'symbol-name flags))))
+
+(describe "cider-stacktrace-frame-p-tests"
+ (it "returns true on frames"
+ (with-temp-buffer
+ ;; a stackframe
+ (cider-stacktrace-render-frame (current-buffer)
+ (cider--frame-of-type '(clj)))
+ (goto-char (point-min))
+ (expect (cider-stacktrace-frame-p) :to-be-truthy)))
+
+ (it "returns false otherwise"
+ (with-temp-buffer
+ ;; not a stackframe but a compile error
+ (cider-stacktrace-render-compile-error (current-buffer)
+ (cider--testing-dict '(file path column line)))
+ (goto-char (point-min))
+ (expect (cider-stacktrace-frame-p) :to-be nil))))