use strict;
use warnings;
use Test::More;
use Loo;

sub dd {
    my ($data, %opts) = @_;
    my $dd = Loo->new([$data]);
    $dd->{use_colour} = 0;
    while (my ($k, $v) = each %opts) {
        my $method = ucfirst($k);
        $dd->$method($v) if $dd->can($method);
    }
    return $dd->Dump;
}

# ── Indent 0 (compact) ───────────────────────────────────────────
is(dd([1, 2, 3], indent => 0), "\$VAR1 = [1, 2, 3];\n", 'indent 0 array');
is(dd({a => 1}, indent => 0), "\$VAR1 = {'a' => 1};\n", 'indent 0 hash');

# ── Indent 1 (single space, closing on its own line) ─────────────
my $i1 = dd([1, 2], indent => 1);
like($i1, qr/\[\n/, 'indent 1: opening bracket + newline');
like($i1, qr/^ 1,$/m, 'indent 1: single space indent');

# ── Indent 2 (default, 2-space) ──────────────────────────────────
my $i2 = dd([1, 2], indent => 2);
like($i2, qr/^  1,$/m, 'indent 2: two-space indent');

# ── Nested indent 0 ──────────────────────────────────────────────
is(dd([[1]], indent => 0), "\$VAR1 = [[1]];\n", 'indent 0 nested');

done_testing;
