| 1 | // Copyright 2019 the SimpleCSS Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT |
| 3 | |
| 4 | //! Stylesheet |
| 5 | |
| 6 | use simplecssrust-analyzer cargo simplecss 0.2.2 crate/::*; |
| 7 | |
| 8 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 9 | fn style_01rust-analyzer cargo simplecss 0.2.2 style_01().() { |
| 10 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().(""); |
| 11 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); |
| 12 | } |
| 13 | |
| 14 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 15 | fn style_02rust-analyzer cargo simplecss 0.2.2 style_02().() { |
| 16 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a {}"); |
| 17 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); |
| 18 | } |
| 19 | |
| 20 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 21 | fn style_03rust-analyzer cargo simplecss 0.2.2 style_03().() { |
| 22 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a { color:red }"); |
| 23 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 24 | } |
| 25 | |
| 26 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 27 | fn style_04rust-analyzer cargo simplecss 0.2.2 style_04().() { |
| 28 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("/**/"); |
| 29 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); |
| 30 | } |
| 31 | |
| 32 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 33 | fn style_05rust-analyzer cargo simplecss 0.2.2 style_05().() { |
| 34 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a { color:red } /**/"); |
| 35 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 36 | } |
| 37 | |
| 38 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 39 | fn style_06rust-analyzer cargo simplecss 0.2.2 style_06().() { |
| 40 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a, b { color:red }"); |
| 41 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }\nb { color:red; }"); |
| 42 | } |
| 43 | |
| 44 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 45 | fn style_07rust-analyzer cargo simplecss 0.2.2 style_07().() { |
| 46 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a, { color:red }"); |
| 47 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 48 | } |
| 49 | |
| 50 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 51 | fn style_08rust-analyzer cargo simplecss 0.2.2 style_08().() { |
| 52 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a,, { color:red }"); |
| 53 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 54 | } |
| 55 | |
| 56 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 57 | fn style_09rust-analyzer cargo simplecss 0.2.2 style_09().() { |
| 58 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a,,b { color:red }"); |
| 59 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }\nb { color:red; }"); |
| 60 | } |
| 61 | |
| 62 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 63 | fn style_10rust-analyzer cargo simplecss 0.2.2 style_10().() { |
| 64 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().(",a { color:red }"); |
| 65 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 66 | } |
| 67 | |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn style_11rust-analyzer cargo simplecss 0.2.2 style_11().() { |
| 70 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("@import \"subs.css\";\na { color:red }"); |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 72 | } |
| 73 | |
| 74 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 75 | fn style_12rust-analyzer cargo simplecss 0.2.2 style_12().() { |
| 76 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().( |
| 77 | "\ |
| 78 | @media screen { |
| 79 | p:before { content: 'Hello'; } |
| 80 | } |
| 81 | a { color:red }", |
| 82 | ); |
| 83 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "a { color:red; }"); |
| 84 | } |
| 85 | |
| 86 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 87 | fn style_13rust-analyzer cargo simplecss 0.2.2 style_13().() { |
| 88 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("a > { color:red }"); |
| 89 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); |
| 90 | } |
| 91 | |
| 92 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 93 | fn style_14rust-analyzer cargo simplecss 0.2.2 style_14().() { |
| 94 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color:green; color }"); |
| 95 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "p { color:green; }"); |
| 96 | } |
| 97 | |
| 98 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 99 | fn style_15rust-analyzer cargo simplecss 0.2.2 style_15().() { |
| 100 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color; color:green }"); |
| 101 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); // TODO: should be 'p { color:green; }' |
| 102 | } |
| 103 | |
| 104 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 105 | fn style_16rust-analyzer cargo simplecss 0.2.2 style_16().() { |
| 106 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color:green; color: }"); |
| 107 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "p { color:green; }"); |
| 108 | } |
| 109 | |
| 110 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 111 | fn style_17rust-analyzer cargo simplecss 0.2.2 style_17().() { |
| 112 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color:green; color:; color:red; }"); |
| 113 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "p { color:green; }"); |
| 114 | } |
| 115 | |
| 116 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 117 | fn style_18rust-analyzer cargo simplecss 0.2.2 style_18().() { |
| 118 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color:green; color{;color:maroon} }"); |
| 119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "p { color:green; }"); |
| 120 | } |
| 121 | |
| 122 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 123 | fn style_19rust-analyzer cargo simplecss 0.2.2 style_19().() { |
| 124 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().("p { color{;color:maroon} color:green; }"); |
| 125 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); // TODO: should be 'p { color:green; }' |
| 126 | } |
| 127 | |
| 128 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 129 | fn style_20rust-analyzer cargo simplecss 0.2.2 style_20().() { |
| 130 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().( |
| 131 | "\ |
| 132 | h1 { color: green } |
| 133 | h2 & h3 { color: red } |
| 134 | h4 { color: black } |
| 135 | ", |
| 136 | ); |
| 137 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 138 | style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 139 | "h1 { color:green; }\nh4 { color:black; }" |
| 140 | ); |
| 141 | } |
| 142 | |
| 143 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 144 | fn style_21rust-analyzer cargo simplecss 0.2.2 style_21().() { |
| 145 | let style = StyleSheetrust-analyzer cargo simplecss 0.2.2 StyleSheet#::parserust-analyzer cargo simplecss 0.2.2 impl#[`StyleSheet<'a>`]parse().(":le>*"); |
| 146 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(style.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ""); |
| 147 | } |