File: exporter-all.t

package info (click to toggle)
liboverload-filecheck-perl 0.013-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,088 kB
  • sloc: perl: 2,030; ansic: 97; makefile: 8
file content (36 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download
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
#!/usr/bin/perl -w

# Copyright (c) 2018, cPanel, LLC.
# All rights reserved.
# http://cpanel.net
#
# This is free software; you can redistribute it and/or modify it under the
# same terms as Perl itself. See L<perlartistic>.

use strict;
use warnings;

use Test2::Bundle::Extended;
use Test2::Tools::Explain;
use Test2::Plugin::NoWarnings;

use Overload::FileCheck q{:all};

my $not_there = q{/should/not/be/there};    # improve

ok( !-e $not_there, "-e 'not_there' file is missing when unmocked" );
ok( !-f $not_there, "-f 'not_there' file is missing when unmocked" );

mock_file_check( 'e' => sub { CHECK_IS_TRUE } );
ok( -e $not_there,  "-e 'not_there' missing file exists when mocked" );
ok( !-f $not_there, "-f 'not_there' still false" );

mock_file_check( f => sub { CHECK_IS_TRUE } );
ok( -e $not_there, "-e mocked => true" );
ok( -f $not_there, "-f mocked => true" );

unmock_all_file_checks();
ok( !-e $not_there, "-e unmocked  => false" );
ok( !-f $not_there, "-f unmocked => false" );

done_testing;