branch: externals/bnf-mode commit 6eb06a8cc85cfac2ce639b3c2cb05b42d4a7c895 Author: Serghei Iakovlev <serg...@phalconphp.com> Commit: Serghei Iakovlev <serg...@phalconphp.com>
Make tests easier to read --- test/bnf-mode-font-test.el | 184 +++++++++++++++++++++++---------------------- 1 file changed, 96 insertions(+), 88 deletions(-) diff --git a/test/bnf-mode-font-test.el b/test/bnf-mode-font-test.el index 58fb1f6..6f9b1b7 100644 --- a/test/bnf-mode-font-test.el +++ b/test/bnf-mode-font-test.el @@ -38,122 +38,130 @@ (ert-deftest bnf-mode-syntax-table/fontify-strings () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "<string delimers> ::= \" | ' | ` | ”" - (should-not (bnf-test-face-at 23)) - (should-not (bnf-test-face-at 27)) - (should-not (bnf-test-face-at 31)) - (should-not (bnf-test-face-at 35)))) + (bnf-test-with-temp-buffer + "<string delimers> ::= \" | ' | ` | ”" + (should-not (bnf-test-face-at 23)) + (should-not (bnf-test-face-at 27)) + (should-not (bnf-test-face-at 31)) + (should-not (bnf-test-face-at 35)))) (ert-deftest bnf-mode-syntax-table/fontify-line-comment () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "; A + (bnf-test-with-temp-buffer + "; A <stm> ::= <decl> ; foo" - (should (eq (bnf-test-face-at 1) 'font-lock-comment-delimiter-face)) - (should (eq (bnf-test-face-at 3) 'font-lock-comment-face)) - (should-not (bnf-test-face-at 5)) - (should (eq (bnf-test-face-at 24) 'font-lock-comment-face)))) + (should (eq (bnf-test-face-at 1) 'font-lock-comment-delimiter-face)) + (should (eq (bnf-test-face-at 3) 'font-lock-comment-face)) + (should-not (bnf-test-face-at 5)) + (should (eq (bnf-test-face-at 24) 'font-lock-comment-face)))) (ert-deftest bnf-mode-syntax-table/fontify-nonterminals () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "<stm> ::= <decl> + (bnf-test-with-temp-buffer + "<stm> ::= <decl> angle-brackets ::= are-optional" - ;; angle bracket - (should-not (bnf-test-face-at 1)) - ;; “stm” - (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 4) 'font-lock-function-name-face)) - ;; angle bracket - (should-not (bnf-test-face-at 5)) - ;; “::=” symbol - (should (eq (bnf-test-face-at 7) 'font-lock-constant-face)) - (should (eq (bnf-test-face-at 9) 'font-lock-constant-face)) - ;; angle bracket - (should-not (bnf-test-face-at 11)) - ;; “dec” symbol - (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face)))) + ;; angle bracket + (should-not (bnf-test-face-at 1)) + ;; "stm" + (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 4) 'font-lock-function-name-face)) + ;; angle bracket + (should-not (bnf-test-face-at 5)) + ;; "::=" symbol + (should (eq (bnf-test-face-at 7) 'font-lock-constant-face)) + (should (eq (bnf-test-face-at 9) 'font-lock-constant-face)) + ;; angle bracket + (should-not (bnf-test-face-at 11)) + ;; "dec" symbol + (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face)))) (ert-deftest bnf-mode-syntax-table/fontify-nonterminals-case () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "<RULE> ::= <foo> + (bnf-test-with-temp-buffer + "<RULE> ::= <foo> <RuLe> ::= <foO>" - (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) - (should-not (bnf-test-face-at 17)) - (should (eq (bnf-test-face-at 19) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 22) 'font-lock-function-name-face)) - (should-not (bnf-test-face-at 23)) - (should (eq (bnf-test-face-at 30) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 32) 'font-lock-builtin-face)) - (should-not (bnf-test-face-at 33)))) + (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) + (should-not (bnf-test-face-at 17)) + (should (eq (bnf-test-face-at 19) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 22) 'font-lock-function-name-face)) + (should-not (bnf-test-face-at 23)) + (should (eq (bnf-test-face-at 30) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 32) 'font-lock-builtin-face)) + (should-not (bnf-test-face-at 33)))) (ert-deftest bnf-mode-syntax-table/fontify-nonterminals-start-pos () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer " <rule> ::= <foo>" - (should-not (bnf-test-face-at 4)) - (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 6) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 7) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 8) 'font-lock-function-name-face)) - (should-not (bnf-test-face-at 9)))) + (bnf-test-with-temp-buffer + " <rule> ::= <foo>" + (should-not (bnf-test-face-at 4)) + (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 6) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 7) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 8) 'font-lock-function-name-face)) + (should-not (bnf-test-face-at 9)))) (ert-deftest bnf-mode-syntax-table/fontify-sequence () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "<rule> ::= <foo> <bar> <baz>" - ;; “<” angle bracket - (should-not (bnf-test-face-at 1)) - ;; “rule” - (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) - ;; “>” angle bracket - (should-not (bnf-test-face-at 6)) - ;; “foo” - (should (eq (bnf-test-face-at 13) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face)) - ;; space - (should-not (bnf-test-face-at 17)) - ;; “bar” - (should (eq (bnf-test-face-at 19) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 21) 'font-lock-builtin-face)) - ;; space - (should-not (bnf-test-face-at 23)) - ;; “baz” - (should (eq (bnf-test-face-at 25) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 27) 'font-lock-builtin-face)))) + (bnf-test-with-temp-buffer + "<rule> ::= <foo> <bar> <baz>" + ;; "<" angle bracket + (should-not (bnf-test-face-at 1)) + ;; "rule" + (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face)) + ;; ">" angle bracket + (should-not (bnf-test-face-at 6)) + ;; "foo" + (should (eq (bnf-test-face-at 13) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face)) + ;; space + (should-not (bnf-test-face-at 17)) + ;; "bar" + (should (eq (bnf-test-face-at 19) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 21) 'font-lock-builtin-face)) + ;; space + (should-not (bnf-test-face-at 23)) + ;; "baz" + (should (eq (bnf-test-face-at 25) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 27) 'font-lock-builtin-face)))) (ert-deftest bnf-mode-syntax-table/fontify-alternatives () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer "<foo> | <bar> | <baz>" - ;; “foo” - (should (eq (bnf-test-face-at 2) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 4) 'font-lock-builtin-face)) - ;; “|” - (should (eq (bnf-test-face-at 7) 'font-lock-warning-face)) - ;; “bar” - (should (eq (bnf-test-face-at 10) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face)) - ;; “|” - (should (eq (bnf-test-face-at 15) 'font-lock-warning-face)) - ;; “baz” - (should (eq (bnf-test-face-at 18) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 20) 'font-lock-builtin-face)))) + (bnf-test-with-temp-buffer + "<foo> | <bar> | <baz>" + ;; "foo" + (should (eq (bnf-test-face-at 2) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 4) 'font-lock-builtin-face)) + ;; "|" + (should (eq (bnf-test-face-at 7) 'font-lock-warning-face)) + ;; "bar" + (should (eq (bnf-test-face-at 10) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face)) + ;; "|" + (should (eq (bnf-test-face-at 15) 'font-lock-warning-face)) + ;; "baz" + (should (eq (bnf-test-face-at 18) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 20) 'font-lock-builtin-face)))) (ert-deftest bnf-mode-syntax-table/fontify-rule-punctuation () :tags '(fontification syntax-table) - (bnf-test-with-temp-buffer " + (bnf-test-with-temp-buffer + " <proper string> ::= <any sequence of symbols not containing ` or ' > | <empty>" - ;; “proper string” - (should (eq (bnf-test-face-at 3) 'font-lock-function-name-face)) - (should (eq (bnf-test-face-at 15) 'font-lock-function-name-face)) - ;; “any sequence of symbols not containing ` or ' ” - (should (eq (bnf-test-face-at 31) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 76) 'font-lock-builtin-face)) - ;; “empty” - (should (eq (bnf-test-face-at 90) 'font-lock-builtin-face)) - (should (eq (bnf-test-face-at 94) 'font-lock-builtin-face)))) + ;; "proper string" + (should (eq (bnf-test-face-at 3) 'font-lock-function-name-face)) + (should (eq (bnf-test-face-at 15) 'font-lock-function-name-face)) + ;; "any sequence of symbols not containing ` or ' " + (should (eq (bnf-test-face-at 31) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 76) 'font-lock-builtin-face)) + ;; "empty" + (should (eq (bnf-test-face-at 90) 'font-lock-builtin-face)) + (should (eq (bnf-test-face-at 94) 'font-lock-builtin-face)))) (provide 'bnf-mode-font-test) ;;; bnf-mode-font-test.el ends here