]> code.delx.au - gnu-emacs-elpa/blob - packages/load-relative/test/test-load.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / load-relative / test / test-load.el
1 ;; Copyright (C) 2015 Free Software Foundation, Inc
2
3 ;; Author: Rocky Bernstein <rocky@gnu.org>
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 (require 'cl)
18 (require 'test-simple)
19 (load-file "../load-relative.el")
20
21 (test-simple-start)
22
23 ;; (setq tempbuf (generate-new-buffer "*cmdbuf-test*"))
24 ;; (assert-nil
25 ;; (with-current-buffer tempbuf
26 ;; (insert "(__FILE__)\n")
27 ;; (eval-current-buffer))
28 ;; (kill-buffer tempbuf) "(__FILE__) on temporary buffer")
29
30 (assert-equal "test-load"
31 (file-name-sans-extension
32 (file-name-nondirectory (__FILE__)))
33 "(__FILE__) on this running program"
34 )
35
36 (dolist (file-name
37 '("load-file1.el" "./load-file1.el" "../test/load-file1.el"))
38 (assert-equal
39 (expand-file-name file-name)
40 (relative-expand-file-name file-name))
41 "relative-expand-filename"
42 )
43
44 (note "Basic load-relative")
45 (setq loaded-file nil)
46 (assert-equal t (load-relative "load-file2"))
47 (assert-equal "load-file3" loaded-file)
48
49 (setq loaded-file nil)
50 (setq loaded-file1 nil)
51 (assert-equal '(t t)
52 (load-relative '("load-file1" "load-file2")
53 ))
54 (assert-equal 't loaded-file1)
55 (assert-equal "load-file3" loaded-file)
56
57
58 (dolist (file-name
59 '("load-file1.el" "./load-file1.el" "../test/load-file1.el"))
60 (setq loaded-file nil)
61 (assert-equal t (load-relative file-name)
62 (format "load-relative with list file %s" loaded-file))
63 (assert-equal "load-file1" loaded-file
64 (format "load-relative value with list file %s" loaded-file)
65 ))
66
67 (if (featurep 'require-file1 t)
68 (unload-feature 'require-file1))
69
70 (require-relative "require-file1")
71 (assert-t (featurep 'require-file1) "require-relative")
72
73 (if (featurep 'require-file1 t)
74 (unload-feature 'require-file1))
75
76 (require-relative-list '("require-file1" "require-file3"))
77 (assert-t (and (featurep 'require-file1)
78 (featurep 'require-file3)) "require-relative-list")
79
80 (if (featurep 'my-require-file2 t)
81 (unload-feature 'my-require-file2))
82
83 (require-relative-list '("require-file2") "my-")
84 (assert-t (featurep 'my-require-file2) "require-relative-list with prefix")
85
86
87 (if (featurep 'test-load t)
88 (unload-feature 'test-load) "provide-me - no prefix")
89 (provide-me)
90 (assert-t (featurep 'test-load))
91
92 (if (featurep 'my-test-load t)
93 (unload-feature 'my-test-load))
94 (provide-me "my-")
95 (assert-t (featurep 'my-test-load) "provide-me - prefix")
96
97 (end-tests)