GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Auto::Subtests(3) User Contributed Perl Documentation Test::Auto::Subtests(3)

Test::Auto::Subtests

Testing Automation

  package main;

  use Test::Auto;
  use Test::Auto::Parser;
  use Test::Auto::Subtests;

  my $test = Test::Auto->new(
    't/Test_Auto_Subtests.t'
  );

  my $parser = Test::Auto::Parser->new(
    source => $test
  );

  my $subtests = Test::Auto::Subtests->new(
    parser => $parser
  );

  # execute dynamic subtests

  # $subtests->standard

This package use the Test::Auto::Parser object to execute a set of dynamic subtests.

This package uses type constraints from:

Test::Auto::Types

This package has the following attributes:

  parser(Parser)

This attribute is read-only, accepts "(Parser)" values, and is required.

This package implements the following methods:

  attributes() : Any

This method registers and executes a subtest which tests the declared attributes.

attributes example #1
  # given: synopsis

  $subtests->attributes;
    

  document() : Any

This method registers and executes a subtest which tests the test document structure.

document example #1
  # given: synopsis

  $subtests->document;
    

  evaluator(Str $context) : Any

This method evaluates (using "eval") the context given and returns the result or raises an exception.

evaluator example #1
  # given: synopsis

  my $context = '1 + 1';

  $subtests->evaluator($context); # 2
    

  example(Num $number, Str $name, Str $type, CodeRef $callback) : Any

This method finds and evaluates (using "eval") the documented example and returns a "Test::Auto::Try" object (see Data::Object::Try). The "try" object can be used to trap exceptions using the "catch" method, and/or execute the code and return the result using the "result" method.

example example #1
  # given: synopsis

  $subtests->example(1, 'evaluator', 'method', sub {
    my ($tryable) = @_;

    ok my $result = $tryable->result, 'result ok';
    is $result, 2, 'meta evaluator test ok';

    $result;
  });
    

  functions() : Any

This method registers and executes a subtest which tests the declared functions.

functions example #1
  # given: synopsis

  $subtests->functions;
    

  inherits() : Any

This method registers and executes a subtest which tests the declared inheritances.

inherits example #1
  # given: synopsis

  $subtests->inherits;
    

  libraries() : Any

This method registers and executes a subtest which tests the declared type libraries.

libraries example #1
  # given: synopsis

  $subtests->libraries;
    

  methods() : Any

This method registers and executes a subtest which tests the declared methods.

methods example #1
  # given: synopsis

  $subtests->methods;
    

  package() : Any

This method registers and executes a subtest which tests the declared package.

package example #1
  # given: synopsis

  $subtests->package;
    

  plugin(Str $name) : Object

This method builds, tests, and returns a plugin object based on the name provided.

plugin example #1
  # given: synopsis

  $subtests->plugin('ShortDescription');
    

  registry() : InstanceOf["Type::Registry"]

This method returns a type registry object comprised of the types declare in the declared type libraries.

registry example #1
  # given: synopsis

  my $registry = $subtests->registry;
    

  routines() : Any

This method registers and executes a subtest which tests the declared routines.

routines example #1
  # given: synopsis

  $subtests->routines;
    

  scenario(Str $name, CodeRef $callback) : Any

This method finds and evaluates (using "eval") the documented scenario example and returns a "Test::Auto::Try" object (see Data::Object::Try). The "try" object can be used to trap exceptions using the "catch" method, and/or execute the code and return the result using the "result" method.

scenario example #1
  package main;

  use Test::Auto;

  my $test = Test::Auto->new(
    't/Test_Auto.t'
  );

  my $subtests = $test->subtests;

  $subtests->scenario('exports', sub {
    my ($tryable) = @_;

    ok my $result = $tryable->result, 'result ok';

    $result;
  });
    

  standard() : Subtests

This method is shorthand which registers and executes a series of other standard subtests.

standard example #1
  # given: synopsis

  # use:
  $subtests->standard;

  # instead of:
  # $self->package;
  # $self->document;
  # $self->libraries;
  # $self->inherits;
  # $self->attributes;
  # $self->methods;
  # $self->routines;
  # $self->functions;
  # $self->types;
    

  synopsis(CodeRef $callback) : Any

This method evaluates (using "eval") the documented synopsis and returns a "Test::Auto::Try" object (see Data::Object::Try). The "try" object can be used to trap exceptions using the "catch" method, and/or execute the code and return the result using the "result" method.

synopsis example #1
  # given: synopsis

  $subtests->synopsis(sub {
    my ($tryable) = @_;

    ok my $result = $tryable->result, 'result ok';
    is ref($result), 'Test::Auto::Subtests', 'isa ok';

    $result;
  });
    

  tryable(Any @arguments) : InstanceOf["Test::Auto::Try"]

This method returns a tryable object which can be used to defer code execution with a try/catch construct.

tryable example #1
  # given: synopsis

  my $tryable = $subtests->tryable;

  $tryable->call(sub { $_[0] + 1 });

  # $tryable->result(1);
  #> 2
    
tryable example #2
  # given: synopsis

  my $tryable = $subtests->tryable(1);

  $tryable->call(sub { $_[0] + $_[1] });

  # $tryable->result(1);
  #> 2
    

Al Newkirk, "awncorp@cpan.org"

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file" <https://github.com/iamalnewkirk/test-auto/blob/master/LICENSE>.

Wiki <https://github.com/iamalnewkirk/test-auto/wiki>

Project <https://github.com/iamalnewkirk/test-auto>

Initiatives <https://github.com/iamalnewkirk/test-auto/projects>

Milestones <https://github.com/iamalnewkirk/test-auto/milestones>

Issues <https://github.com/iamalnewkirk/test-auto/issues>

2020-05-13 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.