Skip to content

Commit 2beda95

Browse files
committed
Upgrade to rustc 2e92c67dc 2014-08-28
1 parent dcfd7c2 commit 2beda95

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/tests.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ fn write_whole_file(path: &Path, data: &str) {
3333

3434
fn almost_equals(a: &json::Json, b: &json::Json) -> bool {
3535
match (a, b) {
36-
(&json::Number(a), &json::Number(b)) => (a - b).abs() < 1e-6,
37-
(&json::String(ref a), &json::String(ref b)) => a == b,
36+
(&json::I64(a), _) => almost_equals(&json::F64(a as f64), b),
37+
(&json::U64(a), _) => almost_equals(&json::F64(a as f64), b),
38+
(_, &json::I64(b)) => almost_equals(a, &json::F64(b as f64)),
39+
(_, &json::U64(b)) => almost_equals(a, &json::F64(b as f64)),
40+
41+
(&json::F64(a), &json::F64(b)) => (a - b).abs() < 1e-6,
42+
3843
(&json::Boolean(a), &json::Boolean(b)) => a == b,
44+
(&json::String(ref a), &json::String(ref b)) => a == b,
3945
(&json::List(ref a), &json::List(ref b))
4046
=> a.iter().zip(b.iter()).all(|(ref a, ref b)| almost_equals(*a, *b)),
4147
(&json::Object(_), &json::Object(_)) => fail!("Not implemented"),
@@ -82,7 +88,7 @@ fn run_raw_json_tests(json_data: &str, run: |json::Json, json::Json|) {
8288
match (&input, item) {
8389
(&None, json_obj) => input = Some(json_obj),
8490
(&Some(_), expected) => {
85-
let input = input.take_unwrap();
91+
let input = input.take().unwrap();
8692
run(input, expected)
8793
},
8894
};
@@ -417,8 +423,8 @@ impl ToJson for ComponentValue {
417423

418424
Number(ref value) => json::List(vec!(JString!("number")) + numeric(value)),
419425
Percentage(ref value) => json::List(vec!(JString!("percentage")) + numeric(value)),
420-
Dimension(ref value, ref unit)
421-
=> json::List(vec!(JString!("dimension")) + numeric(value) + &[unit.to_json()]),
426+
Dimension(ref value, ref unit) => json::List(
427+
vec!(JString!("dimension")) + numeric(value) + [unit.to_json()].as_slice()),
422428

423429
UnicodeRange(start, end)
424430
=> JList!(JString!("unicode-range"), start.to_json(), end.to_json()),

0 commit comments

Comments
 (0)