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

Fix broken color parsing #6

Merged
merged 1 commit into from May 3, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -70,25 +70,25 @@ pub mod parsing {

/** Match an exact color keyword. */
fn parse_by_name(color : &str) -> Option<Color> {
let col = match color.to_ascii().to_lower().to_str() {
~"black" => black(),
~"silver" => silver(),
~"gray" => gray(),
~"grey" => gray(),
~"white" => white(),
~"maroon" => maroon(),
~"red" => red(),
~"purple" => purple(),
~"fuchsia" => fuchsia(),
~"green" => green(),
~"lime" => lime(),
~"olive" => olive(),
~"yellow" => yellow(),
~"navy" => navy(),
~"blue" => blue(),
~"teal" => teal(),
~"aqua" => aqua(),
_ => return fail_unrecognized(color)
let col = match color.to_ascii().to_lower().to_str_ascii() {
~"black" => black(),
~"silver" => silver(),
~"gray" => gray(),
~"grey" => gray(),
~"white" => white(),
~"maroon" => maroon(),
~"red" => red(),
~"purple" => purple(),
~"fuchsia" => fuchsia(),
~"green" => green(),
~"lime" => lime(),
~"olive" => olive(),
~"yellow" => yellow(),
~"navy" => navy(),
~"blue" => blue(),
~"teal" => teal(),
~"aqua" => aqua(),
_ => return fail_unrecognized(color)
};

return Some(col);
@@ -202,6 +202,7 @@ mod test {
assert!(white().eq(&parse_color(~"white").unwrap()));
assert!(black().eq(&parse_color(~"Black").unwrap()));
assert!(gray().eq(&parse_color(~"Gray").unwrap()));
println("silver");
assert!(silver().eq(&parse_color(~"SiLvEr").unwrap()));
assert!(maroon().eq(&parse_color(~"maroon").unwrap()));
assert!(purple().eq(&parse_color(~"PURPLE").unwrap()));
@@ -45,14 +45,16 @@ impl VoidPtrLike for TestNode {
fn from_void_ptr(node: *libc::c_void) -> TestNode {
assert!(node.is_not_null());
TestNode(unsafe {
let box = cast::reinterpret_cast(&node);
let box = cast::transmute_copy(&node);
cast::bump_box_refcount(box);
box
})
}

fn to_void_ptr(&self) -> *libc::c_void {
unsafe { cast::reinterpret_cast(&(*self)) }
unsafe {
cast::transmute_copy(&(*self))
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.