diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-02-27 21:04:15 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-03-01 01:58:55 +0100 |
| commit | 1c4fb909ffad8328983d893f2fefdb17215f2b21 (patch) | |
| tree | b53f0a0dbca3cfa46cf74f6dd3d43d598314b019 /src/libcoretest | |
| parent | 890293655251c372ea99694c0c9f0795e2663286 (diff) | |
| download | rust-1c4fb909ffad8328983d893f2fefdb17215f2b21.tar.gz rust-1c4fb909ffad8328983d893f2fefdb17215f2b21.zip | |
Make Int::pow() take exp as u32 instead usize
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/num/int_macros.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs index f5657d939b2..c33729876cc 100644 --- a/src/libcoretest/num/int_macros.rs +++ b/src/libcoretest/num/int_macros.rs @@ -201,6 +201,17 @@ mod tests { assert_eq!(FromStrRadix::from_str_radix("Z", 35).ok(), None::<$T>); assert_eq!(FromStrRadix::from_str_radix("-9", 2).ok(), None::<$T>); } + + #[test] + fn test_pow() { + let mut r = 2 as $T; + + assert_eq!(r.pow(2u32), 4 as $T); + assert_eq!(r.pow(0u32), 1 as $T); + r = -2 as $T; + assert_eq!(r.pow(2u32), 4 as $T); + assert_eq!(r.pow(3u32), -8 as $T); + } } )} |
