diff --git a/tests/languages/stylus/atrule-declaration_feature.test b/tests/languages/stylus/atrule-declaration_feature.test new file mode 100644 index 0000000000..e6c4c7c89a --- /dev/null +++ b/tests/languages/stylus/atrule-declaration_feature.test @@ -0,0 +1,31 @@ +@media print +@import "reset.css" +@font-face { +@keyframes { +@media (max-{foo}: bar) + +---------------------------------------------------- + +[ + ["atrule-declaration", [["atrule", "@media"], " print"]], + ["atrule-declaration", [["atrule", "@import"], ["string", "\"reset.css\""]]], + ["atrule-declaration", [["atrule", "@font-face"], ["punctuation", "{"]]], + ["atrule-declaration", [["atrule", "@keyframes"], ["punctuation", "{"]]], + ["atrule-declaration", [ + ["atrule", "@media"], + ["punctuation", "("], + "max-", + ["interpolation", [ + ["punctuation", "{"], + "foo", + ["punctuation", "}"] + ]], + ["punctuation", ":"], + " bar", + ["punctuation", ")"] + ]] +] + +---------------------------------------------------- + +Checks for at-rules. \ No newline at end of file diff --git a/tests/languages/stylus/boolean_feature.test b/tests/languages/stylus/boolean_feature.test new file mode 100644 index 0000000000..37eff87d7a --- /dev/null +++ b/tests/languages/stylus/boolean_feature.test @@ -0,0 +1,21 @@ +a = true +b = false + +---------------------------------------------------- + +[ + ["variable-declaration", [ + ["variable", "a"], + ["operator", "="], + ["boolean", "true"] + ]], + ["variable-declaration", [ + ["variable", "b"], + ["operator", "="], + ["boolean", "false"] + ]] +] + +---------------------------------------------------- + +Checks for booleans. \ No newline at end of file diff --git a/tests/languages/stylus/comment_feature.test b/tests/languages/stylus/comment_feature.test new file mode 100644 index 0000000000..90f974cf3d --- /dev/null +++ b/tests/languages/stylus/comment_feature.test @@ -0,0 +1,18 @@ +/**/ +/* foo +bar */ +// +// foobar + +---------------------------------------------------- + +[ + ["comment", "/**/"], + ["comment", "/* foo\r\nbar */"], + ["comment", "//"], + ["comment", "// foobar"] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file diff --git a/tests/languages/stylus/func_feature.test b/tests/languages/stylus/func_feature.test new file mode 100644 index 0000000000..7f2c346774 --- /dev/null +++ b/tests/languages/stylus/func_feature.test @@ -0,0 +1,51 @@ +border-radius(n) + -webkit-border-radius n + -moz-border-radius n + border-radius n + +form input[type=button] + border-radius(5px) + color foo() + +---------------------------------------------------- + +[ + ["func", [ + ["function", "border-radius"], + ["punctuation", "("], + "n", + ["punctuation", ")"] + ]], + ["property-declaration", [ + ["property", ["-webkit-border-radius"]], + " n" + ]], + ["property-declaration", [ + ["property", ["-moz-border-radius"]], + " n" + ]], + ["property-declaration", [ + ["property", ["border-radius"]], + " n" + ]], + ["selector", ["form input[type=button]"]], + ["func", [ + ["function", "border-radius"], + ["punctuation", "("], + ["number", "5"], + "px", + ["punctuation", ")"] + ]], + ["property-declaration", [ + ["property", ["color"]], + ["func", [ + ["function", "foo"], + ["punctuation", "("], + ["punctuation", ")"] + ]] + ]] +] + +---------------------------------------------------- + +Checks for functions. \ No newline at end of file diff --git a/tests/languages/stylus/hexcode_feature.test b/tests/languages/stylus/hexcode_feature.test new file mode 100644 index 0000000000..d85fcb9189 --- /dev/null +++ b/tests/languages/stylus/hexcode_feature.test @@ -0,0 +1,29 @@ +color: #fff +color: #FA3 +color: #f7c111 +color: #9F4ABB + +---------------------------------------------------- + +[ + ["property-declaration", [ + ["property", ["color"]], ["punctuation", ":"], + ["hexcode", "#fff"] + ]], + ["property-declaration", [ + ["property", ["color"]], ["punctuation", ":"], + ["hexcode", "#FA3"] + ]], + ["property-declaration", [ + ["property", ["color"]], ["punctuation", ":"], + ["hexcode", "#f7c111"] + ]], + ["property-declaration", [ + ["property", ["color"]], ["punctuation", ":"], + ["hexcode", "#9F4ABB"] + ]] +] + +---------------------------------------------------- + +Checks for hexadecimal values. \ No newline at end of file diff --git a/tests/languages/stylus/important_feature.test b/tests/languages/stylus/important_feature.test new file mode 100644 index 0000000000..225c1e0539 --- /dev/null +++ b/tests/languages/stylus/important_feature.test @@ -0,0 +1,22 @@ +color: red !important +@extend foo !optional + +---------------------------------------------------- + +[ + ["property-declaration", [ + ["property", ["color"]], + ["punctuation", ":"], + " red ", + ["important", "!important"] + ]], + ["atrule-declaration", [ + ["atrule", "@extend"], + " foo ", + ["important", "!optional"] + ]] +] + +---------------------------------------------------- + +Checks for !important and !optional. \ No newline at end of file diff --git a/tests/languages/stylus/keyword_feature.test b/tests/languages/stylus/keyword_feature.test new file mode 100644 index 0000000000..5182775191 --- /dev/null +++ b/tests/languages/stylus/keyword_feature.test @@ -0,0 +1,44 @@ +for i in 1..5 +if a == 3 +z-index: 1 unless @z-index; +return pair[1] if pair[0] == key for pair in hash + +---------------------------------------------------- + +[ + ["statement", [ + ["keyword", "for"], + " i ", + ["operator", "in"], + ["number", "1"], + ["operator", ".."], + ["number", "5"] + ]], + ["statement", [ + ["keyword", "if"], + " a ", + ["operator", "=="], + ["number", "3"] + ]], + ["property-declaration", [ + ["property", ["z-index"]], + ["punctuation", ":"], + ["number", "1"], + ["keyword", "unless"], + ["keyword", "@z-index"], + ["punctuation", ";"] + ]], + ["statement", [ + ["keyword", "return"], " pair", + ["punctuation", "["], ["number", "1"], ["punctuation", "]"], + ["keyword", "if"], " pair", + ["punctuation", "["], ["number", "0"], ["punctuation", "]"], + ["operator", "=="], " key ", + ["keyword", "for"], " pair ", + ["operator", "in"], " hash" + ]] +] + +---------------------------------------------------- + +Checks for statements and keywords. \ No newline at end of file diff --git a/tests/languages/stylus/number_feature.test b/tests/languages/stylus/number_feature.test new file mode 100644 index 0000000000..f3a0710903 --- /dev/null +++ b/tests/languages/stylus/number_feature.test @@ -0,0 +1,32 @@ +z-index 42 +foo = 3.14159 +width: 23% +bar = 1.5% + +---------------------------------------------------- + +[ + ["property-declaration", [ + ["property", ["z-index"]], + ["number", "42"] + ]], + ["variable-declaration", [ + ["variable", "foo"], + ["operator", "="], + ["number", "3.14159"] + ]], + ["property-declaration", [ + ["property", ["width"]], + ["punctuation", ":"], + ["number", "23%"] + ]], + ["variable-declaration", [ + ["variable", "bar"], + ["operator", "="], + ["number", "1.5%"] + ]] +] + +---------------------------------------------------- + +Checks for numbers and percentages. \ No newline at end of file diff --git a/tests/languages/stylus/operator_feature.test b/tests/languages/stylus/operator_feature.test new file mode 100644 index 0000000000..79f6567100 --- /dev/null +++ b/tests/languages/stylus/operator_feature.test @@ -0,0 +1,273 @@ +a = !b +b = b != a +c = ~b +d = c + b +d += a +e = d - c +e -= b +f = a * b +g = c ** d +g *= f +h = g / f +h /= e +i = h % g +i %= f +j = 1..5 +k = 1...5 +l = k < j +m = l <= k +n = m > l +o = n >= m +p = o ? n : m +q ?= p +r = q == p +s := r +t = s && r +u = t || s +v = u and t +w = v or u +x = 1 in w +y = true is true +z = true is not false +aa = z isnt y +ab = #fff is a 'rgba' +ac = ab is defined +ad = not ac + +---------------------------------------------------- + +[ + ["variable-declaration", [ + ["variable", "a"], + ["operator", "="], + ["operator", "!"], + "b" + ]], + ["variable-declaration", [ + ["variable", "b"], + ["operator", "="], + " b ", + ["operator", "!="], + " a" + ]], + ["variable-declaration", [ + ["variable", "c"], + ["operator", "="], + ["operator", "~"], + "b" + ]], + ["variable-declaration", [ + ["variable", "d"], + ["operator", "="], + " c ", + ["operator", "+"], + " b" + ]], + ["variable-declaration", [ + ["variable", "d"], + ["operator", "+="], + " a" + ]], + ["variable-declaration", [ + ["variable", "e"], + ["operator", "="], + " d ", + ["operator", "-"], + " c" + ]], + ["variable-declaration", [ + ["variable", "e"], + ["operator", "-="], + " b" + ]], + ["variable-declaration", [ + ["variable", "f"], + ["operator", "="], + " a ", + ["operator", "*"], + " b" + ]], + ["variable-declaration", [ + ["variable", "g"], + ["operator", "="], + " c ", + ["operator", "**"], + " d" + ]], + ["variable-declaration", [ + ["variable", "g"], + ["operator", "*="], + " f" + ]], + ["variable-declaration", [ + ["variable", "h"], + ["operator", "="], + " g ", + ["operator", "/"], + " f" + ]], + ["variable-declaration", [ + ["variable", "h"], + ["operator", "/="], + " e" + ]], + ["variable-declaration", [ + ["variable", "i"], + ["operator", "="], + " h ", + ["operator", "%"], + " g" + ]], + ["variable-declaration", [ + ["variable", "i"], + ["operator", "%="], + " f" + ]], + ["variable-declaration", [ + ["variable", "j"], + ["operator", "="], + ["number", "1"], + ["operator", ".."], + ["number", "5"] + ]], + ["variable-declaration", [ + ["variable", "k"], + ["operator", "="], + ["number", "1"], + ["operator", "..."], + ["number", "5"] + ]], + ["variable-declaration", [ + ["variable", "l"], + ["operator", "="], + " k ", + ["operator", "<"], + " j" + ]], + ["variable-declaration", [ + ["variable", "m"], + ["operator", "="], + " l ", + ["operator", "<="], + " k" + ]], + ["variable-declaration", [ + ["variable", "n"], + ["operator", "="], + " m ", + ["operator", ">"], + " l" + ]], + ["variable-declaration", [ + ["variable", "o"], + ["operator", "="], + " n ", + ["operator", ">="], + " m" + ]], + ["variable-declaration", [ + ["variable", "p"], + ["operator", "="], + " o ", + ["operator", "?"], + " n ", + ["punctuation", ":"], + " m" + ]], + ["variable-declaration", [ + ["variable", "q"], + ["operator", "?="], + " p" + ]], + ["variable-declaration", [ + ["variable", "r"], + ["operator", "="], + " q ", + ["operator", "=="], + " p" + ]], + ["variable-declaration", [ + ["variable", "s"], + ["operator", ":="], + " r" + ]], + ["variable-declaration", [ + ["variable", "t"], + ["operator", "="], + " s ", + ["operator", "&&"], + " r" + ]], + ["variable-declaration", [ + ["variable", "u"], + ["operator", "="], + " t ", + ["operator", "||"], + " s" + ]], + ["variable-declaration", [ + ["variable", "v"], + ["operator", "="], + " u ", + ["operator", "and"], + " t" + ]], + ["variable-declaration", [ + ["variable", "w"], + ["operator", "="], + " v ", + ["operator", "or"], + " u" + ]], + ["variable-declaration", [ + ["variable", "x"], + ["operator", "="], + ["number", "1"], + ["operator", "in"], + " w" + ]], + ["variable-declaration", [ + ["variable", "y"], + ["operator", "="], + ["boolean", "true"], + ["operator", "is"], + ["boolean", "true"] + ]], + ["variable-declaration", [ + ["variable", "z"], + ["operator", "="], + ["boolean", "true"], + ["operator", "is not"], + ["boolean", "false"] + ]], + ["variable-declaration", [ + ["variable", "aa"], + ["operator", "="], + " z ", + ["operator", "isnt"], + " y" + ]], + ["variable-declaration", [ + ["variable", "ab"], + ["operator", "="], + ["hexcode", "#fff"], + ["operator", "is a"], + ["string", "'rgba'"] + ]], + ["variable-declaration", [ + ["variable", "ac"], + ["operator", "="], + " ab ", + ["operator", "is defined"] + ]], + ["variable-declaration", [ + ["variable", "ad"], + ["operator", "="], + ["operator", "not"], + " ac" + ]] +] + +---------------------------------------------------- + +Checks for all operators. \ No newline at end of file diff --git a/tests/languages/stylus/property-declaration_feature.test b/tests/languages/stylus/property-declaration_feature.test new file mode 100644 index 0000000000..89fa0e1b08 --- /dev/null +++ b/tests/languages/stylus/property-declaration_feature.test @@ -0,0 +1,52 @@ +div + width 40px + color: red + background: blue; + +div { +background-{foo}: bar; +} + +div + {foo} bar + +---------------------------------------------------- + +[ + ["selector", ["div"]], + ["property-declaration", [ + ["property", ["width"]], ["number", "40"], "px" + ]], + ["property-declaration", [ + ["property", ["color"]], ["punctuation", ":"], " red" + ]], + ["property-declaration", [ + ["property", ["background"]], ["punctuation", ":"], " blue", ["punctuation", ";"] + ]], + ["selector", ["div ", ["punctuation", "{"]]], + ["property-declaration", [ + ["property", [ + "background-", + ["interpolation", [ + ["punctuation", "{"], "foo", ["punctuation", "}"] + ]] + ]], + ["punctuation", ":"], + " bar", + ["punctuation", ";"] + ]], + ["punctuation", "}"], + ["selector", ["div"]], + ["property-declaration", [ + ["property", [ + ["interpolation", [ + ["punctuation", "{"], "foo", ["punctuation", "}"] + ]] + ]], + " bar" + ]] +] + +---------------------------------------------------- + +Checks for property declarations. \ No newline at end of file diff --git a/tests/languages/stylus/selector_feature.test b/tests/languages/stylus/selector_feature.test new file mode 100644 index 0000000000..c07ed10396 --- /dev/null +++ b/tests/languages/stylus/selector_feature.test @@ -0,0 +1,49 @@ +div +span[foo=bar] + color red + +div input, +input:nth-child(2n) + color red + +#foo + .bar::before + color red + +#foo + .bar { +color red +} + +{foo} {bar}:hover + color red + +---------------------------------------------------- + +[ + ["selector", ["div\r\nspan[foo=bar]"]], + ["property-declaration", [["property", ["color"]], " red"]], + ["selector", ["div input", ["punctuation", ","], "\r\ninput:nth-child(2n)"]], + ["property-declaration", [["property", ["color"]], " red"]], + ["selector", ["#foo"]], + ["selector", [".bar::before"]], + ["property-declaration", [["property", ["color"]], " red"]], + ["selector", ["#foo"]], + ["selector", [".bar ", ["punctuation", "{"]]], + ["property-declaration", [["property", ["color"]], " red"]], + ["punctuation", "}"], + ["selector", [ + ["interpolation", [ + ["punctuation", "{"], "foo", ["punctuation", "}"] + ]], + ["interpolation", [ + ["punctuation", "{"], "bar", ["punctuation", "}"] + ]], + ":hover" + ]], + ["property-declaration", [["property", ["color"]], " red"]] +] + +---------------------------------------------------- + +Checks for selectors. \ No newline at end of file diff --git a/tests/languages/stylus/string_feature.test b/tests/languages/stylus/string_feature.test new file mode 100644 index 0000000000..934f94f077 --- /dev/null +++ b/tests/languages/stylus/string_feature.test @@ -0,0 +1,33 @@ +content: "" +content: "foo" +content: '' +content: 'foo' + +---------------------------------------------------- + +[ + ["property-declaration", [ + ["property", ["content"]], + ["punctuation", ":"], + ["string", "\"\""] + ]], + ["property-declaration", [ + ["property", ["content"]], + ["punctuation", ":"], + ["string", "\"foo\""] + ]], + ["property-declaration", [ + ["property", ["content"]], + ["punctuation", ":"], + ["string", "''"] + ]], + ["property-declaration", [ + ["property", ["content"]], + ["punctuation", ":"], + ["string", "'foo'"] + ]] +] + +---------------------------------------------------- + +Checks for strings. \ No newline at end of file diff --git a/tests/languages/stylus/url_feature.test b/tests/languages/stylus/url_feature.test new file mode 100644 index 0000000000..87bd1691a7 --- /dev/null +++ b/tests/languages/stylus/url_feature.test @@ -0,0 +1,21 @@ +background: url('foo.png') +background: url("foo/bar.jpg") + +---------------------------------------------------- + +[ + ["property-declaration", [ + ["property", ["background"]], + ["punctuation", ":"], + ["url", "url('foo.png')"] + ]], + ["property-declaration", [ + ["property", ["background"]], + ["punctuation", ":"], + ["url", "url(\"foo/bar.jpg\")"] + ]] +] + +---------------------------------------------------- + +Checks for urls. \ No newline at end of file diff --git a/tests/languages/stylus/variable-declaration_feature.test b/tests/languages/stylus/variable-declaration_feature.test new file mode 100644 index 0000000000..1d68f9dfe0 --- /dev/null +++ b/tests/languages/stylus/variable-declaration_feature.test @@ -0,0 +1,33 @@ +foo = 'bar' +a = 4 +bar-baz = 5 +a += 8 + +---------------------------------------------------- + +[ + ["variable-declaration", [ + ["variable", "foo"], + ["operator", "="], + ["string", "'bar'"] + ]], + ["variable-declaration", [ + ["variable", "a"], + ["operator", "="], + ["number", "4"] + ]], + ["variable-declaration", [ + ["variable", "bar-baz"], + ["operator", "="], + ["number", "5"] + ]], + ["variable-declaration", [ + ["variable", "a"], + ["operator", "+="], + ["number", "8"] + ]] +] + +---------------------------------------------------- + +Checks for variable declarations. \ No newline at end of file