<commit_before>#![feature(core)]
extern crate simple_parallel;

#[test]
fn unordered_map_probabilistic_out_of_ordering() {
    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |_: usize| ();
    let iter = simple_parallel::unordered_map(0..N, &f);

    // see if there are any elements where the order they come out of
    // the original iterator is different to the order in which they
    // are yielded here.
    assert!(iter.enumerate().any(|(yield_order, (true_order, ()))| yield_order != true_order));
}

#[test]
fn map_in_order() {
    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |i: usize| i;
    let iter = simple_parallel::map(0..N, &f);

    assert!(iter.enumerate().all(|(yield_order, true_order)| yield_order == true_order));
}


#[test]
fn pool_unordered() {
    let mut pool = simple_parallel::Pool::new(8);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |_: usize| {};
    let iter = pool.unordered_map(0..N, &f);

    // see if there are any elements where the order they come out of
    // the original iterator is different to the order in which they
    // are yielded here.
    let v: Vec<_> = iter.enumerate().collect();
    assert_eq!(v.len(), N);
    assert!(v.into_iter().any(|(yield_order, (true_order, ()))| yield_order != true_order));
}
#[test]
fn pool_unordered2() {
    let mut pool = simple_parallel::Pool::new(2);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |_: usize| {};
    let iter = pool.unordered_map2(0..N, &f);

    // see if there are any elements where the order they come out of
    // the original iterator is different to the order in which they
    // are yielded here.
    let v: Vec<_> = iter.enumerate().collect();
    assert_eq!(v.len(), N);
    assert!(v.into_iter().any(|(yield_order, (true_order, ()))| yield_order != true_order));
}

#[test]
fn pool_map_in_order() {
    let mut pool = simple_parallel::Pool::new(8);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |i: usize| i;
    let iter = pool.map(0..N, &f);

    assert!(std::iter::order::eq(iter, 0..N));
}
#[test]
fn pool_map2_in_order() {
    let mut pool = simple_parallel::Pool::new(8);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |i: usize| i;
    let iter = pool.map2(0..N, &f);

    assert!(std::iter::order::eq(iter, 0..N));
}<commit_msg>Remove invalid tests.<commit_after>#![feature(core)]
extern crate simple_parallel;

#[test]
fn unordered_map_probabilistic_out_of_ordering() {
    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |_: usize| ();
    let iter = simple_parallel::unordered_map(0..N, &f);

    // see if there are any elements where the order they come out of
    // the original iterator is different to the order in which they
    // are yielded here.
    assert!(iter.enumerate().any(|(yield_order, (true_order, ()))| yield_order != true_order));
}

#[test]
fn map_in_order() {
    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |i: usize| i;
    let iter = simple_parallel::map(0..N, &f);

    assert!(iter.enumerate().all(|(yield_order, true_order)| yield_order == true_order));
}


#[test]
fn pool_unordered() {
    let mut pool = simple_parallel::Pool::new(8);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |_: usize| {};
    let iter = pool.unordered_map(0..N, &f);

    // see if there are any elements where the order they come out of
    // the original iterator is different to the order in which they
    // are yielded here.
    let v: Vec<_> = iter.enumerate().collect();
    assert_eq!(v.len(), N);
    assert!(v.into_iter().any(|(yield_order, (true_order, ()))| yield_order != true_order));
}

#[test]
fn pool_map_in_order() {
    let mut pool = simple_parallel::Pool::new(8);

    // with this many elements, its (hopefully) likely that the
    // threads won't execute sequentially.
    const N: usize = 1000;

    let f = |i: usize| i;
    let iter = pool.map(0..N, &f);

    assert!(std::iter::order::eq(iter, 0..N));
}
{'fraction_non_alphanumeric': 0.1454316848281643, 'fraction_numerical': 0.013202011735121543, 'mean_word_length': 3.1831726555652935, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7338747', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1527, 'n_words': 501}