File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use std::rt::io;
7
7
use std:: rt:: io:: Writer ;
8
8
use extra:: { tempfile, json} ;
9
9
use extra:: json:: ToJson ;
10
+ use extra:: test;
10
11
11
12
use super :: * ;
12
13
use ast:: * ;
@@ -168,6 +169,27 @@ fn color3_keywords() {
168
169
}
169
170
170
171
172
+ #[bench]
173
+ fn bench_color_lookup_red(b: &mut test::BenchHarness) {
174
+ let ident = parse_one_component_value(tokenize(" red")).unwrap();
175
+ b.iter(|| assert!(Color::parse(&ident).is_some()));
176
+ }
177
+
178
+
179
+ #[bench]
180
+ fn bench_color_lookup_lightgoldenrodyellow(b: &mut test::BenchHarness) {
181
+ let ident = parse_one_component_value(tokenize(" lightgoldenrodyellow")).unwrap();
182
+ b.iter(|| assert!(Color::parse(&ident).is_some()));
183
+ }
184
+
185
+
186
+ #[bench]
187
+ fn bench_color_lookup_fail(b: &mut test::BenchHarness) {
188
+ let ident = parse_one_component_value(tokenize(" lightgoldenrodyellowbazinga")).unwrap();
189
+ b.iter(|| assert!(Color::parse(&ident).is_none()));
190
+ }
191
+
192
+
171
193
#[test]
172
194
fn nth() {
173
195
do run_json_tests(include_str!(" css-parsing-tests/An +B . json")) |input| {
You can’t perform that action at this time.
0 commit comments