float_to_binary_2 strategy
@@ -146,23 +146,7 @@ fn returns_binary_with_coefficient_e_exponent() {
#[test]
fn always_includes_e() {
- run!(
- |arc_process| {
- (
- Just(arc_process.clone()),
- strategy::term::float(arc_process.clone()),
- (Just(arc_process.clone()), digits(arc_process.clone())).prop_map(
- |(arc_process, digits)| {
- arc_process
- .list_from_slice(&[arc_process
- .tuple_from_slice(&[tag(), digits])
- .unwrap()])
- .unwrap()
- },
- ),
- )
- },
- |(arc_process, float, options)| {
+ run!(strategy, |(arc_process, float, options)| {
let result = native(&arc_process, float, options);
prop_assert!(result.is_ok());
@@ -173,29 +157,12 @@ fn always_includes_e() {
prop_assert!(string.contains('e'));
Ok(())
- },
- );
+ },);
}
#[test]
fn always_includes_sign_of_exponent() {
- run!(
- |arc_process| {
- (
- Just(arc_process.clone()),
- strategy::term::float(arc_process.clone()),
- (Just(arc_process.clone()), digits(arc_process.clone())).prop_map(
- |(arc_process, digits)| {
- arc_process
- .list_from_slice(&[arc_process
- .tuple_from_slice(&[tag(), digits])
- .unwrap()])
- .unwrap()
- },
- ),
- )
- },
- |(arc_process, float, options)| {
+ run!(strategy, |(arc_process, float, options)| {
let result = native(&arc_process, float, options);
prop_assert!(result.is_ok());
@@ -211,29 +178,12 @@ fn always_includes_sign_of_exponent() {
prop_assert!(sign == '+' || sign == '-');
Ok(())
- },
- );
+ },);
}
#[test]
fn exponent_is_at_least_2_digits() {
- run!(
- |arc_process| {
- (
- Just(arc_process.clone()),
- strategy::term::float(arc_process.clone()),
- (Just(arc_process.clone()), digits(arc_process.clone())).prop_map(
- |(arc_process, digits)| {
- arc_process
- .list_from_slice(&[arc_process
- .tuple_from_slice(&[tag(), digits])
- .unwrap()])
- .unwrap()
- },
- ),
- )
- },
- |(arc_process, float, options)| {
+ run!(strategy, |(arc_process, float, options)| {
let result = native(&arc_process, float, options);
prop_assert!(result.is_ok());
@@ -247,8 +197,7 @@ fn exponent_is_at_least_2_digits() {
prop_assert!(2 <= part_vec[1].chars().skip(1).count());
Ok(())
- },
- );
+ },);
}
fn digits(arc_process: Arc<Process>) -> BoxedStrategy<Term> {
@@ -265,6 +214,20 @@ fn options(process: &Process, digits: u8) -> Term {
.unwrap()
}
+fn strategy(arc_process: Arc<Process>) -> impl Strategy<Value = (Arc<Process>, Term, Term)> {
+ (
+ Just(arc_process.clone()),
+ super::strategy::term::float(arc_process.clone()),
+ (Just(arc_process.clone()), digits(arc_process.clone())).prop_map(
+ |(arc_process, digits)| {
+ arc_process
+ .list_from_slice(&[arc_process.tuple_from_slice(&[tag(), digits]).unwrap()])
+ .unwrap()
+ },
+ ),
+ )
+}
+
fn tag() -> Term {
Atom::str_to_term("scientific")
}
