feat(impls): Add impls for num::{BigInt,BigUint,Complex,Ratio}

This commit is contained in:
Erick Tryzelaar
2015-12-01 09:03:08 -08:00
parent f3f098e7f5
commit 1a8a11e924
10 changed files with 201 additions and 4 deletions
+34
View File
@@ -1,5 +1,10 @@
use std::collections::BTreeMap;
use num::FromPrimitive;
use num::bigint::{BigInt, BigUint};
use num::complex::Complex;
use num::rational::Ratio;
use token::Token;
//////////////////////////////////////////////////////////////////////////
@@ -259,4 +264,33 @@ declare_ser_tests! {
Token::MapEnd,
],
}
test_num_bigint {
BigInt::from_i64(123).unwrap() => &[Token::Str("123")],
BigInt::from_i64(-123).unwrap() => &[Token::Str("-123")],
}
test_num_biguint {
BigUint::from_i64(123).unwrap() => &[Token::Str("123")],
}
test_num_complex {
Complex::new(1, 2) => &[
Token::SeqStart(Some(2)),
Token::SeqSep,
Token::I32(1),
Token::SeqSep,
Token::I32(2),
Token::SeqEnd,
],
}
test_num_ratio {
Ratio::new(1, 2) => &[
Token::SeqStart(Some(2)),
Token::SeqSep,
Token::I32(1),
Token::SeqSep,
Token::I32(2),
Token::SeqEnd,
],
}
}