diff options
| author | Simen Heggestøyl | 2017-12-16 09:37:11 +0100 |
|---|---|---|
| committer | Simen Heggestøyl | 2017-12-16 09:46:54 +0100 |
| commit | 63b6281fdd9c00c6d968e936289c1e32aa9d0dd3 (patch) | |
| tree | a326fb5cd3db2c34bfa6b154d5b47bf506f55cb7 | |
| parent | 804b37ca63ecd68c5359febbedbec120c06918af (diff) | |
| download | emacs-63b6281fdd9c00c6d968e936289c1e32aa9d0dd3.tar.gz emacs-63b6281fdd9c00c6d968e936289c1e32aa9d0dd3.zip | |
Fix off-by-one error in 'css--hex-color'
* lisp/textmodes/css-mode.el (css--hex-color): Fix off-by-one error.
* test/lisp/textmodes/css-mode-tests.el (css-test-hex-color): New test
for 'css--hex-color'.
| -rw-r--r-- | lisp/textmodes/css-mode.el | 2 | ||||
| -rw-r--r-- | test/lisp/textmodes/css-mode-tests.el | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 1de4ff0fca9..f2481da8aa1 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -1037,7 +1037,7 @@ This recognizes CSS-color-4 extensions." | |||
| 1037 | STR is the incoming CSS hex color. | 1037 | STR is the incoming CSS hex color. |
| 1038 | This function simply drops any transparency." | 1038 | This function simply drops any transparency." |
| 1039 | ;; Either #RGB or #RRGGBB, drop the "A" or "AA". | 1039 | ;; Either #RGB or #RRGGBB, drop the "A" or "AA". |
| 1040 | (if (> (length str) 4) | 1040 | (if (> (length str) 5) |
| 1041 | (substring str 0 7) | 1041 | (substring str 0 7) |
| 1042 | (substring str 0 4))) | 1042 | (substring str 0 4))) |
| 1043 | 1043 | ||
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 47cf5f9244b..1e58751f140 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el | |||
| @@ -295,6 +295,12 @@ | |||
| 295 | (insert input ")")) | 295 | (insert input ")")) |
| 296 | (should (equal (css--hsl-color) "#ff0000"))))) | 296 | (should (equal (css--hsl-color) "#ff0000"))))) |
| 297 | 297 | ||
| 298 | (ert-deftest css-test-hex-color () | ||
| 299 | (should (equal (css--hex-color "#abc") "#abc")) | ||
| 300 | (should (equal (css--hex-color "#abcd") "#abc")) | ||
| 301 | (should (equal (css--hex-color "#aabbcc") "#aabbcc")) | ||
| 302 | (should (equal (css--hex-color "#aabbccdd") "#aabbcc"))) | ||
| 303 | |||
| 298 | (ert-deftest css-test-named-color () | 304 | (ert-deftest css-test-named-color () |
| 299 | (dolist (text '("@mixin black" "@include black")) | 305 | (dolist (text '("@mixin black" "@include black")) |
| 300 | (with-temp-buffer | 306 | (with-temp-buffer |