This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
spelling: till -> until
[perl5.git] / cpan / Test-Simple / t / Modern / Builder_Provider.t
CommitLineData
6bdb8877
CG
1use strict;
2use warnings;
3
4use Scalar::Util qw/reftype/;
5
6{
7 package My::Provider;
8 use Test::Builder::Provider;
9}
10
11My::Provider->import();
12my $anointed = __PACKAGE__->can('TB_TESTER_META');
13
14require Test::More;
15Test::More->import;
16
17ok($anointed, "Importing our provider anointed us");
18
19can_ok(
20 'My::Provider',
21 qw{
22 TB_PROVIDER_META builder TB anoint gives give provides provide export
23 import nest
24 }
25);
26
27is(reftype(My::Provider->TB_PROVIDER_META), 'HASH', "Got Metadata");
28
29isa_ok(My::Provider->builder, 'Test::Builder');
30isa_ok(My::Provider->TB, 'Test::Builder');
31
32{
33 package My::Provider;
34
35 provide foo => sub { 'foo' };
36 provide hsh => { a => 1 };
37
38 give xxx => sub { 'xxx' };
39 give arr => [ 1 .. 5 ];
40
41 provide nestx => sub(&) { TB->ok(&nest($_[0]), "Internal") };
42
43 provides qw/bar baz/;
44 gives qw/aaa bbb/;
45
46 provides qw/nesta nestb/;
47
48 sub bar { 'bar' }
49 sub baz { 'baz' }
50 sub aaa { 'aaa' }
51 sub bbb { 'bbb' }
52
53 sub nesta { &nest($_->[0]) }
54 sub nestb { &nest($_->[0]) }
55}
56
57My::Provider->import();
58
59can_ok(
60 __PACKAGE__,
61 qw{ foo xxx nestx bar baz aaa bbb nesta nestb }
62);
63
64{
65 no strict 'vars';
66 no warnings 'once';
67 is_deeply(\%hsh, { a => 1 }, "imported hash");
68 is_deeply(\@arr, [ 1 .. 5 ], "imported array");
69}
70
71nestx(
72 sub { ok(1, "Foo") }
73);
74
75done_testing();