#!/usr/bin/perl

use strict;
use warnings;

use Test::ManyParams;
use Test::More;
use Test::Exception;
use Test::Builder::Tester tests => 247;
use Data::Dumper;
use t'CommonStuff;

Test::Builder::Tester::color(1);

sub always_true_is_always_true($;$) {
    my ($params, $testname) = @_;
    test_out "ok 1" . ($testname ? " - $testname" : "");
    $testname ? any_ok { 1 } $params, $testname : any_ok { 1 } $params;
    test_test "Everything should be O.K., if sub always returns true ".
              _dump_params({params => $params, testname => $testname});
}

sub only_one_value_is_ok($$;$) {
    my ($params, $ok_params, $testname) = @_;
    test_out "ok 1" . ($testname ? " - $testname" : "");
    any_ok { eq_array \@_, $ok_params } $params, $testname;
    test_test "any_ok should be correct with" .
              _dump_params({params => $params, valid => $ok_params, testname => $testname});
}

sub all_values_arent_ok($;$) {
    my ($params, $testname) = @_;
    test_out "not ok 1" . ($testname ? " - $testname" : "");
    test_fail +1;
    any_ok { 0 } $params, $testname;
    test_test "no true values should fail (". 
              _dump_params(params => $params, testname => $testname);
}

foreach (STANDARD_PARAMETERS()) {
    my ($params, $values) = @$_;
    always_true_is_always_true $params;
    always_true_is_always_true $params, "With a testname";
    all_values_arent_ok        $params;
    all_values_arent_ok        $params, "With a testname";
    foreach (@$values) {
        my $ok_params = [split //];
        only_one_value_is_ok $params, $ok_params;
        only_one_value_is_ok $params, $ok_params, "With a testname";
    }
}

dies_ok { any_ok { 1 } [ [1 .. 10], 11, 12, 13 ] }
        "Used a an array of arrays and not-arrays, what's not ok and should die";
