From f17507102c543a9d1c4cbaf86c4387ec3b4b1d40 Mon Sep 17 00:00:00 2001 From: Maayan Hanin Date: Mon, 1 Feb 2021 22:44:08 +0200 Subject: [PATCH 1/4] Exclude i128 and u128 when targeting emscripten --- src/arbitrary.rs | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/arbitrary.rs b/src/arbitrary.rs index 92f893b..708b5a5 100644 --- a/src/arbitrary.rs +++ b/src/arbitrary.rs @@ -795,7 +795,12 @@ macro_rules! unsigned_arbitrary { } unsigned_arbitrary! { - usize, u8, u16, u32, u64, u128 + usize, u8, u16, u32, u64 +} + +#[cfg(not(target_os = "emscripten"))] +unsigned_arbitrary! { + u128 } macro_rules! signed_shrinker { @@ -867,7 +872,12 @@ macro_rules! signed_arbitrary { } signed_arbitrary! { - isize, i8, i16, i32, i64, i128 + isize, i8, i16, i32, i64 +} + +#[cfg(not(target_os = "emscripten"))] +signed_arbitrary! { + i128 } macro_rules! float_problem_values { @@ -973,7 +983,11 @@ unsigned_non_zero_arbitrary! { NonZeroU8 => u8, NonZeroU16 => u16, NonZeroU32 => u32, - NonZeroU64 => u64, + NonZeroU64 => u64 +} + +#[cfg(not(target_os = "emscripten"))] +unsigned_non_zero_arbitrary! { NonZeroU128 => u128 } @@ -1174,12 +1188,23 @@ mod test { #[test] fn arby_int() { - arby_int!(true, i8, i16, i32, i64, isize, i128); + arby_int!(true, i8, i16, i32, i64, isize); + } + + #[cfg(not(target_os = "emscripten"))] + #[test] + fn arby_int_128() { + arby_int!(true, i128); } #[test] fn arby_uint() { - arby_int!(false, u8, u16, u32, u64, usize, u128); + arby_int!(false, u8, u16, u32, u64, usize); + } + + #[cfg(not(target_os = "emscripten"))] + fn arby_uint_128() { + arby_int!(false, u128); } macro_rules! arby_float { @@ -1315,6 +1340,7 @@ mod test { eq(0i64, vec![]); } + #[cfg(not(target_os = "emscripten"))] #[test] fn ints128() { eq(5i128, vec![0, 3, 4]); @@ -1328,6 +1354,7 @@ mod test { eq(0usize, vec![]); } + #[cfg(not(target_os = "emscripten"))] #[test] fn uints8() { eq(5u8, vec![0, 3, 4]); @@ -1352,6 +1379,7 @@ mod test { eq(0u64, vec![]); } + #[cfg(not(target_os = "emscripten"))] #[test] fn uints128() { eq(5u128, vec![0, 3, 4]); From 6fb06243b364346232dddd60395c5a1dd7c8c4b0 Mon Sep 17 00:00:00 2001 From: Maayan Hanin Date: Mon, 1 Feb 2021 22:50:45 +0200 Subject: [PATCH 2/4] Fixing test. Getting rid of warnings when compiling for emscripten. --- src/arbitrary.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/arbitrary.rs b/src/arbitrary.rs index 708b5a5..4feecae 100644 --- a/src/arbitrary.rs +++ b/src/arbitrary.rs @@ -11,8 +11,10 @@ use std::net::{ }; use std::num::Wrapping; use std::num::{ - NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, + NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, }; +#[cfg(not(target_os = "emscripten"))] +use std::num::NonZeroU128; use std::ops::{ Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, @@ -1189,21 +1191,16 @@ mod test { #[test] fn arby_int() { arby_int!(true, i8, i16, i32, i64, isize); - } - #[cfg(not(target_os = "emscripten"))] - #[test] - fn arby_int_128() { + #[cfg(not(target_os = "emscripten"))] arby_int!(true, i128); } #[test] fn arby_uint() { arby_int!(false, u8, u16, u32, u64, usize); - } - #[cfg(not(target_os = "emscripten"))] - fn arby_uint_128() { + #[cfg(not(target_os = "emscripten"))] arby_int!(false, u128); } From 36346ad89fc0d164db4b7e1ef8d50822a729c0cd Mon Sep 17 00:00:00 2001 From: Maayan Hanin Date: Tue, 2 Feb 2021 12:11:43 +0200 Subject: [PATCH 3/4] Excluded uints8 tests from emscripten by mistake, reveting --- src/arbitrary.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arbitrary.rs b/src/arbitrary.rs index 4feecae..e218837 100644 --- a/src/arbitrary.rs +++ b/src/arbitrary.rs @@ -1351,7 +1351,6 @@ mod test { eq(0usize, vec![]); } - #[cfg(not(target_os = "emscripten"))] #[test] fn uints8() { eq(5u8, vec![0, 3, 4]); From db37b9b3d36a6fb4ee09c28c1121ed563aea94f9 Mon Sep 17 00:00:00 2001 From: Maayan Hanin Date: Tue, 2 Feb 2021 12:30:05 +0200 Subject: [PATCH 4/4] Fix fmt --- src/arbitrary.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/arbitrary.rs b/src/arbitrary.rs index e218837..f2adc73 100644 --- a/src/arbitrary.rs +++ b/src/arbitrary.rs @@ -9,12 +9,10 @@ use std::iter::{empty, once}; use std::net::{ IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, }; -use std::num::Wrapping; -use std::num::{ - NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, -}; #[cfg(not(target_os = "emscripten"))] use std::num::NonZeroU128; +use std::num::Wrapping; +use std::num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; use std::ops::{ Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,