### ----------------------------------------------------
### -- Grammar::TokenProcessing
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: xt/05-random-sentence-generation.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use lib '.';
use lib './lib';

use Chemistry::Stoichiometry::Grammar;
use DSL::English::DataQueryWorkflows::Grammar;

use Grammar::TokenProcessing;

plan 5;

##-----------------------------------------------------------
## 1÷3
##-----------------------------------------------------------
my $focusGrammar1 = DSL::English::DataQueryWorkflows::Grammar;
my %focusRules1 = $focusGrammar1.^method_table;
my $ruleBody1 = '<workflow-command>';

my @randSentences1 = (^10).map({ random-sentence-generation(
        $ruleBody1,
        %focusRules1,
        max-iterations => 40,
        random-token-generators => Whatever,
        sep => ' ') }).sort.unique(as => { $_.join(' ') });

## 1
is @randSentences1.isa(Array),
        True,
        'DSL::English::DataQueryWorkflows::Grammar test: is Array';

## 2
is  @randSentences1.all ~~ Str,
        True,
        'DSL::English::DataQueryWorkflows::Grammar test: all Str';

## 3
is @randSentences1.elems ≥ 8,
        True,
        'DSL::English::DataQueryWorkflows::Grammar test: sufficient number of elements';

##-----------------------------------------------------------
## 4÷5
##-----------------------------------------------------------
grammar Parser {
        rule  TOP  { I <love> <lang> }
        token love { '♥' | '🤮' | love }
        token lang { < Raku Perl Rust Go Python Ruby > }
}

## 4
ok random-sentence-generation(Parser);

## 5
say random-sentence-generation(Parser, '<love>').raku;
ok random-sentence-generation(Parser, '<love>');

done-testing;



