File: TodoExample.pm

package info (click to toggle)
libtest-spec-perl 0.54-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 308 kB
  • sloc: perl: 2,502; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Test::Spec::TodoExample;

# Purpose: represents a `xit` block (ie. a pending/todo test)

use strict;
use warnings;

use Test::Spec qw(*TODO);

sub new {
    my ($class, $args) = @_;

    my $self = bless {}, $class;
    $self->{name}        = $args->{name};
    $self->{description} = $args->{description};
    $self->{reason}      = $args->{reason} || '(unimplemented)';
    $self->{builder}     = $args->{builder};

    return $self;
}

# Attributes
sub name        { shift->{name} }
sub description { shift->{description} }
sub reason      { shift->{reason} }
sub builder     { shift->{builder} }

# Methods
sub run {
    my ($self) = @_;

    local $TODO = $self->reason;
    my $builder = $self->builder;

    $builder->todo_start($TODO);
    $builder->ok(1, $self->description); # XXX: could fail the TOOD (or even run it?)
    $builder->todo_end();
}

1;