File: shared_examples.t

package info (click to toggle)
libtest-spec-perl 0.54-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 308 kB
  • sloc: perl: 2,502; makefile: 2
file content (48 lines) | stat: -rwxr-xr-x 2,373 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
41
42
43
44
45
46
47
48
#!/usr/bin/env perl
#
# shared_examples.t
#
# Test cases for Test::Spec shared example definition and inclusion.
# Executes shared_examples_spec.pl and validates its TAP output.
#
########################################################################
#
use strict;
use warnings;
use FindBin qw($Bin);
BEGIN { require "$Bin/test_helper.pl" };

use Test::More;

my @results = parse_tap("shared_examples_spec.pl");
my %passing = map { $_->description => 1 } grep { $_->is_test } @results;

sub test_passed {
  my $desc = shift;
  my $testdesc = "- $desc";
  ok(exists $passing{$testdesc}, $desc);
}

test_passed("A context importing an example group can take at least one example");
test_passed("A context importing an example group can take more than one example");
test_passed("A context importing an example group with an inner block nests properly");
test_passed("A context importing an example group can have custom behavior");
test_passed("A context importing an example group can be reopened");
test_passed("A context importing an example group executes");
test_passed("Another context importing an example group can take at least one example");
test_passed("Another context importing an example group can take more than one example");
test_passed("Another context importing an example group with an inner block nests properly");
test_passed("Another context importing an example group can have custom behavior, too");
test_passed("Another context importing an example group can be reopened");
test_passed("Another context can have behavior that doesn't interfere with example groups in sub-contexts");
test_passed("Another context importing an example group accumulates examples in the same way that describe() does");

@results = parse_tap("another_shared_examples_spec.pl");
%passing = map { $_->description => 1 } grep { $_->is_test } @results;

test_passed("A context in a second spec importing an example group defined in another package can take at least one example");
test_passed("A context in a second spec importing an example group defined in another package can take more than one example");
test_passed("A context in a second spec importing an example group defined in another package with an inner block nests properly");
test_passed("A context in a second spec importing an example group defined in another package can be reopened");

done_testing();