diff options
| author | Simen Heggestøyl | 2016-03-23 19:03:47 +0100 |
|---|---|---|
| committer | Simen Heggestøyl | 2016-03-23 19:03:47 +0100 |
| commit | 269d5631ab6ae7a5a792d0139b9421bddac8870c (patch) | |
| tree | 00bfdf536dff6c02ad1b5c7e869eeaa8ad91d9bd /test | |
| parent | 500a781bc5d3d7cc2f671a950816ba4035a9d58c (diff) | |
| download | emacs-269d5631ab6ae7a5a792d0139b9421bddac8870c.tar.gz emacs-269d5631ab6ae7a5a792d0139b9421bddac8870c.zip | |
Support completion of attribute values in CSS mode
* lisp/textmodes/css-mode.el (css-property-alist): New defconst
holding CSS identifiers and the values they can have.
(css-property-ids): Compute dynamically from `css-property-alist'.
(css-value-class-alist): New defconst holding property value classes
and their values.
(css--property-value-cache): New variable providing a cache for
`css--property-values'.
(css--value-class-lookup): New function for computing a list of values
in a value class.
(css--property-values): New function for computing a list of possible
values for a CSS property.
(css--complete-property-value): New function for completing a property
value.
(css-completion-at-point): Add support for completing property values.
* test/lisp/textmodes/css-mode-tests.el: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/textmodes/css-mode-tests.el | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el new file mode 100644 index 00000000000..9c5953db4a8 --- /dev/null +++ b/test/lisp/textmodes/css-mode-tests.el | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | ;;; css-mode-tests.el --- Test suite for CSS mode -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> | ||
| 6 | ;; Keywords: internal | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; This program is free software; you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; This program is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (require 'ert) | ||
| 28 | (require 'css-mode) | ||
| 29 | |||
| 30 | (ert-deftest css-test-property-values () | ||
| 31 | ;; The `float' property has a flat value list. | ||
| 32 | (should | ||
| 33 | (equal (sort (css--property-values "float") #'string-lessp) | ||
| 34 | '("left" "none" "right"))) | ||
| 35 | |||
| 36 | ;; The `list-style' property refers to several other properties. | ||
| 37 | (should | ||
| 38 | (equal (sort (css--property-values "list-style") #'string-lessp) | ||
| 39 | (sort (append (css--property-values "list-style-type") | ||
| 40 | (css--property-values "list-style-position") | ||
| 41 | (css--property-values "list-style-image")) | ||
| 42 | #'string-lessp))) | ||
| 43 | |||
| 44 | ;; The `position' property is tricky because it's also the name of a | ||
| 45 | ;; value class. | ||
| 46 | (should | ||
| 47 | (equal (sort (css--property-values "position") #'string-lessp) | ||
| 48 | '("absolute" "fixed" "relative" "static"))) | ||
| 49 | |||
| 50 | ;; The `background-position' property should refer to the `position' | ||
| 51 | ;; value class, not the property of the same name. | ||
| 52 | (should | ||
| 53 | (equal (css--property-values "background-position") | ||
| 54 | (css--value-class-lookup 'position))) | ||
| 55 | |||
| 56 | ;; Check that the `color' property doesn't cause infinite recursion | ||
| 57 | ;; because it refers to the value class of the same name. | ||
| 58 | (should (= (length (css--property-values "color")) 18))) | ||
| 59 | |||
| 60 | (ert-deftest css-test-value-class-lookup () | ||
| 61 | (should | ||
| 62 | (equal (sort (css--value-class-lookup 'position) #'string-lessp) | ||
| 63 | '("bottom" "center" "left" "right" "top")))) | ||
| 64 | |||
| 65 | (provide 'css-mode-tests) | ||
| 66 | ;;; css-mode-tests.el ends here | ||