Browse Source

Add unit tests for indium-repl.el

workspaces
Nicolas Petton 3 years ago
parent
commit
0cf07787a2
Signed by: nico GPG Key ID: 233587A47C207910
3 changed files with 53 additions and 3 deletions
  1. +0
    -3
      indium-interaction.el
  2. +3
    -0
      indium-repl.el
  3. +50
    -0
      test/unit/indium-repl-test.el

+ 0
- 3
indium-interaction.el View File

@ -108,9 +108,6 @@ If PRINT is non-nil, print the output into the current buffer."
(lambda (result _error)
(indium-inspector-inspect result))))))
(defvar indium-repl-switch-from-buffer nil
"The buffer from which repl was activated last time.")
(defun indium-switch-to-repl-buffer ()
"Switch to the repl buffer if any."
(interactive)


+ 3
- 0
indium-repl.el View File

@ -46,6 +46,9 @@
(defvar indium-repl-evaluate-hook nil
"Hook run when input is evaluated in the repl.")
(defvar indium-repl-switch-from-buffer nil
"The buffer from which repl was activated last time.")
(defvar indium-repl-history nil "History of the REPL inputs.")
(make-variable-buffer-local 'indium-repl-history)
(defvar indium-repl-history-position -1 "Position in the REPL history.")


+ 50
- 0
test/unit/indium-repl-test.el View File

@ -0,0 +1,50 @@
;;; indium-repl-test.el --- Unit tests for indium-repl.el -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Nicolas Petton
;; Author: Nicolas Petton <nicolas@petton.fr>
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Unit tests for indium-repl.el
;;; Code:
(require 'indium-repl)
(require 'indium-interaction)
(require 'buttercup)
(describe "Switching from and to the REPL buffer"
(it "should throw an error if there's no REPL buffer"
(spy-on 'indium-repl-get-buffer :and-return-value nil)
(expect #'indium-switch-to-repl-buffer :to-throw 'user-error))
(it "should be able to switch to the REPL buffer"
(spy-on 'indium-repl-get-buffer :and-return-value 'repl)
(spy-on 'pop-to-buffer)
(indium-switch-to-repl-buffer)
(expect #'pop-to-buffer :to-have-been-called-with 'repl t))
(it "should be able to switch back from the REPL buffer"
(let ((indium-repl-switch-from-buffer 'from))
(spy-on 'pop-to-buffer)
(indium-repl-pop-buffer)
(expect #'pop-to-buffer :to-have-been-called-with 'from t))))
(provide 'indium-repl-test)
;;; indium-repl-test.el ends here

Loading…
Cancel
Save