File: stylesheet.rs

package info (click to toggle)
rust-simplecss 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 196 kB
  • sloc: makefile: 2
file content (135 lines) | stat: -rw-r--r-- 3,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use simplecss::*;

#[test]
fn style_01() {
    let style = StyleSheet::parse("");
    assert_eq!(style.to_string(), "");
}

#[test]
fn style_02() {
    let style = StyleSheet::parse("a {}");
    assert_eq!(style.to_string(), "");
}

#[test]
fn style_03() {
    let style = StyleSheet::parse("a { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_04() {
    let style = StyleSheet::parse("/**/");
    assert_eq!(style.to_string(), "");
}

#[test]
fn style_05() {
    let style = StyleSheet::parse("a { color:red } /**/");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_06() {
    let style = StyleSheet::parse("a, b { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }\nb { color:red; }");
}

#[test]
fn style_07() {
    let style = StyleSheet::parse("a, { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_08() {
    let style = StyleSheet::parse("a,, { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_09() {
    let style = StyleSheet::parse("a,,b { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }\nb { color:red; }");
}

#[test]
fn style_10() {
    let style = StyleSheet::parse(",a { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_11() {
    let style = StyleSheet::parse("@import \"subs.css\";\na { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_12() {
    let style = StyleSheet::parse("\
@media screen {
    p:before { content: 'Hello'; }
}
a { color:red }");
    assert_eq!(style.to_string(), "a { color:red; }");
}

#[test]
fn style_13() {
    let style = StyleSheet::parse("a > { color:red }");
    assert_eq!(style.to_string(), "");
}

#[test]
fn style_14() {
    let style = StyleSheet::parse("p { color:green; color }");
    assert_eq!(style.to_string(), "p { color:green; }");
}

#[test]
fn style_15() {
    let style = StyleSheet::parse("p { color; color:green }");
    assert_eq!(style.to_string(), ""); // TODO: should be 'p { color:green; }'
}

#[test]
fn style_16() {
    let style = StyleSheet::parse("p { color:green; color: }");
    assert_eq!(style.to_string(), "p { color:green; }");
}

#[test]
fn style_17() {
    let style = StyleSheet::parse("p { color:green; color:; color:red; }");
    assert_eq!(style.to_string(), "p { color:green; }");
}

#[test]
fn style_18() {
    let style = StyleSheet::parse("p { color:green; color{;color:maroon} }");
    assert_eq!(style.to_string(), "p { color:green; }");
}

#[test]
fn style_19() {
    let style = StyleSheet::parse("p { color{;color:maroon} color:green; }");
    assert_eq!(style.to_string(), ""); // TODO: should be 'p { color:green; }'
}

#[test]
fn style_20() {
    let style = StyleSheet::parse("\
        h1 { color: green }
        h2 & h3 { color: red }
        h4 { color: black }
    ");
    assert_eq!(style.to_string(), "h1 { color:green; }\nh4 { color:black; }");
}

#[test]
fn style_21() {
    let style = StyleSheet::parse(":le>*");
    assert_eq!(style.to_string(), "");
}