Browse Source

Fix issue #92

Fix `indium-add-conditional-breakpoint` to call `indium-add-breakpoint` with a
condition string.

Also add a regression test.
workspaces
Nicolas Petton 3 years ago
parent
commit
bc414bdc75
2 changed files with 21 additions and 9 deletions
  1. +10
    -8
      indium-interaction.el
  2. +11
    -1
      test/unit/indium-interaction-test.el

+ 10
- 8
indium-interaction.el View File

@ -127,21 +127,23 @@ If PRINT is non-nil, print the output into the current buffer."
(pop-to-buffer buf t))
(user-error "No REPL buffer open")))
(defun indium-add-breakpoint ()
(defun indium-add-breakpoint (&optional condition)
"Add a breakpoint on the current line.
If there is already a breakpoint, signal an error."
If there is already a breakpoint, signal an error.
When CONDITION is non-nil, add a conditional breakpoint with
CONDITION."
(interactive)
(indium-interaction--guard-no-breakpoint-at-point)
(if-let ((location (indium-script-generated-location-at-point)))
(indium-breakpoint-add location)
(indium-breakpoint-add location condition)
(user-error "Cannot place a breakpoint here")))
(defun indium-add-conditional-breakpoint ()
"Add a conditional breakpoint at point.
(defun indium-add-conditional-breakpoint (condition)
"Add a breakpoint with CONDITION at point.
If there is already a breakpoint, signal an error."
(interactive)
(indium-interaction--guard-no-breakpoint-at-point)
(indium-breakpoint-add (read-from-minibuffer "Breakpoint condition: ")))
(interactive "sBreakpoint condition: ")
(indium-add-breakpoint condition))
(defun indium-edit-breakpoint-condition ()
"Edit the condition of breakpoint at point.


+ 11
- 1
test/unit/indium-interaction-test.el View File

@ -150,7 +150,17 @@
(with-current-buffer buf
(insert "let a = 2;")
(indium-add-breakpoint)
(expect #'indium-add-conditional-breakpoint :to-throw 'user-error))))))
(expect (lambda () (indium-add-conditional-breakpoint "true")) :to-throw 'user-error))))))
(describe "Adding conditional breakpoints"
(it "should call `indium-add-breakpoint' with a condition (GH issue #92)"
(spy-on 'indium-add-breakpoint)
(assess-with-filesystem '("app.js")
(let ((buf (find-file-noselect (expand-file-name "app.js"))))
(with-current-buffer buf
(insert "let a = 2;")
(indium-add-conditional-breakpoint "foo")
(expect #'indium-add-breakpoint :to-have-been-called-with "foo"))))))
(provide 'indium-interaction-test)
;;; indium-interaction-test.el ends here

Loading…
Cancel
Save