-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
81 lines (50 loc) · 2.12 KB
/
README
File metadata and controls
81 lines (50 loc) · 2.12 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
NAME
T2 - Define the T2 namespace that can always be used to access
functionality from a Test2 bundle such as Test2::V1.
DESCRIPTION
If you want a global T2 that can be called from anywhere, without
needing to import Test2::V1 in every package, you can do that with the
T2 module.
This defines the T2 namespace so you can always call methods on it like
T2->ok(1, "pass") and T2->done_testing.
SYNOPSIS
Create a file/package somewhere to initialize it. Only initialize it
once!
package My::Global::T2;
# Load Test2::V1 (or future bundle)
# Add any customizations like including extra tools, overriding tools, etc.
use Test2::V1 ...;
# Load T2, it will find the T2() handle in the current package and make it global
use T2;
#########################################
# Alternatively you can do this:
my $handle = Test2::V1::Handle->new(...);
require T2;
T2->import($handle);
Now use it somewhere in your code:
use My::Global::T2;
Now T2 is available from any package
T2->ok(1, "pass");
T2->ok(0, "fail");
T2->done_testing;
Note: In this case T2 is a package name, not a function, so T2() will
not work. However you can import Test2::V1 into any package providing a
T2() function that will be used preferentially to the T2 namespace.
Bonus: You can use the T2::tool(...) form to leverage the original
prototype of the tool.
T2::is(@foo, 3, "Array has 3 elements");
Without the prototype (method form does not allow prototypes) you would
have to prefix scalar on @foo:
T2->is(scalar(@foo), 3, "Array matches expections");
SOURCE
The source code repository for T2 can be found at
https://github.com/Test-More/T2/.
MAINTAINERS
Chad Granum <exodist@cpan.org>
AUTHORS
Chad Granum <exodist@cpan.org>
COPYRIGHT
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See http://dev.perl.org/licenses/