]> code.delx.au - gnu-emacs-elpa/blob - packages/js2-mode/tests/externs.el
Merge commit '212c8fc3101781a2f1c55ca61772eb75a2046e87' from company
[gnu-emacs-elpa] / packages / js2-mode / tests / externs.el
1 ;;; tests/externs.el --- Some tests for js2-mode.
2
3 ;; Copyright (C) 2009, 2011-2013 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Code:
21
22 (require 'ert)
23 (require 'js2-mode)
24
25 (ert-deftest js2-finds-jslint-globals ()
26 (with-temp-buffer
27 (insert "/*global foo, bar:false, baz: true */")
28 (js2-mode)
29 (should (equal (js2-get-jslint-globals)
30 '("foo" "bar" "baz")))))
31
32 (ert-deftest js2-no-jslint-globals-without-keyword ()
33 (with-temp-buffer
34 (insert "/* foo, bar:false, baz: true */")
35 (js2-mode)
36 (should (null (js2-get-jslint-globals)))))
37
38 (ert-deftest js2-finds-jslint-globals-in-other-comments ()
39 (with-temp-buffer
40 (insert "/* foo, bar */\n\n\n/*global quux, tee: true, $*/")
41 (js2-mode)
42 (should (equal (js2-get-jslint-globals)
43 '("quux" "tee" "$")))))
44
45 ;;;TODO
46 ;; ensure that any symbols bound with the import syntax are added to the extern list
47 ;; ensure that any symbols bound with the export syntax exist in the file scope