From 644b37c919a72103bafa8a4c9383e6b746d1573d Mon Sep 17 00:00:00 2001 From: Dan Sutton Date: Sun, 25 Jun 2017 08:38:50 -0500 Subject: 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. --- test/cider-stacktrace-tests.el | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') 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)))) -- cgit v1.2.3