From dc471a600b7c9219e46c95900919ec0ac88106d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Fri, 10 Jan 2020 13:58:14 -0500 Subject: improve syntax --- src/test.el | 118 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index ddc7e40..b5140b9 100644 --- a/src/test.el +++ b/src/test.el @@ -7,15 +7,15 @@ (defun emmet-run-test-case (name fn cases) (let ((res (loop for c in cases - for i to (1- (length cases)) do - (let ((expected (cdr c)) - (actual (funcall fn (car c)))) - (when (not (equal expected actual)) - (princ - (concat "*** [FAIL] | \"" name "\" " (number-to-string i) "\n\n" - (format "%s" (car c)) "\t=>\n\n" - "Expected\n" (format "%s" expected) "\n\nActual\n" (format "%s" actual) "\n\n")) - (return 'fail)))))) + for i to (1- (length cases)) do + (let ((expected (cdr c)) + (actual (funcall fn (car c)))) + (when (not (equal expected actual)) + (princ + (concat "*** [FAIL] | \"" name "\" " (number-to-string i) "\n\n" + (format "%s" (car c)) "\t=>\n\n" + "Expected\n" (format "%s" expected) "\n\nActual\n" (format "%s" actual) "\n\n")) + (return 'fail)))))) (if (not (eql res 'fail)) (princ (concat " [PASS] | \"" name "\" " (number-to-string (length cases)) " tests.\n"))))) @@ -40,11 +40,11 @@ (defmacro define-emmet-transform-test-case (name fn &rest tests) `(emmet-test-cases 'assign ',name - ,fn - ',(loop for x on tests by #'cddr collect - (cons (car x) - (emmet-join-string (cadr x) - "\n"))))) + ,fn + ',(loop for x on tests by #'cddr collect + (cons (car x) + (emmet-join-string (cadr x) + "\n"))))) (defmacro define-emmet-transform-html-test-case (name &rest tests) `(define-emmet-transform-test-case ,name @@ -53,9 +53,9 @@ (defmacro define-emmet-unit-test-case (name fn &rest tests) `(emmet-test-cases 'assign ',name - ,fn - ',(loop for x on tests by #'cddr collect - (cons (car x) (cadr x))))) + ,fn + ',(loop for x on tests by #'cddr collect + (cons (car x) (cadr x))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; XML-abbrev tests @@ -119,8 +119,8 @@ "
  • " "") "ul#q.x.y[m=l]+" ("")) + "
  • " + "")) (define-emmet-transform-html-test-case Parent-child "a>b" ("") @@ -296,15 +296,15 @@ "a#foo.bar.mu[x=y m=l]" ("") "a/#foo.bar.mu[x=y m=l]" ("") "a[x=y]+b" ("" - "") + "") "a[x=y]+b[x=y]" ("" - "") + "") "a[x=y]>b" ("") "a[x=y]>b[x=y]" ("") "a[x=y]>b[x=y]+c[x=y]" ("" - " " - " " - "")) + " " + " " + "")) (define-emmet-transform-html-test-case Parentheses "(a)" ("") @@ -432,8 +432,8 @@ "a#q.x[x=y m=l]|hic" ("[:a#q.x {:x \"y\", :m \"l\"}]") ".footer|hic" ("[:div.footer]") "p>a[href=#]+br|hic" ("[:p" - " [:a {:href \"#\"}]" - " [:br]]") + " [:a {:href \"#\"}]" + " [:br]]") "#q>(a*2>b{x})+p>{m}+b|hic" ("[:div#q" @@ -552,9 +552,9 @@ "fs" ("font-style: italic;") "xxxxxx 0 auto 0e auto!" ("xxxxxx: 0px auto 0em auto !important;") "p auto+m auto+bg+#F00 x.jpg 10 10 repeat-x" - ("padding: auto;" - "margin: auto;" - "background: #F00 url(x.jpg) 10px 10px repeat-x;") + ("padding: auto;" + "margin: auto;" + "background: #F00 url(x.jpg) 10px 10px repeat-x;") "-bdrs" ("-webkit-border-radius: ;" "-moz-border-radius: ;" "border-radius: ;") @@ -570,7 +570,7 @@ " 1px" "}") "@i http://github.com/smihica/index.css" - ("@import url(http://github.com/smihica/index.css);") + ("@import url(http://github.com/smihica/index.css);") ) ;; lorem generator test @@ -599,8 +599,8 @@ (buffer-string)))) (emmet-run-test-case "Inline Expansion" - #'emmet-inline-expansion-test - '((("span#test") . "
    "))) + #'emmet-inline-expansion-test + '((("span#test") . "
    "))) ;; indent ;; NOTE: Indent uses indent-region by default, @@ -621,14 +621,14 @@ (let ((emmet-indent-after-insert t)) (emmet-run-test-case "Indentation via indent-region" - #'emmet-indent-test - '((("div>ul>li*3") . "
    \n \n
    ")))) + #'emmet-indent-test + '((("div>ul>li*3") . "
    \n \n
    ")))) (let ((emmet-indent-after-insert nil) (emmet-indentation 2)) (emmet-run-test-case "Indentation via emmet-indentation" - #'emmet-indent-test - '((("div>ul>li*3") . "
    \n \n
    ")))) + #'emmet-indent-test + '((("div>ul>li*3") . "
    \n \n
    ")))) ;; Old tests for previous indent behavior last seen: ;; commit: f56174e5905a40583b47f9737abee3af8da3faeb @@ -648,21 +648,21 @@ (buffer-string)))) (emmet-run-test-case "Wrap with markup on text with brackets and markup" - #'emmet-wrap-with-markup-test - '((("div>ul>li") . "
    \n \n
    "))) + #'emmet-wrap-with-markup-test + '((("div>ul>li") . "
    \n \n
    "))) (emmet-run-test-case "Wrap with markup multiplier" - #'emmet-wrap-with-markup-test - '((("div>ul>li*3") . "
    \n \n
    "))) + #'emmet-wrap-with-markup-test + '((("div>ul>li*3") . "
    \n \n
    "))) (emmet-run-test-case "Wrap with multiline content" - #'emmet-wrap-with-markup-test - '((("div>ul>li" "I am some\nmultiline\n text") . "
    \n \n
    "))) + #'emmet-wrap-with-markup-test + '((("div>ul>li" "I am some\nmultiline\n text") . "
    \n \n
    "))) (emmet-run-test-case "Wrap with per-line markup (trailing *)" #'emmet-wrap-with-markup-test '((("div>ul>li*" "I am some\nmultiline\n text") . - "
    \n \n
    "))) + "
    \n \n
    "))) ;; Regression test for #54 (broken emmet-find-left-bound behavior ;; after tag with attributes) @@ -679,12 +679,12 @@ (buffer-string)))) (emmet-run-test-case "Regression 54 with span" - #'emmet-regression-54-test - '((("span") . "
    "))) + #'emmet-regression-54-test + '((("span") . "
    "))) (emmet-run-test-case "Regression 54 with complex span" - #'emmet-regression-54-test - '((("span.whut[thing=\"stuff\"]{Huh?}") . "
    Huh?"))) + #'emmet-regression-54-test + '((("span.whut[thing=\"stuff\"]{Huh?}") . "
    Huh?"))) (define-emmet-transform-html-test-case regression-61-bracket-escapes "div{\\}\\}\\}}" ("
    }}}
    ")) @@ -703,12 +703,12 @@ (buffer-string)))) (emmet-run-test-case "JSX's className 1" - #'emmet-expand-jsx-className?-test - '(((".jsx") . "
    "))) + #'emmet-expand-jsx-className?-test + '(((".jsx") . "
    "))) (emmet-run-test-case "JSX's className 2" - #'emmet-expand-jsx-className?-test - '(((".jsx>ul.lis>li.itm{x}*2") . "
    \n
      \n
    • x
    • \n
    • x
    • \n
    \n
    "))) + #'emmet-expand-jsx-className?-test + '(((".jsx>ul.lis>li.itm{x}*2") . "
    \n
      \n
    • x
    • \n
    • x
    • \n
    \n
    "))) (defun emmet-self-closing-tag-style-test (lis) (let ((es (car lis)) @@ -721,23 +721,23 @@ ;; By default, `emmet-self-closing-tag-style' must not break any test code. (emmet-run-test-case "Self closing tag style 1" - #'emmet-self-closing-tag-style-test - '((("meta") . ""))) + #'emmet-self-closing-tag-style-test + '((("meta") . ""))) (let ((emmet-self-closing-tag-style "/")) (emmet-run-test-case "Self closing tag style 2" - #'emmet-self-closing-tag-style-test - '((("meta") . "")))) + #'emmet-self-closing-tag-style-test + '((("meta") . "")))) (let ((emmet-self-closing-tag-style " /")) (emmet-run-test-case "Self closing tag style 3" - #'emmet-self-closing-tag-style-test - '((("meta") . "")))) + #'emmet-self-closing-tag-style-test + '((("meta") . "")))) (let ((emmet-self-closing-tag-style "")) (emmet-run-test-case "Self closing tag style 4" - #'emmet-self-closing-tag-style-test - '((("meta") . "")))) + #'emmet-self-closing-tag-style-test + '((("meta") . "")))) ;; start (emmet-test-cases) -- cgit v1.2.3