### ----------------------------------------------------
### -- Rakuast::RakuDoc::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/050-debug-vals.rakutest
### ----------------------------------------------------
use v6.d;
use Test;
use Test::Output;

#test-output-verbosity(:on);

use RakuDoc::Render;

plan 32;

my $ast;
my $rv;
my $output;

# enum RDProcDebug <None All AstBlock BlockType Scoping Templates>;
my RakuDoc::Processor $rdp;

# AstBlock
$rdp  .= new(:test, :debug(AstBlock));
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    =head This is a header

    Some text
    =end rakudoc
    QAST
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };
like $output, / 'Handling: RakuAST::Doc::Block' /, 'got a handling message';
unlike $output, / 'Doc::Block type: rakudoc' /, 'didnt get block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
unlike $output, / 'Template' .+ 'source:' /, 'didnt get template message';

$rdp  .= new(:test, :debug(BlockType));
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };
unlike $output, / 'Handling: RakuAST::Doc::Block' /, 'didnt get a handling message';
like $output, / 'Doc::Block type: rakudoc' /, 'got block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
unlike $output, / 'Template' .+ 'source:' /, 'didnt get template message';

$rdp  .= new(:test, :debug(Scoping));
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };
unlike $output, / 'Handling: RakuAST::Doc::Block' /, 'didnt get a handling message';
unlike $output, / 'Doc::Block type: rakudoc' /, 'didnt get block message';
like $output, / 'Scope levels' /, 'got scoping message';
unlike $output, / 'Template' .+ 'source:' /, 'didnt get template message';

$rdp  .= new(:test, :debug(AstBlock, BlockType));
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };
like $output, / 'Handling: RakuAST::Doc::Block' /, 'got a handling message';
like $output, / 'Doc::Block type: rakudoc' /, 'got block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
unlike $output, / 'Template' .+ 'source:' /, 'didnt get template message';

$rdp  .= new(:test, :debug(Templates));
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
};
unlike $output, / 'Handling: RakuAST::Doc::Block' /, 'didnt get a handling message';
unlike $output, / 'Doc::Block type: rakudoc' /, 'didnt get block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
like $output, / 'Template' .+ 'source:' /, 'got template message';

$rdp  .= new(:test, :debug(All));
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };

like $output, / 'Handling: RakuAST::Doc::Block' /, 'got a handling message';
like $output, / 'Doc::Block type: rakudoc' /, 'got block message';
like $output, / 'Scope levels' /, 'got scoping message';
like $output, / 'Template' .+ 'source:' /, 'got template message';

$rdp  .= new(:test);
$rdp.debug(AstBlock, BlockType, Templates);
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
    };
like $output, / 'Handling: RakuAST::Doc::Block' /, 'got a handling message';
like $output, / 'Doc::Block type: rakudoc' /, 'got block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
like $output, / 'Template' .+ 'source:' /, 'got template message';

$rdp  .= new(:test);
$rdp.debug('AstBlock BlockType Templates');
$output = output-from {
    $rv = $rdp.render( $ast, :pre-finalised )
};
like $output, / 'Handling: RakuAST::Doc::Block' /, 'got a handling message';
like $output, / 'Doc::Block type: rakudoc' /, 'got block message';
unlike $output, / 'Scope levels' /, 'didnt get scoping message';
like $output, / 'Template' .+ 'source:' /, 'got template message';

done-testing;


