Browse Source

Add tests and travis support

workspaces 0.12
Nicolas Petton 6 years ago
parent
commit
485b8c680c
4 changed files with 114 additions and 0 deletions
  1. +15
    -0
      .travis.yml
  2. +3
    -0
      run-tests.sh
  3. +13
    -0
      run-travis-ci.sh
  4. +83
    -0
      test/jade-interaction-test.el

+ 15
- 0
.travis.yml View File

@ -0,0 +1,15 @@
language: emacs-lisp
before_install:
- if [ "$EMACS" = 'emacs-snapshot' ]; then
sudo add-apt-repository -y ppa:ubuntu-elisp/ppa &&
sudo apt-get update -qq &&
sudo apt-get install -qq
emacs-snapshot-el emacs-snapshot;
fi
- curl -fsSkL https://raw.github.com/cask/cask/master/go | python
- export PATH="/home/travis/.cask/bin:$PATH"
- cask
env:
- EMACS=emacs-snapshot TAGS=""
script:
./run-travis-ci.sh

+ 3
- 0
run-tests.sh View File

@ -0,0 +1,3 @@
#!/bin/sh -e
cask exec ecukes "$@"
cask exec ert-runner -L . "$@"

+ 13
- 0
run-travis-ci.sh View File

@ -0,0 +1,13 @@
#!/bin/sh -e
cd "$(dirname "$0")"
ECUKES_EMACS=${EMACS:-$(which emacs)}
export ECUKES_EMACS
echo "*** Emacs version ***"
echo "ECUKES_EMACS = $ECUKES_EMACS"
"$ECUKES_EMACS" --version
echo
exec ./run-tests.sh $TAGS

+ 83
- 0
test/jade-interaction-test.el View File

@ -0,0 +1,83 @@
;;; jade-interaction-test.el --- Test for jade-interaction.el -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Nicolas Petton
;; Author: Nicolas Petton <nicolas@petton.fr>
;; 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:
;;; Code:
(require 'ert)
;;; Helpers
(defmacro with-js2-buffer (contents &rest body)
"Evaluate BODY.
BODY is evaluated with the current buffer set to a JavaScript
buffer in `js2-mode' with CONTENTS."
(declare (indent 1))
`(with-temp-buffer
(insert ,contents)
(goto-char (point-max))
(js2-mode)
(js2-parse)
,@body))
;;; Tests
(ert-deftest jade-node-before-point-test ()
(with-js2-buffer "var foo = 2;\nfoo"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo")))
(with-js2-buffer "var foo = 2;\nfoo + 1;"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo + 1;")))
(with-js2-buffer "var foo = 2;\nfoo + 1;"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo + 1;")))
(with-js2-buffer "var foo = 2; var bar = 3;"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"var bar = 3;")))
(with-js2-buffer "this.bar(3); this.baz(3);"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"this.baz(3);")))
(with-js2-buffer "[1,2,\n3,\n4]"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"[1,2,\n3,\n4]")))
(with-js2-buffer "foo(a,\nb,\nc);"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo(a,\nb,\nc);")))
(with-js2-buffer "foo({\na: 1,\nb: 2,\nc: 3\n});"
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo({\na: 1,\nb: 2,\nc: 3\n});")))
(with-js2-buffer "foo({\na: 1,\nb: 2,\nc: 3\n});"
(goto-char 11)
(should (equal (js2-node-string (jade-interaction-node-before-point))
"1"))
(goto-char 12)
(should (equal (js2-node-string (jade-interaction-node-before-point))
"1"))
(goto-char 25)
(should (equal (js2-node-string (jade-interaction-node-before-point))
"{\na: 1,\nb: 2,\nc: 3\n}"))
(goto-char 26)
(should (equal (js2-node-string (jade-interaction-node-before-point))
"foo({\na: 1,\nb: 2,\nc: 3\n})"))))
(provide 'jade-interaction-test)
;;; jade-interaction-test.el ends here

Loading…
Cancel
Save