1use Test2::V0;
2use Test2::API qw/test2_stack/;
3use PerlIO;
4# HARNESS-NO-FORMATTER
5
6imported_ok qw{
7    ok pass fail diag note todo skip
8    plan skip_all done_testing bail_out
9
10    gen_event
11
12    intercept context
13
14    cmp_ok
15
16    subtest
17    can_ok isa_ok DOES_ok
18    set_encoding
19    imported_ok not_imported_ok
20    ref_ok ref_is ref_is_not
21    mock mocked
22
23    dies lives try_ok
24
25    is like isnt unlike
26    match mismatch validator
27    hash array object meta number string bool check_isa
28    in_set not_in_set check_set
29    item field call call_list call_hash prop check all_items all_keys all_vals all_values
30    etc end filter_items
31    T F D DF E DNE FDNE U L
32    event fail_events
33    exact_ref
34};
35
36ok(Test2::Plugin::ExitSummary->active, "Exit Summary is loaded");
37ok(defined(Test2::Plugin::SRand->seed), "SRand is loaded");
38
39subtest strictures => sub {
40    local $^H;
41    my $hbefore = $^H;
42    Test2::V0->import;
43    my $hafter = $^H;
44
45    my $strict = do { local $^H; strict->import(); $^H };
46
47    ok($strict,               'sanity, got $^H value for strict');
48    ok(!($hbefore & $strict), "strict is not on before loading Test2::V0");
49    ok(($hafter & $strict),   "strict is on after loading Test2::V0");
50};
51
52subtest warnings => sub {
53    local ${^WARNING_BITS};
54    my $wbefore = ${^WARNING_BITS} || '';
55    Test2::V0->import;
56    my $wafter = ${^WARNING_BITS} || '';
57
58    my $warnings = do { local ${^WARNING_BITS}; 'warnings'->import(); ${^WARNING_BITS} || '' };
59
60    ok($warnings, 'sanity, got ${^WARNING_BITS} value for warnings');
61    ok($wbefore ne $warnings, "warnings are not on before loading Test2::V0") || diag($wbefore, "\n", $warnings);
62    ok(($wafter & $warnings), "warnings are on after loading Test2::V0");
63};
64
65subtest utf8 => sub {
66    ok(utf8::is_utf8("癸"), "utf8 pragma is on");
67
68    # -2 cause the subtest adds to the stack
69    my $format = test2_stack()->[-2]->format;
70    my $handles = $format->handles or return;
71    for my $hn (0 .. @$handles) {
72        my $h = $handles->[$hn] || next;
73        my $layers = { map {$_ => 1} PerlIO::get_layers($h) };
74        ok($layers->{utf8}, "utf8 is on for formatter handle $hn");
75    }
76};
77
78subtest "rename imports" => sub {
79    package A::Consumer;
80    use Test2::V0 ':DEFAULT', '!subtest', subtest => {-as => 'a_subtest'};
81    imported_ok('a_subtest');
82    not_imported_ok('subtest');
83};
84
85subtest "no meta" => sub {
86    package B::Consumer;
87    use Test2::V0 '!meta';
88    imported_ok('meta_check');
89    not_imported_ok('meta');
90};
91
92done_testing;
93
941;
95