Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Stylus #751

Merged
merged 1 commit into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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