<commit_before>package com.googlecode.totallylazy;

import com.googlecode.totallylazy.callables.CountingCallable;
import com.googlecode.totallylazy.comparators.Comparators;
import com.googlecode.totallylazy.matchers.NumberMatcher;
import com.googlecode.totallylazy.numbers.Numbers;
import org.junit.Test;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.googlecode.totallylazy.Arrays.list;
import static com.googlecode.totallylazy.Callables.asString;
import static com.googlecode.totallylazy.Callables.ascending;
import static com.googlecode.totallylazy.Callables.call;
import static com.googlecode.totallylazy.Callables.callThrows;
import static com.googlecode.totallylazy.Callables.descending;
import static com.googlecode.totallylazy.Callables.length;
import static com.googlecode.totallylazy.Callables.returns;
import static com.googlecode.totallylazy.Callables.size;
import static com.googlecode.totallylazy.Option.none;
import static com.googlecode.totallylazy.Option.option;
import static com.googlecode.totallylazy.Option.some;
import static com.googlecode.totallylazy.Pair.pair;
import static com.googlecode.totallylazy.Predicates.notNullValue;
import static com.googlecode.totallylazy.Quadruple.quadruple;
import static com.googlecode.totallylazy.Sequences.cons;
import static com.googlecode.totallylazy.Sequences.empty;
import static com.googlecode.totallylazy.Sequences.sequence;
import static com.googlecode.totallylazy.Sequences.sort;
import static com.googlecode.totallylazy.Sequences.zip;
import static com.googlecode.totallylazy.Triple.triple;
import static com.googlecode.totallylazy.callables.CountNotNull.count;
import static com.googlecode.totallylazy.callables.CountingCallable.counting;
import static com.googlecode.totallylazy.matchers.IterableMatcher.hasExactly;
import static com.googlecode.totallylazy.matchers.IterableMatcher.startsWith;
import static com.googlecode.totallylazy.numbers.Numbers.add;
import static com.googlecode.totallylazy.numbers.Numbers.even;
import static com.googlecode.totallylazy.numbers.Numbers.numbers;
import static com.googlecode.totallylazy.numbers.Numbers.odd;
import static com.googlecode.totallylazy.numbers.Numbers.range;
import static com.googlecode.totallylazy.numbers.Numbers.remainder;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class SequenceTest {
    @Test
    public void supportsEquality() throws Exception {
        assertThat(sequence(1, 2, 3).equals(sequence(1, 2, 3)), is(true));
        assertThat(sequence(1, 2, 3).equals(sequence(3, 2, 1)), is(false));
        assertThat(sequence(1, 2, 3).equals(sequence("1", "2", "3")), is(false));
        assertThat(sequence(1, 2).equals(sequence(1, 2, 3)), is(false));
        assertThat(sequence(1, 2, 3).equals(sequence(1, 2)), is(false));
        assertThat(sequence(1, 2, 3).equals(list(1, 2, 3)), is(false));
    }

    @Test
    public void supportsHashCodes() throws Exception {
        assertThat(sequence(1, 2, 3).hashCode() == sequence(1, 2, 3).hashCode(), is(true));
        assertThat(sequence(1, 2, 3).hashCode() == sequence(3, 2, 1).hashCode(), is(true)); // could we make this false easily?
        assertThat(sequence(1, 2, 3).hashCode() == sequence("1", "2", "3").hashCode(), is(false));<commit_msg>Added splitAt support to Sequence<commit_after>package com.googlecode.totallylazy;

import com.googlecode.totallylazy.callables.CountingCallable;
import com.googlecode.totallylazy.comparators.Comparators;
import com.googlecode.totallylazy.matchers.NumberMatcher;
import com.googlecode.totallylazy.numbers.Numbers;
import org.junit.Test;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static com.googlecode.totallylazy.Arrays.list;
import static com.googlecode.totallylazy.Callables.asString;
import static com.googlecode.totallylazy.Callables.ascending;
import static com.googlecode.totallylazy.Callables.call;
import static com.googlecode.totallylazy.Callables.callThrows;
import static com.googlecode.totallylazy.Callables.descending;
import static com.googlecode.totallylazy.Callables.length;
import static com.googlecode.totallylazy.Callables.returns;
import static com.googlecode.totallylazy.Callables.size;
import static com.googlecode.totallylazy.Option.none;
import static com.googlecode.totallylazy.Option.option;
import static com.googlecode.totallylazy.Option.some;
import static com.googlecode.totallylazy.Pair.pair;
import static com.googlecode.totallylazy.Predicates.notNullValue;
import static com.googlecode.totallylazy.Quadruple.quadruple;
import static com.googlecode.totallylazy.Sequences.characters;
import static com.googlecode.totallylazy.Sequences.cons;
import static com.googlecode.totallylazy.Sequences.empty;
import static com.googlecode.totallylazy.Sequences.sequence;
import static com.googlecode.totallylazy.Sequences.sort;
import static com.googlecode.totallylazy.Sequences.zip;
import static com.googlecode.totallylazy.Triple.triple;
import static com.googlecode.totallylazy.callables.CountNotNull.count;
import static com.googlecode.totallylazy.callables.CountingCallable.counting;
import static com.googlecode.totallylazy.matchers.IterableMatcher.hasExactly;
import static com.googlecode.totallylazy.matchers.IterableMatcher.startsWith;
import static com.googlecode.totallylazy.numbers.Numbers.add;
import static com.googlecode.totallylazy.numbers.Numbers.even;
import static com.googlecode.totallylazy.numbers.Numbers.numbers;
import static com.googlecode.totallylazy.numbers.Numbers.odd;
import static com.googlecode.totallylazy.numbers.Numbers.range;
import static com.googlecode.totallylazy.numbers.Numbers.remainder;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class SequenceTest {
    @Test
    public void supportsSplitAt() throws Exception {
        Sequence<String> data = sequence("Cat", "Dog", "Mouse", "Rabbit", "Monkey");
        assertThat(data.splitAt(2), is(pair(sequence("Cat", "Dog"), sequence("Mouse", "Rabbit", "Monkey"))));
        assertThat(characters("Hello World!").splitAt(6).first().toString(""), is("Hello "));
        assertThat(characters("Hello World!").splitAt(6).second().toString(""), is("World!"));
    }

    @Test
    public void supportsRecursiveSplitAt() throws Exception {
        Sequence<String> data = sequence("Cat", "Dog", "Mouse", "Rabbit", "Monkey");
        assertThat(data.recursive(Sequences.<String>splitAt(2)), is(sequence(sequence("Cat", "Dog"), sequence("Mouse", "Rabbit"), sequence("Monkey"))));
    }

    @Test
    public void supportsEquality() throws Exception {
        assertThat(sequence(1, 2, 3).equals(sequence(1, 2, 3)), is(true));
        assertThat(sequence(1, 2, 3).equals(sequence(3, 2, 1)), is(false));
        assertThat(sequence(1, 2, 3).equals(sequence("1", "2", "3")), is(false));
        assertThat(sequence(1, 2).equals(sequence(1, 2, 3)), is(false));
        assertThat(sequence(1, 2, 3).equals(sequence(1, 2)), is(false));
        assertThat(sequence(1, 2, 3).equals(list(1, 2, 3)), is(false));
    }

    @Test
    public void supportsHashCodes() throws Exception {
        assertThat(sequence(1, 2, 3).hashCode() == sequence(1, 2, 3).hashCode(), is(true));
        assertThat(sequence(1, 2, 3).hashCode() == sequence(3, 2, 1).hashCode(), is(true)); // could we make this false easily?
        assertThat(sequence(1, 2, 3).hashCode() == sequence("1", "2", "3").hashCode(), is(false));
{'fraction_non_alphanumeric': 0.12780500386897084, 'fraction_numerical': 0.013928295073510446, 'mean_word_length': 5.899466192170818, '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': '3307826', 'n_tokens_mistral': 2511, 'n_tokens_neox': 2428, 'n_words': 446}