Skip to content

Commit

Permalink
Merge pull request #751 from Golmote/tests-stylus
Browse files Browse the repository at this point in the history
Add tests for Stylus
  • Loading branch information
Golmote committed Sep 8, 2015
2 parents c053c9e + d9f4021 commit a6a2711
Show file tree
Hide file tree
Showing 14 changed files with 709 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/languages/stylus/atrule-declaration_feature.test
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions tests/languages/stylus/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions tests/languages/stylus/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**/
/* foo
bar */
//
// foobar

----------------------------------------------------

[
["comment", "/**/"],
["comment", "/* foo\r\nbar */"],
["comment", "//"],
["comment", "// foobar"]
]

----------------------------------------------------

Checks for comments.
51 changes: 51 additions & 0 deletions tests/languages/stylus/func_feature.test
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions tests/languages/stylus/hexcode_feature.test
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 22 additions & 0 deletions tests/languages/stylus/important_feature.test
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 44 additions & 0 deletions tests/languages/stylus/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 32 additions & 0 deletions tests/languages/stylus/number_feature.test
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit a6a2711

Please sign in to comment.