<commit_before>package com.aol.cyclops2.streams.streamable;


import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import cyclops.companion.Streams;
import org.junit.Test;

import cyclops.control.anym.AnyM;
import cyclops.reactive.ReactiveSeq;
import cyclops.reactive.Streamable;

public class SequenceMTest {
	
	@Test
    public void emptyAllPermutations() {
        assertThat(Streamable.of().permutations().map(s->s.toList()).toList(),equalTo(Arrays.asList()));
    }

    @Test
    public void allPermutations3() {
    	System.out.println(Streamable.of(1, 2, 3).permutations().map(s->s.toList()).toList());
        assertThat(Streamable.of(1, 2, 3).permutations().map(s->s.toList()).toList(),
        		equalTo(Streamable.of(Streamable.of(1, 2, 3),
        		Streamable.of(1, 3, 2), Streamable.of(2, 1, 3), Streamable.of(2, 3, 1), Streamable.of(3, 1, 2), Streamable.of(3, 2, 1)).map(s->s.toList()).toList()));
    }
    

    

  

    @Test
    public void emptyCombinations() {
        assertThat(Streamable.of().combinations(2).toList(),equalTo(Arrays.asList()));
    }

    @Test
    public void combinations2() {
        assertThat(Streamable.of(1, 2, 3).combinations(2).map(s->s.toList()).toList(),
                equalTo(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(1, 3), Arrays.asList(2, 3))));
    }
	@Test
	public void onEmpty(){
		assertThat(Streamable.of()
						.onEmpty(1)
						.toList(),
				equalTo(Arrays.asList(1)));

	}
	@Test
	public void onEmptySwitchEmpty(){
		assertThat(Streamable.of()
							.onEmptySwitch(()->Streamable.of(1,2,3))
							.toList(),
							equalTo(Arrays.asList(1,2,3)));
				
	}
	@Test
	public void onEmptySwitch(){
		assertThat(Streamable.of(4,5,6)
							.onEmptySwitch(()->Streamable.of(1,2,3))
							.toList(),
							equalTo(Arrays.asList(4,5,6)));
				
	}
	
	@Test
	public void elapsedIsPositive(){
		
		
		assertTrue(Streamable.of(1,2,3,4,5).elapsed().noneMatch(t->t._2()<0));
	}
	@Test
	public void timeStamp(){
		
		
		assertTrue(Streamable.of(1,2,3,4,5)
							.timestamp()
							.allMatch(t-> t._2() <= System.currentTimeMillis()));
		

	}
	@Test
	public void elementAt0(){
		assertThat(Streamable.of(1).elementAt(0).toOptional().get(),equalTo(1));
	}
	@Test
	public void elementAtMultple(){
		assertThat(Streamable.of(1,2,3,4,5).elementAt(2),equalTo(3));
	}
	
	@Test(expected=NoSuchElementException.class)
	public void elementAtMultiple1(){
		Streamable.of(1).elementAt(1);
	}
	@Test(expected=NoSuchElementException.class)
	public void elementAtEmpty(){
		Streamable.of().elementAt(0);
	}
	@Test
	public void get0(){
		assertTrue(Streamable.of(1).elementAt(0).isPresent());
	}
	@Test
	public void getMultple(){
		assertThat(Streamable.of(1,2,3,4,5).elementAt(2).toOptional().get(),equalTo(3));
	}
	@Test
	public void getAt1(){
		assertFalse(Streamable.of(1).elementAt(1).isPresent());
	}
	@Test
	public void getEmpty(){
		assertFalse(Streamable.of().elementAt(0).isPresent());
	}
	@Test
	public void singleTest(){
		assertThat(Streamable.of(1).singleOrElse(-1),equalTo(1));
	}
	@Test(expected=UnsupportedOperationException.class)
	public void singleEmpty(){
		Streamable.of().singleOrElse(null);
	}
	@Test(expected=UnsupportedOperationException.class)
	public void single2(){
		Streamable.of(1,2).singleOrElse(null);
	}
	@Test
	public void limitTime(){
		List<Integer> result = Streamable.of(1,2,3,4,5,6)
										.peek(i->sleep(i*100))
										.limit(1000,TimeUnit.MILLISECONDS)
										.toList();
		
		
		assertThat(result,equalTo(Arrays.asList(1,2,3)));
	}
	@Test
	public void limitTimeEmpty(){
		List<Integer> result = ReactiveSeq.<Integer>of()
										.peek(i->sleep(i*100))
										.limit(1000,TimeUnit.MILLISECONDS)
										.toList();
		
		<commit_msg>fix tests<commit_after>package com.aol.cyclops2.streams.streamable;


import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import cyclops.companion.Streams;
import cyclops.control.Option;
import org.junit.Test;

import cyclops.control.anym.AnyM;
import cyclops.reactive.ReactiveSeq;
import cyclops.reactive.Streamable;

public class SequenceMTest {
	
	@Test
    public void emptyAllPermutations() {
        assertThat(Streamable.of().permutations().map(s->s.toList()).toList(),equalTo(Arrays.asList()));
    }

    @Test
    public void allPermutations3() {
    	System.out.println(Streamable.of(1, 2, 3).permutations().map(s->s.toList()).toList());
        assertThat(Streamable.of(1, 2, 3).permutations().map(s->s.toList()).toList(),
        		equalTo(Streamable.of(Streamable.of(1, 2, 3),
        		Streamable.of(1, 3, 2), Streamable.of(2, 1, 3), Streamable.of(2, 3, 1), Streamable.of(3, 1, 2), Streamable.of(3, 2, 1)).map(s->s.toList()).toList()));
    }
    

    

  

    @Test
    public void emptyCombinations() {
        assertThat(Streamable.of().combinations(2).toList(),equalTo(Arrays.asList()));
    }

    @Test
    public void combinations2() {
        assertThat(Streamable.of(1, 2, 3).combinations(2).map(s->s.toList()).toList(),
                equalTo(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(1, 3), Arrays.asList(2, 3))));
    }
	@Test
	public void onEmpty(){
		assertThat(Streamable.of()
						.onEmpty(1)
						.toList(),
				equalTo(Arrays.asList(1)));

	}
	@Test
	public void onEmptySwitchEmpty(){
		assertThat(Streamable.of()
							.onEmptySwitch(()->Streamable.of(1,2,3))
							.toList(),
							equalTo(Arrays.asList(1,2,3)));
				
	}
	@Test
	public void onEmptySwitch(){
		assertThat(Streamable.of(4,5,6)
							.onEmptySwitch(()->Streamable.of(1,2,3))
							.toList(),
							equalTo(Arrays.asList(4,5,6)));
				
	}
	
	@Test
	public void elapsedIsPositive(){
		
		
		assertTrue(Streamable.of(1,2,3,4,5).elapsed().noneMatch(t->t._2()<0));
	}
	@Test
	public void timeStamp(){
		
		
		assertTrue(Streamable.of(1,2,3,4,5)
							.timestamp()
							.allMatch(t-> t._2() <= System.currentTimeMillis()));
		

	}
	@Test
	public void elementAt0(){
		assertThat(Streamable.of(1).elementAt(0).toOptional().get(),equalTo(1));
	}
	@Test
	public void elementAtMultple(){
		assertThat(Streamable.of(1,2,3,4,5).elementAt(2),equalTo(Option.some(3)));
	}
	
	@Test
	public void elementAtMultiple1(){
		assertThat(Streamable.of(1).elementAt(1),equalTo(Option.none()));
	}
	@Test
	public void elementAtEmpty(){
		assertThat(Streamable.of().elementAt(0),equalTo(Option.none()));
	}
	@Test
	public void get0(){
		assertTrue(Streamable.of(1).elementAt(0).isPresent());
	}
	@Test
	public void getMultple(){
		assertThat(Streamable.of(1,2,3,4,5).elementAt(2).toOptional().get(),equalTo(3));
	}
	@Test
	public void getAt1(){
		assertFalse(Streamable.of(1).elementAt(1).isPresent());
	}
	@Test
	public void getEmpty(){
		assertFalse(Streamable.of().elementAt(0).isPresent());
	}
	@Test
	public void singleTest(){
		assertThat(Streamable.of(1).singleOrElse(-1),equalTo(1));
	}
	@Test
	public void singleEmpty(){
		assertThat(Streamable.of().singleOrElse(null),equalTo(null));
	}
	@Test
	public void single2(){
		assertThat(Streamable.of(1,2).singleOrElse(null),equalTo(null));
	}
	@Test
	public void limitTime(){
		List<Integer> result = Streamable.of(1,2,3,4,5,6)
										.peek(i->sleep(i*100))
										.limit(1000,TimeUnit.MILLISECONDS)
										.toList();
		
		
		assertThat(result,equalTo(Arrays.asList(1,2,3)));
	}
	@Test
	public void limitTimeEmpty(){
		List<Integer> result = ReactiveSeq.<Integer>of()
										.peek(i->sleep(i*100))
										.limit(1000,TimeUnit.MILLISECONDS)
										.toList();
		
		
{'fraction_non_alphanumeric': 0.16935672514619882, 'fraction_numerical': 0.029473684210526315, 'mean_word_length': 4.111177525403467, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, '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': '1373766', 'n_tokens_mistral': 3505, 'n_tokens_neox': 3100, 'n_words': 441}