(scheme-in-list): Add a fallback to create an error tag.
[cedet.git] / tests / cit-projvar.el
blob5405106282bbbfc31461ca9b6169a89a55db69c1
1 ;;; cit-projvar.el --- Test project local variables
2 ;;
3 ;; Copyright (C) 2012 Eric M. Ludlam
4 ;;
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License as
9 ;; published by the Free Software Foundation; either version 2, or (at
10 ;; your option) any later version.
12 ;; This program is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 ;;; Commentary:
24 ;; Test `ede-set' and that it will correctly set variables in project buffers, but not other
25 ;; buffers.
27 (defvar cit-test-moose nil)
28 (defvar cit-test-list nil)
30 ;;; Code:
31 (defun cit-proj-variables ()
32 "Test project local variables."
33 ;; Pre-load a file from the project
34 (find-file (cit-file "include/foo.hpp"))
36 ;; Make some misc file we created and added to a project local.
37 (find-file (cit-file "src/main.cpp"))
39 ;; Add some "unique" variables to the EDE project
40 (ede-set 'cit-test-moose "MOOSE")
41 (ede-set 'cit-test-list '(1 2 3))
43 ;; Make sure the variables get immediately set to this buffer.
44 (cit-projvar-desired-vars-test)
46 ;; Make sure they are set in an open, but not current buffer.
47 (set-buffer "foo.hpp")
48 (cit-projvar-desired-vars-test)
50 ;; Make sure they are set when we open a file.
51 (kill-buffer (current-buffer))
52 (find-file (cit-file "include/foo.hpp"))
53 (cit-projvar-desired-vars-test)
55 ;; Make sure they are NOT set is some file not belonging to our project
56 (find-file (cit-file "../NOT_A_FILE"))
57 (cit-projvar-desired-vars-test t)
59 ;; Lets flip back to main.cpp - lets set a variable even MORE local
60 (find-file (cit-file "src/main.cpp"))
61 (ede-set 'cit-test-moose "moose" (ede-current-project))
63 (when (not (and (stringp cit-test-moose)
64 (string= cit-test-moose "moose")))
65 (error "ede-set failed to create a subproject string variable."))
67 ;; I hope it didn't set things over here in foo.hpp
68 (find-file (cit-file "include/foo.hpp"))
69 (when (not (and (stringp cit-test-moose)
70 (string= cit-test-moose "MOOSE")))
71 (error "ede-set failed to restrict a subproject string variable to the subproject."))
75 (defun cit-projvar-desired-vars-test (&optional notset)
76 "Test that the created variables are all property set.
77 If optional NOTSET, then make sure that they DONT have the desired values."
79 (if notset
81 (when (or cit-test-moose cit-test-list)
82 (error "ede-set set variables where they don't belong."))
84 ;; Test positively
85 (when (not (and (stringp cit-test-moose)
86 (string= cit-test-moose "MOOSE")))
87 (error "ede-set failed to create a string variable."))
89 (when (not (and (listp cit-test-list)
90 (equal cit-test-list '(1 2 3))))
91 (error "ede-set failed to create a list variable."))
95 (provide 'cit-projvar)
97 ;;; cit-projvar.el ends here