Auto merge of #10608 - KiChjang:parse-double, r=nox

Add parsing of double values in style attributes

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10608)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-26 11:59:25 -07:00
commit ccba2d6841
11 changed files with 132 additions and 14 deletions

View file

@ -6,6 +6,15 @@ use app_units::Au;
use style::attr::{AttrValue, parse_length};
use util::str::{DOMString, LengthOrPercentageOrAuto};
#[test]
fn test_parse_double() {
let value = DOMString::from("432.5e2");
match AttrValue::from_double(value, 0.0) {
AttrValue::Double(_, num) => assert_eq!(num, 43250f64),
_ => panic!("expected a double value")
}
}
#[test]
fn test_from_limited_i32_should_be_default_when_less_than_0() {
let value = DOMString::from("-1");