From 7ff95cafdcf85b5048e5ec51f5fd51a176e3d97e Mon Sep 17 00:00:00 2001 From: smihica Date: Tue, 12 Mar 2013 10:50:02 +0900 Subject: Created emmet branch. --- src/test.el | 405 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 src/test.el (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el new file mode 100644 index 0000000..25da65b --- /dev/null +++ b/src/test.el @@ -0,0 +1,405 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Test-cases + +(load-file (concat (file-name-directory load-file-name) "../zencoding-mode.el")) + +(defmacro defparameter (symbol &optional initvalue docstring) + `(progn + (defvar ,symbol nil ,docstring) + (setq ,symbol ,initvalue))) +(defparameter *zencoding-test-cases* nil) + +(defun zencoding-test-cases (&rest args) + (let ((cmd (car args))) + (flet + ((run-cases + (cases) + (block outer + (loop for c in cases + for i to (1- (length cases)) do + (let ((expected (mapconcat 'identity (cdr c) "\n")) + (actual (zencoding-transform (car (zencoding-expr (car c)))))) + (when (not (equal expected actual)) + (princ + (concat "*** [FAIL] | \"" name "\" " (number-to-string i) "\n\n" + (car c) "\t=>\n\n" + "Expected\n" expected "\n\nActual\n" actual "\n\n")) + (return-from outer 'fail))))))) + (cond ((eql cmd 'assign) + (let ((name (cadr args)) + (defs (caddr args))) + (let ((place (assoc name *zencoding-test-cases*))) + (if place + (setf (cdr place) defs) + (setq *zencoding-test-cases* + (cons (cons name defs) *zencoding-test-cases*)))))) + (t + (loop for test in (reverse *zencoding-test-cases*) do + (let ((name (symbol-name (car test))) + (cases (cdr test))) + (let ((res (run-cases cases))) + (if (not (eql res 'fail)) + (princ (concat " [PASS] | \"" name "\" " + (number-to-string (length cases)) " tests.\n"))))))))))) + +(defmacro define-zencoding-test-case (name &rest tests) + `(zencoding-test-cases 'assign ',name + ',(loop for x on tests by #'cddr collect (cons (car x) (cadr x))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; XML-abbrev tests + +(define-zencoding-test-case Tags + "a" ("") + "a.x" ("") + "a#q.x" ("") + "a#q.x.y.z" ("") + "#q" ("
" + "
") + ".x" ("
" + "
") + "#q.x" ("
" + "
") + "#q.x.y.z" ("
" + "
")) + +(define-zencoding-test-case Empty-tags + "a/" ("") + "a/.x" ("") + "a/#q.x" ("") + "a/#q.x.y.z" ("")) + +(define-zencoding-test-case Self-closing-tags + "input type=text" ("") + "img" ("") + "img>metadata/*2" ("" + " " + " " + "")) + +(define-zencoding-test-case Siblings + "a+b" ("" + "") + "a+b+c" ("" + "" + "") + "a.x+b" ("" + "") + "a#q.x+b" ("" + "") + "a#q.x.y.z+b" ("" + "") + "a#q.x.y.z+b#p.l.m.n" ("" + "")) + +(define-zencoding-test-case Tag-expansion + "table+" ("" + " " + " " + " " + "
" + "
") + "dl+" ("
" + "
" + "
" + "
") + "ul+" ("") + "ul++ol+" ("" + "
    " + "
  1. " + "
") + "ul#q.x.y m=l+" ("")) + +(define-zencoding-test-case Parent-child + "a>b" ("") + "a>b>c" ("") + "a.x>b" ("") + "a#q.x>b" ("") + "a#q.x.y.z>b" ("") + "a#q.x.y.z>b#p.l.m.n" ("") + "#q>.x" ("
" + "
" + "
" + "
") + "a>b+c" ("" + " " + " " + "") + "a>b+c>d" ("" + " " + " " + "")) + +(define-zencoding-test-case Multiplication + "a*1" ("") + "a*2" ("" + "") + "a/*2" ("" + "") + "a*2+b*2" ("" + "" + "" + "") + "a*2>b*2" ("" + " " + " " + "" + "" + " " + " " + "") + "a>b*2" ("" + " " + " " + "") + "a#q.x>b#q.x*2" ("" + " " + " " + "") + "a#q.x>b/#q.x*2" ("" + " " + " " + "")) + +(define-zencoding-test-case Numbering + "a.$x*3" ("" + "" + "") + "ul>li.item$*3" ("
    " + "
  • " + "
  • " + "
  • " + "
") + "ul>li.item$$$*3" ("
    " + "
  • " + "
  • " + "
  • " + "
") + "ul>li.item$@-*2" ("
    " + "
  • " + "
  • " + "
") + "ul>li.item$@-1000*2" ("
    " + "
  • " + "
  • " + "
") + "a.$*2>b.$$@-*3" ("" + " " + " " + " " + "" + "" + " " + " " + " " + "") + + "(div>(a#id$$*2)+b.c$@-3+c#d$)*2" + ("
" + " " + " " + " " + " " + "
" + "
" + " " + " " + " " + " " + "
") + + "a:b$$$-c$$@-:d$@-3-e$$@100/#b.c$*3" + ("" + "" + "") + + "ul>li.item${name: item$ price: $\\$}*3" + ("
    " + "
  • name: item1 price: 1$
  • " + "
  • name: item2 price: 2$
  • " + "
  • name: item3 price: 3$
  • " + "
")) + +(define-zencoding-test-case Properties + "a x" ("") + "a x=" ("") + "a x=\"\"" ("") + "a x=y" ("") + "a x=\"y\"" ("") + "a x=\"()\"" ("") + "a x m" ("") + "a x= m=\"\"" ("") + "a x=y m=l" ("") + "a/ x=y m=l" ("") + "a#foo x=y m=l" ("") + "a.foo x=y m=l" ("") + "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-zencoding-test-case Parentheses + "(a)" ("") + "(a)+(b)" ("" + "") + "a>(b)" ("") + "(a>b)>c" ("") + "(a>b)+c" ("" + "") + "z+(a>b)+c+k" ("" + "" + "" + "") + "(a)*2" ("" + "") + "((a)*2)" ("" + "") + "((a))*2" ("" + "") + "(a>b)*2" ("" + "") + "(a+b)*2" ("" + "" + "" + "")) + +(define-zencoding-test-case Text + "a{Click me}" ("Click me") + "a>{Click me}*3" ("" + " Click me" + " Click me" + " Click me" + "") + "a{click}+b{here}" ("click" + "here") + "a>{click}+b{here}" ("" + " click" + " here" + "") + + "p>{Click }+a{here}+{ to continue}" + ("

" + " Click " + " here" + " to continue" + "

") + + "p{Click }+a{here}+{ to continue}" + ("

" + " Click " + "

" + "here" + " to continue")) + +(define-zencoding-test-case Climb-up + "a>b>c^d" ("" + " " + " " + "") + "a>b>c^^d" ("" + "") + "a*2>b*2>c^d" ("" + " " + " " + " " + "" + "" + " " + " " + " " + "") + + "div+a>p>span{foo}+em>b^^^p" + ("
" + "
" + "" + "

" + " foo" + " " + "

" + "
" + "

" + "

") + + "div+div>p>span+em^blockquote{foo}" + ("
" + "
" + "
" + "

" + " " + " " + "

" + "
" + " foo" + "
" + "
")) + +(define-zencoding-test-case Filter-comment + "a.b|c" ("" + "" + "") + "#a>.b|c" ("" + "
" + " " + "
" + "
" + " " + "
" + "")) + +(define-zencoding-test-case Filter-HAML + "a|haml" ("%a") + "a#q.x.y.z|haml" ("%a#q.x.y.z") + "a#q.x x=y m=l|haml" ("%a#q.x{:x => \"y\", :m => \"l\"}") + "div|haml" ("%div") + "div.footer|haml" (".footer") + ".footer|haml" (".footer") + + "p>{This is haml}*2+a href=#+br|haml" + ("%p" + " This is haml" + " This is haml" + " %a{:href => \"#\"}" + " %br")) + +(define-zencoding-test-case Filter-Hiccup + "a|hic" ("[:a]") + "a#q.x.y.z|hic" ("[:a#q.x.y.z]") + "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]]") + + "#q>(a*2>b{x})+p>{m}+b|hic" + ("[:div#q" + " [:a [:b \"x\"]]" + " [:a [:b \"x\"]]" + " [:p" + " \"m\"" + " [:b]]]")) + +(define-zencoding-test-case Filter-escape + "script src="|e" ("<script src=\"&quot;\">" + "</script>")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; CSS-abbrev tests + + +;; start +(zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From 918e5420388bded0dd6b3656cc2fe9f4ba9c0649 Mon Sep 17 00:00:00 2001 From: smihica Date: Thu, 21 Mar 2013 11:41:55 +0900 Subject: [add] Added CSS transform functions. --- src/test.el | 176 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 52 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index 25da65b..70f41f3 100644 --- a/src/test.el +++ b/src/test.el @@ -3,53 +3,59 @@ (load-file (concat (file-name-directory load-file-name) "../zencoding-mode.el")) -(defmacro defparameter (symbol &optional initvalue docstring) - `(progn - (defvar ,symbol nil ,docstring) - (setq ,symbol ,initvalue))) -(defparameter *zencoding-test-cases* nil) +(zencoding-defparameter *zencoding-test-cases* nil) (defun zencoding-test-cases (&rest args) (let ((cmd (car args))) (flet ((run-cases - (cases) - (block outer - (loop for c in cases - for i to (1- (length cases)) do - (let ((expected (mapconcat 'identity (cdr c) "\n")) - (actual (zencoding-transform (car (zencoding-expr (car c)))))) - (when (not (equal expected actual)) - (princ - (concat "*** [FAIL] | \"" name "\" " (number-to-string i) "\n\n" - (car c) "\t=>\n\n" - "Expected\n" expected "\n\nActual\n" actual "\n\n")) - (return-from outer 'fail))))))) - (cond ((eql cmd 'assign) - (let ((name (cadr args)) - (defs (caddr args))) - (let ((place (assoc name *zencoding-test-cases*))) - (if place - (setf (cdr place) defs) - (setq *zencoding-test-cases* - (cons (cons name defs) *zencoding-test-cases*)))))) - (t - (loop for test in (reverse *zencoding-test-cases*) do - (let ((name (symbol-name (car test))) - (cases (cdr test))) - (let ((res (run-cases cases))) - (if (not (eql res 'fail)) - (princ (concat " [PASS] | \"" name "\" " - (number-to-string (length cases)) " tests.\n"))))))))))) - -(defmacro define-zencoding-test-case (name &rest tests) + (fn cases) + (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)))))) + (cond ((eql cmd 'assign) + (let ((name (cadr args)) + (fn (caddr args)) + (defs (cadddr args))) + (let ((place (assoc name *zencoding-test-cases*))) + (if place + (setf (cdr place) (cons fn defs)) + (setq *zencoding-test-cases* + (cons (cons name (cons fn defs)) *zencoding-test-cases*)))))) + (t + (loop for test in (reverse *zencoding-test-cases*) do + (let ((name (symbol-name (car test))) + (fn (cadr test)) + (cases (cddr test))) + (let ((res (run-cases fn cases))) + (if (not (eql res 'fail)) + (princ (concat " [PASS] | \"" name "\" " + (number-to-string (length cases)) " tests.\n"))))))))))) + +(defmacro define-zencoding-transform-test-case (name fn &rest tests) `(zencoding-test-cases 'assign ',name - ',(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) + (zencoding-join-string (cadr x) + "\n"))))) + +(defmacro define-zencoding-transform-html-test-case (name &rest tests) + `(define-zencoding-transform-test-case ,name + #'(lambda (c) (zencoding-transform (car (zencoding-expr c)))) + ,@tests)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; XML-abbrev tests -(define-zencoding-test-case Tags +(define-zencoding-transform-html-test-case Tags "a" ("") "a.x" ("") "a#q.x" ("") @@ -63,13 +69,13 @@ "#q.x.y.z" ("
" "
")) -(define-zencoding-test-case Empty-tags +(define-zencoding-transform-html-test-case Empty-tags "a/" ("") "a/.x" ("") "a/#q.x" ("") "a/#q.x.y.z" ("")) -(define-zencoding-test-case Self-closing-tags +(define-zencoding-transform-html-test-case Self-closing-tags "input type=text" ("") "img" ("") "img>metadata/*2" ("" @@ -77,7 +83,7 @@ " " "")) -(define-zencoding-test-case Siblings +(define-zencoding-transform-html-test-case Siblings "a+b" ("" "") "a+b+c" ("" @@ -92,7 +98,7 @@ "a#q.x.y.z+b#p.l.m.n" ("" "")) -(define-zencoding-test-case Tag-expansion +(define-zencoding-transform-html-test-case Tag-expansion "table+" ("" " " "
" @@ -116,7 +122,7 @@ "
  • " "")) -(define-zencoding-test-case Parent-child +(define-zencoding-transform-html-test-case Parent-child "a>b" ("") "a>b>c" ("") "a.x>b" ("") @@ -136,7 +142,7 @@ " " "")) -(define-zencoding-test-case Multiplication +(define-zencoding-transform-html-test-case Multiplication "a*1" ("") "a*2" ("" "") @@ -167,7 +173,7 @@ " " "")) -(define-zencoding-test-case Numbering +(define-zencoding-transform-html-test-case Numbering "a.$x*3" ("" "" "") @@ -226,7 +232,7 @@ "
  • name: item3 price: 3$
  • " "")) -(define-zencoding-test-case Properties +(define-zencoding-transform-html-test-case Properties "a x" ("") "a x=" ("") "a x=\"\"" ("") @@ -252,7 +258,7 @@ " " "")) -(define-zencoding-test-case Parentheses +(define-zencoding-transform-html-test-case Parentheses "(a)" ("") "(a)+(b)" ("" "") @@ -277,7 +283,7 @@ "" "")) -(define-zencoding-test-case Text +(define-zencoding-transform-html-test-case Text "a{Click me}" ("Click me") "a>{Click me}*3" ("" " Click me" @@ -305,7 +311,7 @@ "here" " to continue")) -(define-zencoding-test-case Climb-up +(define-zencoding-transform-html-test-case Climb-up "a>b>c^d" ("" " " " " @@ -348,7 +354,7 @@ " " "")) -(define-zencoding-test-case Filter-comment +(define-zencoding-transform-html-test-case Filter-comment "a.b|c" ("" "" "") @@ -361,7 +367,7 @@ "" "")) -(define-zencoding-test-case Filter-HAML +(define-zencoding-transform-html-test-case Filter-HAML "a|haml" ("%a") "a#q.x.y.z|haml" ("%a#q.x.y.z") "a#q.x x=y m=l|haml" ("%a#q.x{:x => \"y\", :m => \"l\"}") @@ -376,7 +382,7 @@ " %a{:href => \"#\"}" " %br")) -(define-zencoding-test-case Filter-Hiccup +(define-zencoding-transform-html-test-case Filter-Hiccup "a|hic" ("[:a]") "a#q.x.y.z|hic" ("[:a#q.x.y.z]") "a#q.x x=y m=l|hic" ("[:a#q.x {:x \"y\", :m \"l\"}]") @@ -393,13 +399,79 @@ " \"m\"" " [:b]]]")) -(define-zencoding-test-case Filter-escape +(define-zencoding-transform-html-test-case Filter-escape "script src="|e" ("<script src=\"&quot;\">" "</script>")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CSS-abbrev tests +(defmacro define-zencoding-unit-test-case (name fn &rest tests) + `(zencoding-test-cases 'assign ',name + ,fn + ',(loop for x on tests by #'cddr collect + (cons (car x) (cadr x))))) + +(define-zencoding-unit-test-case CSS-toknize + #'zencoding-css-toknize + "" ("") + "abc" ("abc") + "abc+" ("abc+") + "abc+cde" ("abc" "cde") + "abc++cde" ("abc+" "cde") + "abc+cde+" ("abc" "cde+") + "abc++cde+" ("abc+" "cde+") + "ab:c+0p0x#aa+p0+cde+" ("ab:c+0p0x#aa" "p0" "cde+") + "ab+#0+p+#c+x++cde+" ("ab+#0" "p+#c" "x+" "cde+")) + +(define-zencoding-unit-test-case CSS-parse-arg-number + #'zencoding-css-arg-number + "" (error "expected css number arguments") + "0" (("0" "px") . "") + "0-1-2" (("0" "px") . "1-2") + "-100" (("-100" "px") . "") + "-10e-20" (("-10" "em") . "-20") + "35p#a" (("35" "%") . "#a")) + +(define-zencoding-unit-test-case CSS-parse-arg-color + #'zencoding-css-arg-color + "" (error "expected css color argument") + "abc" (error "expected css color argument") + "#x" (error "expected css color argument") + "#a" ("#aaaaaa" . "") + "#09" ("#090909" . "") + "#3D5-2" ("#33DD55" . "-2") + "#1a2B-3" ("#1a2B1a" . "-3") + "#1A2b3x" ("#1A2b31" . "x") + "#1a2B3Cx" ("#1a2B3C" . "x") + "#1A2B3C4D-2" ("#1A2B3C" . "4D-2")) + +(define-zencoding-unit-test-case CSS-parse-args + #'zencoding-css-parse-args + "" nil + "1-2--3-4" (("1" "px") ("2" "px") ("-3" "px") ("4" "px")) + "-10-2p-30#abc" (("-10" "px") ("2" "%") ("-30" "px") "#aabbcc") + "1p2x3-4e5x" (("1" "%") ("2" "ex") ("3" "px") ("4" "em") ("5" "ex")) + "#abc#de#f-3" ("#aabbcc" "#dedede" "#ffffff" ("-3" "px"))) + +(define-zencoding-unit-test-case CSS-exprs + #'zencoding-css-expr + "" (("")) + "cl:l+ov:h+bg+" (("cl:l") ("ov:h") ("bg+")) + "m10-auto" (("m" ("10" "px") "auto")) + "bg++c" (("bg+") ("c")) + "m+0-10-10--20+p0-0" (("m+" ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) + ("p" ("0" "px") ("0" "px"))) + "bg+#abc#bc#c-3" (("bg+" "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) + +(defmacro define-zencoding-transform-css-test-case (name &rest tests) + `(define-zencoding-transform-test-case ,name + #'(lambda (c) (zencoding-css-transform (zencoding-css-expr c))) + ,@tests)) + +(define-zencoding-transform-css-test-case CSS-transform + "m0+p0-1p2e3x" ("margin:0px;" + "padding:0px 1% 2em 3ex;")) ;; start (zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From e353327def110e43716be349c9cf79420a985ca5 Mon Sep 17 00:00:00 2001 From: smihica Date: Sun, 24 Mar 2013 04:25:40 +0900 Subject: Supported subset of emmet's CSS Abbreviations. You can test it in css-mode. --- src/test.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index 70f41f3..c0d7e2b 100644 --- a/src/test.el +++ b/src/test.el @@ -49,7 +49,7 @@ (defmacro define-zencoding-transform-html-test-case (name &rest tests) `(define-zencoding-transform-test-case ,name - #'(lambda (c) (zencoding-transform (car (zencoding-expr c)))) + 'zencoding-html-transform ,@tests)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -466,7 +466,7 @@ (defmacro define-zencoding-transform-css-test-case (name &rest tests) `(define-zencoding-transform-test-case ,name - #'(lambda (c) (zencoding-css-transform (zencoding-css-expr c))) + 'zencoding-css-transform ,@tests)) (define-zencoding-transform-css-test-case CSS-transform -- cgit v1.2.3 From a6a5f57bdfa6bcbaa64c5e7088c2882255a5f627 Mon Sep 17 00:00:00 2001 From: smihica Date: Fri, 5 Apr 2013 01:00:34 +0900 Subject: Added css !important syntax support. (http://docs.emmet.io/css-abbreviations/#important-modifier). --- src/test.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index c0d7e2b..f7b7889 100644 --- a/src/test.el +++ b/src/test.el @@ -456,13 +456,13 @@ (define-zencoding-unit-test-case CSS-exprs #'zencoding-css-expr - "" (("")) - "cl:l+ov:h+bg+" (("cl:l") ("ov:h") ("bg+")) - "m10-auto" (("m" ("10" "px") "auto")) - "bg++c" (("bg+") ("c")) - "m+0-10-10--20+p0-0" (("m+" ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) - ("p" ("0" "px") ("0" "px"))) - "bg+#abc#bc#c-3" (("bg+" "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) + "" (("" nil)) + "cl:l+ov:h+bg+" (("cl:l" nil) ("ov:h" nil) ("bg+" nil)) + "m10-auto" (("m" nil ("10" "px") "auto")) + "bg++c" (("bg+" nil) ("c" nil)) + "m+0-10-10--20+p0-0" (("m+" nil ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) + ("p" nil ("0" "px") ("0" "px"))) + "bg+#abc#bc#c-3" (("bg+" nil "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) (defmacro define-zencoding-transform-css-test-case (name &rest tests) `(define-zencoding-transform-test-case ,name @@ -471,7 +471,10 @@ (define-zencoding-transform-css-test-case CSS-transform "m0+p0-1p2e3x" ("margin:0px;" - "padding:0px 1% 2em 3ex;")) + "padding:0px 1% 2em 3ex;") + "p!+m10e!+f" ("padding: !important;" + "margin:10em !important;" + "font:;")) ;; start (zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From 3d4c9de975da913fefd2d6f4e5f276ea9e03ed26 Mon Sep 17 00:00:00 2001 From: smihica Date: Sat, 6 Apr 2013 00:16:38 +0900 Subject: Supported a missing pattern like 'prop:${default}'. --- src/test.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index f7b7889..3dae692 100644 --- a/src/test.el +++ b/src/test.el @@ -474,7 +474,8 @@ "padding:0px 1% 2em 3ex;") "p!+m10e!+f" ("padding: !important;" "margin:10em !important;" - "font:;")) + "font:;") + "fs" ("font-style:italic;")) ;; start (zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From 60fa9d893bc9f4372dbb7563ba13a279e7d59212 Mon Sep 17 00:00:00 2001 From: smihica Date: Fri, 3 May 2013 19:57:48 +0900 Subject: Added #\Space division of css arguments. --- src/test.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index 3dae692..71e7f1d 100644 --- a/src/test.el +++ b/src/test.el @@ -422,7 +422,8 @@ "abc+cde+" ("abc" "cde+") "abc++cde+" ("abc+" "cde+") "ab:c+0p0x#aa+p0+cde+" ("ab:c+0p0x#aa" "p0" "cde+") - "ab+#0+p+#c+x++cde+" ("ab+#0" "p+#c" "x+" "cde+")) + "ab+#0+p+#c+x++cde+" ("ab+#0" "p+#c" "x+" "cde+") + "abc def" ("abc def")) (define-zencoding-unit-test-case CSS-parse-arg-number #'zencoding-css-arg-number @@ -431,7 +432,8 @@ "0-1-2" (("0" "px") . "1-2") "-100" (("-100" "px") . "") "-10e-20" (("-10" "em") . "-20") - "35p#a" (("35" "%") . "#a")) + "35p#a" (("35" "%") . "#a") + " 0p" (("0" "%") . "")) (define-zencoding-unit-test-case CSS-parse-arg-color #'zencoding-css-arg-color @@ -444,7 +446,15 @@ "#1a2B-3" ("#1a2B1a" . "-3") "#1A2b3x" ("#1A2b31" . "x") "#1a2B3Cx" ("#1a2B3C" . "x") - "#1A2B3C4D-2" ("#1A2B3C" . "4D-2")) + "#1A2B3C4D-2" ("#1A2B3C" . "4D-2") + " #abc" ("#aabbcc" . "")) + +(define-zencoding-unit-test-case CSS-parse-arg-something + #'zencoding-css-arg-something + "" (error "expected css argument") + "abc" ("abc" . "") + "abc def" ("abc" . " def") + "url(http://abc.com) auto" ("url(http://abc.com)" . " auto")) (define-zencoding-unit-test-case CSS-parse-args #'zencoding-css-parse-args @@ -475,7 +485,11 @@ "p!+m10e!+f" ("padding: !important;" "margin:10em !important;" "font:;") - "fs" ("font-style:italic;")) + "fs" ("font-style:italic;") + "p auto+m auto+bg+#F00 x.jpg 10 10 repeat-x" + ("padding:auto;" + "margin:auto;" + "background:#FF0000 url(x.jpg) 10px 10px repeat-x;")) ;; start (zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From 976449a2d5e28b731e848aa22dab38a05a39ecc1 Mon Sep 17 00:00:00 2001 From: smihica Date: Sat, 4 May 2013 18:08:29 +0900 Subject: Added css vendor-prefix support. (http://docs.emmet.io/css-abbreviations/vendor-prefixes/) --- src/test.el | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index 71e7f1d..1433d86 100644 --- a/src/test.el +++ b/src/test.el @@ -423,7 +423,9 @@ "abc++cde+" ("abc+" "cde+") "ab:c+0p0x#aa+p0+cde+" ("ab:c+0p0x#aa" "p0" "cde+") "ab+#0+p+#c+x++cde+" ("ab+#0" "p+#c" "x+" "cde+") - "abc def" ("abc def")) + "abc def" ("abc def") + "-abc+-xyz" ("-abc" "-xyz") + "-abc+-10" ("-abc+-10")) (define-zencoding-unit-test-case CSS-parse-arg-number #'zencoding-css-arg-number @@ -464,15 +466,21 @@ "1p2x3-4e5x" (("1" "%") ("2" "ex") ("3" "px") ("4" "em") ("5" "ex")) "#abc#de#f-3" ("#aabbcc" "#dedede" "#ffffff" ("-3" "px"))) +(define-zencoding-unit-test-case CSS-split-vendor-prefixes + #'zencoding-css-split-vendor-prefixes + "" ("" nil) + "-abc" ("abc" auto) + "-wmso-abc" ("abc" (119 109 115 111))) + (define-zencoding-unit-test-case CSS-exprs #'zencoding-css-expr - "" (("" nil)) - "cl:l+ov:h+bg+" (("cl:l" nil) ("ov:h" nil) ("bg+" nil)) - "m10-auto" (("m" nil ("10" "px") "auto")) - "bg++c" (("bg+" nil) ("c" nil)) - "m+0-10-10--20+p0-0" (("m+" nil ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) - ("p" nil ("0" "px") ("0" "px"))) - "bg+#abc#bc#c-3" (("bg+" nil "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) + "" (("" nil nil)) + "cl:l+ov:h+bg+" (("cl:l" nil nil) ("ov:h" nil nil) ("bg+" nil nil)) + "m10-auto!" (("m" nil t ("10" "px") "auto")) + "bg++c!" (("bg+" nil nil) ("c" nil t)) + "m+0-10-10--20!+p0-0" (("m+" nil t ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) + ("p" nil nil ("0" "px") ("0" "px"))) + "bg+#abc#bc#c-3!" (("bg+" nil t "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) (defmacro define-zencoding-transform-css-test-case (name &rest tests) `(define-zencoding-transform-test-case ,name @@ -480,16 +488,29 @@ ,@tests)) (define-zencoding-transform-css-test-case CSS-transform - "m0+p0-1p2e3x" ("margin:0px;" - "padding:0px 1% 2em 3ex;") - "p!+m10e!+f" ("padding: !important;" - "margin:10em !important;" - "font:;") - "fs" ("font-style:italic;") + "m0+p0-1p2e3x" ("margin: 0px;" + "padding: 0px 1% 2em 3ex;") + "p!+m10e!+f" ("padding: !important;" + "margin: 10em !important;" + "font: ;") + "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:#FF0000 url(x.jpg) 10px 10px repeat-x;")) + ("padding: auto;" + "margin: auto;" + "background: #FF0000 url(x.jpg) 10px 10px repeat-x;") + "-bdrs" ("-webkit-border-radius: ;" + "-moz-border-radius: ;" + "border-radius: ;") + "-super-foo" ("-webkit-super-foo: ;" + "-moz-super-foo: ;" + "-ms-super-foo: ;" + "-o-super-foo: ;" + "super-foo: ;") + "-wm-trf" ("-webkit-transform: ;" + "-moz-transform: ;" + "transform: ;") + ) ;; start (zencoding-test-cases) \ No newline at end of file -- cgit v1.2.3 From a93996e0bf718d79d50b0becdf0469b1715d998b Mon Sep 17 00:00:00 2001 From: smihica Date: Wed, 15 May 2013 00:41:05 +0900 Subject: Supporting HTML-Snippents phase1: Cleaned config-file and Supported html default attributes. --- src/test.el | 196 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 96 insertions(+), 100 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index 1433d86..dc731eb 100644 --- a/src/test.el +++ b/src/test.el @@ -56,10 +56,10 @@ ;; XML-abbrev tests (define-zencoding-transform-html-test-case Tags - "a" ("") - "a.x" ("") - "a#q.x" ("") - "a#q.x.y.z" ("") + "a" ("") + "a.x" ("") + "a#q.x" ("") + "a#q.x.y.z" ("") "#q" ("
    " "
    ") ".x" ("
    " @@ -70,39 +70,38 @@ "
    ")) (define-zencoding-transform-html-test-case Empty-tags - "a/" ("") - "a/.x" ("") - "a/#q.x" ("") - "a/#q.x.y.z" ("")) + "a/" ("") + "a/.x" ("") + "a/#q.x" ("") + "a/#q.x.y.z" ("")) (define-zencoding-transform-html-test-case Self-closing-tags - "input type=text" ("") - "img" ("") - "img>metadata/*2" ("" + "input type=text" ("") + "img" ("\"\"/") + "img>metadata/*2" ("\"\"" " " " " "")) (define-zencoding-transform-html-test-case Siblings - "a+b" ("" + "a+b" ("" "") - "a+b+c" ("" + "a+b+c" ("" "" "") - "a.x+b" ("" + "a.x+b" ("" "") - "a#q.x+b" ("" + "a#q.x+b" ("" "") - "a#q.x.y.z+b" ("" + "a#q.x.y.z+b" ("" "") - "a#q.x.y.z+b#p.l.m.n" ("" + "a#q.x.y.z+b#p.l.m.n" ("" "")) (define-zencoding-transform-html-test-case Tag-expansion "table+" ("" " " - " " + " " " " "
    " - "
    ") "dl+" ("
    " @@ -123,60 +122,60 @@ "")) (define-zencoding-transform-html-test-case Parent-child - "a>b" ("") - "a>b>c" ("") - "a.x>b" ("") - "a#q.x>b" ("") - "a#q.x.y.z>b" ("") - "a#q.x.y.z>b#p.l.m.n" ("") + "a>b" ("") + "a>b>c" ("") + "a.x>b" ("") + "a#q.x>b" ("") + "a#q.x.y.z>b" ("") + "a#q.x.y.z>b#p.l.m.n" ("") "#q>.x" ("
    " "
    " "
    " "
    ") - "a>b+c" ("" + "a>b+c" ("" " " " " "") - "a>b+c>d" ("" + "a>b+c>d" ("" " " " " "")) (define-zencoding-transform-html-test-case Multiplication - "a*1" ("") - "a*2" ("" - "") - "a/*2" ("" - "") - "a*2+b*2" ("" - "" + "a*1" ("") + "a*2" ("" + "") + "a/*2" ("" + "") + "a*2+b*2" ("" + "" "" "") - "a*2>b*2" ("" + "a*2>b*2" ("" " " " " "" - "" + "" " " " " "") - "a>b*2" ("" + "a>b*2" ("" " " " " "") - "a#q.x>b#q.x*2" ("" + "a#q.x>b#q.x*2" ("" " " " " "") - "a#q.x>b/#q.x*2" ("" + "a#q.x>b/#q.x*2" ("" " " " " "")) (define-zencoding-transform-html-test-case Numbering - "a.$x*3" ("" - "" - "") + "a.$x*3" ("" + "" + "") "ul>li.item$*3" ("
      " "
    • " "
    • " @@ -195,12 +194,12 @@ "
    • " "
    • " "
    ") - "a.$*2>b.$$@-*3" ("" + "a.$*2>b.$$@-*3" ("" " " " " " " "" - "" + "" " " " " " " @@ -208,14 +207,14 @@ "(div>(a#id$$*2)+b.c$@-3+c#d$)*2" ("
    " - " " - " " + " " + " " " " " " "
    " "
    " - " " - " " + " " + " " " " " " "
    ") @@ -233,66 +232,66 @@ "")) (define-zencoding-transform-html-test-case Properties - "a x" ("") - "a x=" ("") - "a x=\"\"" ("") - "a x=y" ("") - "a x=\"y\"" ("") - "a x=\"()\"" ("") - "a x m" ("") - "a x= m=\"\"" ("") - "a x=y m=l" ("") - "a/ x=y m=l" ("") - "a#foo x=y m=l" ("") - "a.foo x=y m=l" ("") - "a#foo.bar.mu x=y m=l" ("") - "a/#foo.bar.mu x=y m=l" ("") - "a x=y+b" ("" + "a x" ("") + "a x=" ("") + "a x=\"\"" ("") + "a x=y" ("") + "a x=\"y\"" ("") + "a x=\"()\"" ("") + "a x m" ("") + "a x= m=\"\"" ("") + "a x=y m=l" ("") + "a/ x=y m=l" ("") + "a#foo x=y m=l" ("") + "a.foo x=y m=l" ("") + "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 x=y" ("" "") - "a x=y>b" ("") - "a x=y>b x=y" ("") - "a x=y>b x=y+c x=y" ("" + "a x=y>b" ("") + "a x=y>b x=y" ("") + "a x=y>b x=y+c x=y" ("" " " " " "")) (define-zencoding-transform-html-test-case Parentheses - "(a)" ("") - "(a)+(b)" ("" + "(a)" ("") + "(a)+(b)" ("" "") - "a>(b)" ("") - "(a>b)>c" ("") - "(a>b)+c" ("" + "a>(b)" ("") + "(a>b)>c" ("") + "(a>b)+c" ("" "") "z+(a>b)+c+k" ("" - "" + "" "" "") - "(a)*2" ("" - "") - "((a)*2)" ("" - "") - "((a))*2" ("" - "") - "(a>b)*2" ("" - "") - "(a+b)*2" ("" + "(a)*2" ("" + "") + "((a)*2)" ("" + "") + "((a))*2" ("" + "") + "(a>b)*2" ("" + "") + "(a+b)*2" ("" "" - "" + "" "")) (define-zencoding-transform-html-test-case Text - "a{Click me}" ("Click me") - "a>{Click me}*3" ("" + "a{Click me}" ("Click me") + "a>{Click me}*3" ("" " Click me" " Click me" " Click me" "") - "a{click}+b{here}" ("click" + "a{click}+b{here}" ("click" "here") - "a>{click}+b{here}" ("" + "a>{click}+b{here}" ("" " click" " here" "") @@ -300,30 +299,28 @@ "p>{Click }+a{here}+{ to continue}" ("

    " " Click " - " here" + " here" " to continue" "

    ") "p{Click }+a{here}+{ to continue}" - ("

    " - " Click " - "

    " - "here" + ("

    Click

    " + "here" " to continue")) (define-zencoding-transform-html-test-case Climb-up - "a>b>c^d" ("" + "a>b>c^d" ("" " " " " "") - "a>b>c^^d" ("" + "a>b>c^^d" ("" "") - "a*2>b*2>c^d" ("" + "a*2>b*2>c^d" ("" " " " " " " "" - "" + "" " " " " " " @@ -332,14 +329,13 @@ "div+a>p>span{foo}+em>b^^^p" ("
    " "
    " - "
    " + "" "

    " " foo" " " "

    " "
    " - "

    " - "

    ") + "

    ") "div+div>p>span+em^blockquote{foo}" ("
    " @@ -356,7 +352,7 @@ (define-zencoding-transform-html-test-case Filter-comment "a.b|c" ("" - "" + "" "") "#a>.b|c" ("" "
    " -- cgit v1.2.3 From ad1f8f3d0347d81756921214e4611cfdad9a1327 Mon Sep 17 00:00:00 2001 From: smihica Date: Wed, 15 May 2013 01:29:00 +0900 Subject: Fixed a bug that CSS snipets @xxx is not working. --- src/test.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index dc731eb..f651928 100644 --- a/src/test.el +++ b/src/test.el @@ -506,6 +506,11 @@ "-wm-trf" ("-webkit-transform: ;" "-moz-transform: ;" "transform: ;") + "@m print 1" ("@media print {" + " 1px" + "}") + "@i http://github.com/smihica/index.css" + ("@import url(http://github.com/smihica/index.css);") ) ;; start -- cgit v1.2.3 From 4713a355010ff4a51e53470c2e8c101bbdaf177b Mon Sep 17 00:00:00 2001 From: smihica Date: Sat, 18 May 2013 17:56:33 +0900 Subject: Some trivial improvements. --- src/test.el | 119 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 48 deletions(-) (limited to 'src/test.el') diff --git a/src/test.el b/src/test.el index f651928..dc021ae 100644 --- a/src/test.el +++ b/src/test.el @@ -141,6 +141,48 @@ " " "")) +(define-zencoding-transform-html-test-case Climb-up + "a>b>c^d" ("" + " " + " " + "") + "a>b>c^^d" ("" + "") + "a*2>b*2>c^d" ("" + " " + " " + " " + "" + "" + " " + " " + " " + "") + + "div+a>p>span{foo}+em>b^^^p" + ("
    " + "
    " + "" + "

    " + " foo" + " " + "

    " + "
    " + "

    ") + + "div+div>p>span+em^blockquote{foo}" + ("
    " + "
    " + "
    " + "

    " + " " + " " + "

    " + "
    " + " foo" + "
    " + "
    ")) + (define-zencoding-transform-html-test-case Multiplication "a*1" ("") "a*2" ("" @@ -306,49 +348,11 @@ "p{Click }+a{here}+{ to continue}" ("

    Click

    " "here" - " to continue")) + " to continue") -(define-zencoding-transform-html-test-case Climb-up - "a>b>c^d" ("" - " " - " " - "") - "a>b>c^^d" ("" - "") - "a*2>b*2>c^d" ("" - " " - " " - " " - "" - "" - " " - " " - " " - "") + "xxx#id.cls p=1{txt}" + ("txt")) - "div+a>p>span{foo}+em>b^^^p" - ("
    " - "
    " - "" - "

    " - " foo" - " " - "

    " - "
    " - "

    ") - - "div+div>p>span+em^blockquote{foo}" - ("
    " - "
    " - "
    " - "

    " - " " - " " - "

    " - "
    " - " foo" - "
    " - "
    ")) (define-zencoding-transform-html-test-case Filter-comment "a.b|c" ("" @@ -438,14 +442,14 @@ "" (error "expected css color argument") "abc" (error "expected css color argument") "#x" (error "expected css color argument") - "#a" ("#aaaaaa" . "") + "#a" ("#aaa" . "") "#09" ("#090909" . "") - "#3D5-2" ("#33DD55" . "-2") + "#3D5-2" ("#3D5" . "-2") "#1a2B-3" ("#1a2B1a" . "-3") "#1A2b3x" ("#1A2b31" . "x") "#1a2B3Cx" ("#1a2B3C" . "x") "#1A2B3C4D-2" ("#1A2B3C" . "4D-2") - " #abc" ("#aabbcc" . "")) + " #abc" ("#abc" . "")) (define-zencoding-unit-test-case CSS-parse-arg-something #'zencoding-css-arg-something @@ -458,9 +462,9 @@ #'zencoding-css-parse-args "" nil "1-2--3-4" (("1" "px") ("2" "px") ("-3" "px") ("4" "px")) - "-10-2p-30#abc" (("-10" "px") ("2" "%") ("-30" "px") "#aabbcc") + "-10-2p-30#abc" (("-10" "px") ("2" "%") ("-30" "px") "#abc") "1p2x3-4e5x" (("1" "%") ("2" "ex") ("3" "px") ("4" "em") ("5" "ex")) - "#abc#de#f-3" ("#aabbcc" "#dedede" "#ffffff" ("-3" "px"))) + "#abc#de#f-3" ("#abc" "#dedede" "#fff" ("-3" "px"))) (define-zencoding-unit-test-case CSS-split-vendor-prefixes #'zencoding-css-split-vendor-prefixes @@ -476,7 +480,7 @@ "bg++c!" (("bg+" nil nil) ("c" nil t)) "m+0-10-10--20!+p0-0" (("m+" nil t ("0" "px") ("10" "px") ("10" "px") ("-20" "px")) ("p" nil nil ("0" "px") ("0" "px"))) - "bg+#abc#bc#c-3!" (("bg+" nil t "#aabbcc" "#bcbcbc" "#cccccc" ("-3" "px")))) + "bg+#abc#bc#c-3!" (("bg+" nil t "#abc" "#bcbcbc" "#ccc" ("-3" "px")))) (defmacro define-zencoding-transform-css-test-case (name &rest tests) `(define-zencoding-transform-test-case ,name @@ -484,6 +488,25 @@ ,@tests)) (define-zencoding-transform-css-test-case CSS-transform + ;; supplying values with units + "m10" ("margin: 10px;") + "m1.5" ("margin: 1.5em;") + "m1.5ex" ("margin: 1.5ex;") + "m1.5x" ("margin: 1.5ex;") + "m10foo" ("margin: 10foo;") + "m10ex20em" ("margin: 10ex 20em;") + "m10x20e" ("margin: 10ex 20em;") + "m10x-5" ("margin: 10ex -5px;") + ;; Color values + "c#3" ("color: #333;") + "bd5#0rgb" ("border: 5px rgb(0,0,0);") + "bd5#20rgb" ("border: 5px rgb(32,32,32);") + "bd5#0s" ("border: 5px #000 solid;") + "bd5#2rgbs" ("border: 5px rgb(34,34,34) solid;") + ;; Unitless property + "lh2" ("line-height: 2;") + "fw400" ("font-weight: 400;") + ;; "m0+p0-1p2e3x" ("margin: 0px;" "padding: 0px 1% 2em 3ex;") "p!+m10e!+f" ("padding: !important;" @@ -494,7 +517,7 @@ "p auto+m auto+bg+#F00 x.jpg 10 10 repeat-x" ("padding: auto;" "margin: auto;" - "background: #FF0000 url(x.jpg) 10px 10px repeat-x;") + "background: #F00 url(x.jpg) 10px 10px repeat-x;") "-bdrs" ("-webkit-border-radius: ;" "-moz-border-radius: ;" "border-radius: ;") -- cgit v1.2.3