### ----------------------------------------------------
### -- Math::NumberTheory
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/20-utilities.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use lib <. lib>;
use Math::NumberTheory::Utilities;
use Math::NumberTheory;

## 1
subtest {
    ok spiral-lattice(11);
    is spiral-lattice(11, :dataset).all ~~ Map:D, True;
    ok spiral-lattice(11, :dataset, last-at => 'top-left');
    ok spiral-lattice(12, end-corner => 'bottom-right'):d;
}, 'spiral-lattice';

## 2
subtest {
    ok triangle-matrix-embedding(11);
    ok triangle-matrix-embedding(12);
    is triangle-matrix-embedding(11, :dataset).all ~~ Map:D, True;
}, 'triangle matrix embedding';


## 3
subtest {
    ok sunflower-embedding(11), 'standard';
    ok sunflower-embedding(11, with => { $_ div 2 });
    ok sunflower-embedding(11, with => { $_ div 2 }, :120angle);
    is sunflower-embedding(11, :dataset).all ~~ Map:D, True, 'dataset obtained';
}, 'sunflower embedding';

## 4
subtest {
    ok circular-chords-tracing(11), 'standard';
    dies-ok { circular-chords-tracing(11, with => { $_ div 2 }) };
    ok circular-chords-tracing(11, with => { modular-inverse($_, 11) ?? ($_ => modular-inverse($_, 11)) !! Empty } );
    is circular-chords-tracing(11, :dataset).all ~~ Map:D, True;
    is circular-chords-tracing(11, :dataset)».keys.flat.unique.sort, <group index x y>;
}, 'circular chords representation';

done-testing;


