Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit bdc60d0

Browse files
committed
Merge pull request #6 from pcwalton/fix-tests
Fix broken color parsing
2 parents 0c4cb1b + 07374e2 commit bdc60d0

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

color.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,25 @@ pub mod parsing {
7070
7171
/** Match an exact color keyword. */
7272
fn parse_by_name(color : &str) -> Option<Color> {
73-
let col = match color.to_ascii().to_lower().to_str() {
74-
~"black" => black(),
75-
~"silver" => silver(),
76-
~"gray" => gray(),
77-
~"grey" => gray(),
78-
~"white" => white(),
79-
~"maroon" => maroon(),
80-
~"red" => red(),
81-
~"purple" => purple(),
82-
~"fuchsia" => fuchsia(),
83-
~"green" => green(),
84-
~"lime" => lime(),
85-
~"olive" => olive(),
86-
~"yellow" => yellow(),
87-
~"navy" => navy(),
88-
~"blue" => blue(),
89-
~"teal" => teal(),
90-
~"aqua" => aqua(),
91-
_ => return fail_unrecognized(color)
73+
let col = match color.to_ascii().to_lower().to_str_ascii() {
74+
~"black" => black(),
75+
~"silver" => silver(),
76+
~"gray" => gray(),
77+
~"grey" => gray(),
78+
~"white" => white(),
79+
~"maroon" => maroon(),
80+
~"red" => red(),
81+
~"purple" => purple(),
82+
~"fuchsia" => fuchsia(),
83+
~"green" => green(),
84+
~"lime" => lime(),
85+
~"olive" => olive(),
86+
~"yellow" => yellow(),
87+
~"navy" => navy(),
88+
~"blue" => blue(),
89+
~"teal" => teal(),
90+
~"aqua" => aqua(),
91+
_ => return fail_unrecognized(color)
9292
};
9393
9494
return Some(col);
@@ -202,6 +202,7 @@ mod test {
202202
assert!(white().eq(&parse_color(~"white").unwrap()));
203203
assert!(black().eq(&parse_color(~"Black").unwrap()));
204204
assert!(gray().eq(&parse_color(~"Gray").unwrap()));
205+
println("silver");
205206
assert!(silver().eq(&parse_color(~"SiLvEr").unwrap()));
206207
assert!(maroon().eq(&parse_color(~"maroon").unwrap()));
207208
assert!(purple().eq(&parse_color(~"PURPLE").unwrap()));

test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ impl VoidPtrLike for TestNode {
4545
fn from_void_ptr(node: *libc::c_void) -> TestNode {
4646
assert!(node.is_not_null());
4747
TestNode(unsafe {
48-
let box = cast::reinterpret_cast(&node);
48+
let box = cast::transmute_copy(&node);
4949
cast::bump_box_refcount(box);
5050
box
5151
})
5252
}
5353

5454
fn to_void_ptr(&self) -> *libc::c_void {
55-
unsafe { cast::reinterpret_cast(&(*self)) }
55+
unsafe {
56+
cast::transmute_copy(&(*self))
57+
}
5658
}
5759
}
5860

0 commit comments

Comments
 (0)