### ----------------------------------------------------
### -- Grok
### -- Licenses: Artistic-2.0
### -- Authors: Jeff Armstrong
### -- File: xt/83-grok-exception-types.rakutest
### ----------------------------------------------------
use v6;

use Test;
use Test::Output;

plan 130;

use lib $?FILE.IO.parent;
use TestUtils;

use Grok;

for (
  Backtrace                                         ,
  Backtrace::Frame                                  ,
  CX::Done                                          ,
  CX::Emit                                          ,
  CX::Last                                          ,
  CX::Next                                          ,
  CX::Proceed                                       ,
  CX::Redo                                          ,
  CX::Return                                        ,
  CX::Succeed                                       ,
  CX::Take                                          ,
  CX::Warn                                          ,
  Exception                                         ,
  Failure                                           ,
  X::AdHoc                                          ,
  X::Anon::Augment                                  ,
  X::Anon::Multi                                    ,
  X::Assignment::RO                                 ,
  X::Attribute::NoPackage                           ,
  X::Attribute::Package                             ,
  X::Attribute::Required                            ,
  X::Attribute::Undeclared                          ,
  X::Augment::NoSuchType                            ,
  X::Bind                                           ,
  X::Bind::NativeType                               ,
  X::Bind::Slice                                    ,
  X::Caller::NotDynamic                             ,
  X::Cannot::Lazy                                   ,
  X::Channel::ReceiveOnClosed                       ,
  X::Channel::SendOnClosed                          ,
  X::Comp                                           ,
  X::Composition::NotComposable                     ,
  X::Constructor::Positional                        ,
  X::Control                                        ,
  X::ControlFlow                                    ,
  X::ControlFlow::Return                            ,
  X::DateTime::TimezoneClash                        ,
  X::Declaration::Scope                             ,
  X::Declaration::Scope::Multi                      ,
  X::Does::TypeObject                               ,
  X::Dynamic::NotFound                              ,
  X::Eval::NoSuchLang                               ,
  X::Export::NameClash                              ,
  X::IO                                             ,
  X::IO::Chdir                                      ,
  X::IO::Chmod                                      ,
  X::IO::Copy                                       ,
  X::IO::Cwd                                        ,
  X::IO::Dir                                        ,
  X::IO::DoesNotExist                               ,
  X::IO::Link                                       ,
  X::IO::Mkdir                                      ,
  X::IO::Move                                       ,
  X::IO::Rename                                     ,
  X::IO::Rmdir                                      ,
  X::IO::Symlink                                    ,
  X::IO::Unlink                                     ,
  X::Inheritance::NotComposed                       ,
  X::Inheritance::Unsupported                       ,
  X::Method::InvalidQualifier                       ,
  X::Method::NotFound                               ,
  X::Method::Private::Permission                    ,
  X::Method::Private::Unqualified                   ,
  X::Mixin::NotComposable                           ,
  X::NYI                                            ,
  X::NoDispatcher                                   ,
  X::Numeric::Real                                  ,
  X::OS                                             ,
  X::Obsolete                                       ,
  X::OutOfRange                                     ,
  X::Package::Stubbed                               ,
  X::Parameter::Default                             ,
  X::Parameter::MultipleTypeConstraints             ,
  X::Parameter::Placeholder                         ,
  X::Parameter::Twigil                              ,
  X::Parameter::WrongOrder                          ,
  X::Phaser::Multiple                               ,
  X::Phaser::PrePost                                ,
  X::Placeholder::Block                             ,
  X::Placeholder::Mainline                          ,
  X::Pod                                            ,
  X::Proc::Async                                    ,
  X::Proc::Async::AlreadyStarted                    ,
  X::Proc::Async::BindOrUse                         ,
  X::Proc::Async::CharsOrBytes                      ,
  X::Proc::Async::MustBeStarted                     ,
  X::Proc::Async::OpenForWriting                    ,
  X::Proc::Async::TapBeforeSpawn                    ,
  X::Proc::Unsuccessful                             ,
  X::Promise::CauseOnlyValidOnBroken                ,
  X::Promise::Vowed                                 ,
  X::Redeclaration                                  ,
  X::Role::Initialization                           ,
  X::Scheduler::CueInNaNSeconds                     ,
  X::Seq::Consumed                                  ,
  X::Sequence::Deduction                            ,
  X::Signature::NameClash                           ,
  X::Signature::Placeholder                         ,
  X::Str::Numeric                                   ,
  X::StubCode                                       ,
  X::Syntax                                         ,
  X::Syntax::Augment::WithoutMonkeyTyping           ,
  X::Syntax::Comment::Embedded                      ,
  X::Syntax::Confused                               ,
  X::Syntax::InfixInTermPosition                    ,
  X::Syntax::Malformed                              ,
  X::Syntax::Missing                                ,
  X::Syntax::NegatedPair                            ,
  X::Syntax::NoSelf                                 ,
  X::Syntax::Number::RadixOutOfRange                ,
  X::Syntax::P5                                     ,
  X::Syntax::Perl5Var                               ,
  X::Syntax::Regex::Adverb                          ,
  X::Syntax::Regex::SolitaryQuantifier              ,
  X::Syntax::Reserved                               ,
  X::Syntax::Self::WithoutObject                    ,
  X::Syntax::Signature::InvocantMarker              ,
  X::Syntax::Term::MissingInitializer               ,
  X::Syntax::UnlessElse                             ,
  X::Syntax::Variable::Match                        ,
  X::Syntax::Variable::Numeric                      ,
  X::Syntax::Variable::Twigil                       ,
  X::Temporal                                       ,
  X::Temporal::InvalidFormat                        ,
  X::TypeCheck                                      ,
  X::TypeCheck::Assignment                          ,
  X::TypeCheck::Binding                             ,
  X::TypeCheck::Return                              ,
  X::TypeCheck::Splice                              ,
  X::Undeclared                                     ,
) -> $thing {

  my $file = get-output-name($thing).IO;

  # Generate reference output
  $file.spurt( output-from({grok($thing)}).&purified )
    unless $file.e;

  # Test reference output
  is  output-from( { grok($thing) } ).&purified,
      $file.IO.slurp,
      $thing.^name;

}

say 'done';

done-testing;



