Optimize list_or_bitstring
use super::*;
+use proptest::prop_oneof;
use proptest::strategy::Strategy;
#[test]
@@ -27,12 +28,8 @@ fn without_list_or_bitstring_returns_false() {
fn with_list_or_bitstring_right_returns_true() {
TestRunner::new(Config::with_source_file(file!()))
.run(
- &strategy::process().prop_flat_map(|arc_process| {
- strategy::term(arc_process.clone())
- .prop_filter("Right must be a list or bitstring", |right| {
- right.is_list() || right.is_bitstring()
- })
- }),
+ &strategy::process()
+ .prop_flat_map(|arc_process| list_or_bitstring(arc_process.clone())),
|right| {
let left = Term::NIL;
@@ -43,3 +40,11 @@ fn with_list_or_bitstring_right_returns_true() {
)
.unwrap();
}
+
+fn list_or_bitstring(arc_process: Arc<ProcessControlBlock>) -> BoxedStrategy<Term> {
+ prop_oneof![
+ strategy::term::is_list(arc_process.clone()),
+ strategy::term::is_bitstring(arc_process)
+ ]
+ .boxed()
+}
