diff options
| author | Lars Ingebrigtsen | 2019-07-11 18:44:30 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-11 18:44:30 +0200 |
| commit | b44f0c457997af53808218536ebfdf507ddb5995 (patch) | |
| tree | c4fc4df143a0e913b8c6d9ea91ac159b4afd102f /test | |
| parent | b41ddb7a8b11c8234e2f010d0db1b13e395468ae (diff) | |
| download | emacs-b44f0c457997af53808218536ebfdf507ddb5995.tar.gz emacs-b44f0c457997af53808218536ebfdf507ddb5995.zip | |
Allow passing unknown specs to format-spec
* lisp/format-spec.el (format-spec): Allow passing through format
strings that have no specs (to be able to act as a filter). Also
add an example.
* test/lisp/format-spec-tests.el (test-format-spec): Add tests for
the new functionality.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/format-spec-tests.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/lisp/format-spec-tests.el b/test/lisp/format-spec-tests.el index a5c62ac9ce3..e831657a3e6 100644 --- a/test/lisp/format-spec-tests.el +++ b/test/lisp/format-spec-tests.el | |||
| @@ -23,11 +23,21 @@ | |||
| 23 | (require 'format-spec) | 23 | (require 'format-spec) |
| 24 | 24 | ||
| 25 | (ert-deftest test-format-spec () | 25 | (ert-deftest test-format-spec () |
| 26 | (should (equal (format-spec "foo %b zot" '((?b . "bar"))) | 26 | (should (equal (format-spec "foo %b zot" `((?b . "bar"))) |
| 27 | "foo bar zot")) | 27 | "foo bar zot")) |
| 28 | (should (equal (format-spec "foo %-10b zot" '((?b . "bar"))) | 28 | (should (equal (format-spec "foo %-10b zot" '((?b . "bar"))) |
| 29 | "foo bar zot")) | 29 | "foo bar zot")) |
| 30 | (should (equal (format-spec "foo %10b zot" '((?b . "bar"))) | 30 | (should (equal (format-spec "foo %10b zot" '((?b . "bar"))) |
| 31 | "foo bar zot"))) | 31 | "foo bar zot"))) |
| 32 | 32 | ||
| 33 | (ert-deftest test-format-unknown () | ||
| 34 | (should (eq (condition-case _ | ||
| 35 | (format-spec "foo %b %z zot" '((?b . "bar"))) | ||
| 36 | (error :error)) | ||
| 37 | :error)) | ||
| 38 | (should (equal (format-spec "foo %b %z zot" '((?b . "bar")) t) | ||
| 39 | "foo bar %z zot")) | ||
| 40 | (should (equal (format-spec "foo %b %z %% zot" '((?b . "bar")) t) | ||
| 41 | "foo bar %z %% zot"))) | ||
| 42 | |||
| 33 | ;;; format-spec-tests.el ends here | 43 | ;;; format-spec-tests.el ends here |