<commit_before>package com.sageserpent.americium.java;

import org.junit.jupiter.api.Test;

import java.math.BigDecimal;

public class TrialsApiTests {
    private final static TrialsApi api = Trials.api();

    Trials<String> chainedIntegers() {
        return api.alternate(
                api.integers()
                        .flatMap(value -> chainedIntegers()
                                .map(chain -> String.join(",", value.toString(), chain))),
                api.only("*** END ***"));
    }

    Trials<String> chainedBooleansAndIntegersInATree() {
        return api.alternate(
                api.delay(() -> chainedBooleansAndIntegersInATree())
                        .flatMap(left -> api.booleans()
                                .flatMap(side -> chainedBooleansAndIntegersInATree()
                                        .map(right -> "(" + String.join(",", left, side.toString(), right) + ")"))),
                api.integers().map(value -> value.toString()));
    }

    Trials<String> chainedIntegersUsingAnExplicitTerminationCase() {
        return api.booleans().flatMap(terminate ->
                terminate ? api.only("*** END ***") : api.integers().flatMap(value -> chainedIntegersUsingAnExplicitTerminationCase().map(simplerCase -> String.join(",", value.toString(), simplerCase))));
    }

    @Test
    void testDrivePureJavaApi() {
        final Trials<Integer> integerTrials = api.only(1);
        final Trials<Double> doubleTrials =
                api.choose(new Double[]{1.2, 5.6, 0.1 + 0.1 + 0.1})
                        .map(value -> 10 * value);
        final BigDecimal oneTenthAsABigDecimal = BigDecimal.ONE.divide(BigDecimal.TEN);
        final Trials<BigDecimal> bigDecimalTrials =
                api.only(oneTenthAsABigDecimal.add(oneTenthAsABigDecimal).add(oneTenthAsABigDecimal))
                        .map(value -> value.multiply(BigDecimal.TEN));

        final Trials<? extends Number> alternateTrials = api.alternate(integerTrials, doubleTrials, bigDecimalTrials);

        final int limit = 20;

        alternateTrials.withLimit(limit).supplyTo(number -> {
            System.out.println(number.doubleValue());
        });

        final Trials<? extends Number> alternateTrialsFromArray = api.alternate(new Trials[]{integerTrials, doubleTrials, bigDecimalTrials});

        alternateTrialsFromArray.withLimit(limit).supplyTo(number -> {
            System.out.println(number.doubleValue());
        });

        System.out.println("Chained integers...");

        chainedIntegers().withLimit(limit).supplyTo(System.out::println);

        System.out.println("Chained integers using an explicit termination case...");

        chainedIntegersUsingAnExplicitTerminationCase().withLimit(limit).supplyTo(System.out::println);

        System.out.println("Chained integers and Booleans in a tree...");

        chainedBooleansAndIntegersInATree().withLimit(limit).supplyTo(System.out::println);

        System.out.println("A sorted map of strings keyed by integers...");

        integerTrials.sortedMaps(Integer::compare, api.strings()).withLimit(limit).supplyTo(System.out::println);
    }
}<commit_msg>Add some more Java API smoke tests, these all fail, as expected...<commit_after>package com.sageserpent.americium.java;

import org.junit.jupiter.api.Test;

import java.math.BigDecimal;

public class TrialsApiTests {
    private final static TrialsApi api = Trials.api();

    Trials<String> chainedIntegers() {
        return api.alternate(
                api.integers()
                        .flatMap(value -> chainedIntegers()
                                .map(chain -> String.join(",", value.toString(), chain))),
                api.only("*** END ***"));
    }

    Trials<String> chainedBooleansAndIntegersInATree() {
        return api.alternate(
                api.delay(() -> chainedBooleansAndIntegersInATree())
                        .flatMap(left -> api.booleans()
                                .flatMap(side -> chainedBooleansAndIntegersInATree()
                                        .map(right -> "(" + String.join(",", left, side.toString(), right) + ")"))),
                api.integers().map(value -> value.toString()));
    }

    Trials<String> chainedIntegersUsingAnExplicitTerminationCase() {
        return api.booleans().flatMap(terminate ->
                terminate ? api.only("*** END ***") : api.integers().flatMap(value -> chainedIntegersUsingAnExplicitTerminationCase().map(simplerCase -> String.join(",", value.toString(), simplerCase))));
    }

    @Test
    void testDrivePureJavaApi() {
        final Trials<Integer> integerTrials = api.only(1);
        final Trials<Double> doubleTrials =
                api.choose(new Double[]{1.2, 5.6, 0.1 + 0.1 + 0.1})
                        .map(value -> 10 * value);
        final BigDecimal oneTenthAsABigDecimal = BigDecimal.ONE.divide(BigDecimal.TEN);
        final Trials<BigDecimal> bigDecimalTrials =
                api.only(oneTenthAsABigDecimal.add(oneTenthAsABigDecimal).add(oneTenthAsABigDecimal))
                        .map(value -> value.multiply(BigDecimal.TEN));

        final Trials<? extends Number> alternateTrials = api.alternate(integerTrials, doubleTrials, bigDecimalTrials);

        final int limit = 20;

        alternateTrials.withLimit(limit).supplyTo(number -> {
            System.out.println(number.doubleValue());
        });

        final Trials<? extends Number> alternateTrialsFromArray = api.alternate(new Trials[]{integerTrials, doubleTrials, bigDecimalTrials});

        alternateTrialsFromArray.withLimit(limit).supplyTo(number -> {
            System.out.println(number.doubleValue());
        });

        System.out.println("Chained integers...");

        chainedIntegers().withLimit(limit).supplyTo(System.out::println);

        System.out.println("Chained integers using an explicit termination case...");

        chainedIntegersUsingAnExplicitTerminationCase().withLimit(limit).supplyTo(System.out::println);

        System.out.println("Chained integers and Booleans in a tree...");

        chainedBooleansAndIntegersInATree().withLimit(limit).supplyTo(System.out::println);

        System.out.println("A list of doubles...");

        doubleTrials.lists().withLimit(limit).supplyTo(System.out::println);

        System.out.println("A set of doubles...");

        doubleTrials.sets().withLimit(limit).supplyTo(System.out::println);

        System.out.println("A map of strings keyed by integers...");

        Trials<Integer> integersTrialsWithVariety = api.choose(1, 2, 3);

        integersTrialsWithVariety.maps(api.strings()).withLimit(limit).supplyTo(System.out::println);

        System.out.println("A sorted map of strings keyed by integers...");

        integersTrialsWithVariety.sortedMaps(Integer::compare, api.strings()).withLimit(limit).supplyTo(System.out::println);
    }
}
{'fraction_non_alphanumeric': 0.13453174833285012, 'fraction_numerical': 0.004783995360974195, 'mean_word_length': 2.6833956219967967, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4264193', 'n_tokens_mistral': 2042, 'n_tokens_neox': 1908, 'n_words': 314}