Astro-App-Satpass2
view release on metacpan or search on metacpan
inc/My/Module/Test/App.pm view on Meta::CPAN
If the method fails, the desired value is compared to the exception
using C<like()>, after converting the desired value to a C<Regex> if
needed.
If the method returns a blessed reference, the return for testing
purposes is set to C<undef>. In this case, all we're doing is testing to
see if the method call succeeded.
If the desired result is C<'true'> or C<'false'>, the result of the
method call is tested with C<ok()>. If the desired result is C<'false'>,
the actual result is logically inverted before the test.
If the desired result is a C<Regexp>, the results are tested with
C<like()>. If it is any other reference, the test is done with
C<is_deeply()>. Otherwise, they are tested with C<is()>.
=head2 call_m_result
call_m get => 'twilight', 'civil', 'Confirm civil twilight';
say call_m_result;
This subroutine returns whatever value was returned by the method call
executed by the most-recent C<call_m()>.
=head2 normalize_path
my $normalized = normalize_path( $path );
This subroutine normalizes paths. It converts them to absolute using
C<Cwd::cwd()>, then it performs OS-specific normalization on them.
Typically this consists of changing slash direction (MSWin32 and
friends) and lopping off trailing slashes (DragonFly BSD).
=head2 setup_app_mocker
my $mocker = setup_app_mocker();
This subroutine sets up to mock
L<Astro::App::Satpass2|Astro::App::Satpass2> using the tools provided by
L<Test2::Tools::Mock|Test2::Tools::Mock>. The C<new()>, C<get()>, and
C<set()> methods are mocked, but behind them is a hash that just stores
and returns values.
The return is not a mock L<Astro::App::Satpass2|Astro::App::Satpass2>
object, but an object that manages the mocking. This object needs to be
retained because it is also a sentinel that tears down the mock when it
is destroyed. See L<Test2::Tools::Mock|Test2::Tools::Mock> for details.
You actually get a new application object in the normal way:
my $app = Astro::App::Satpass2->new();
=head2 same_path
same_path $got, $want, 'Got the same path';
This subroutine implements a test to see if the first two arguments
represent the same file path. On systems that do not support reliable
inode results from C<stat()> (that is, MSWin32 and friends, riscos, and
VMS) the test is simply a comparison of normalized paths. On systems
that support (or are suspected to support) reliable inodes, if the
normalized paths are different the inode numbers are compared.
=head1 METHODS
This module also does some aspect-oriented programming (read: 'violates
encapsulation') by placing the following methods in the
L<Astro::App::Satpass2|Astro::App::Satpass2> name space:
=head2 __TEST__frame_stack_depth
call_m __TEST__frame_stack_depth => 1, 'Stack is empty';
This method returns the context frame stack depth. There is always 1
frame, even when the stack is nominally empty.
=head2 __TEST__is_exported
call_m __TEST__is_exported => 'foo', 1, 'Foo is exported';
This method returns C<1> if the given variable is currently exported,
and C<0> otherwise.
=head2 __TEST__raw_attr
call_m __TEST__raw_attr => '_twilight', '%.3f', -0.215,
'Twilight in radians';
This method bypasses the accessors and accesses attribute values
directly. It takes one or two arguments. The first is the name of the
hash key to be accessed. The second argument, which is optional, is an
C<sprintf> format to run the value through.
=head1 SEE ALSO
L<Astro::App::Satpass2|Astro::App::Satpass2>.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2>,
L<https://github.com/trwyant/perl-Astro-App-Satpass2/issues>, or in
electronic mail to the author.
=head1 AUTHOR
Thomas R. Wyant, III F<wyant at cpan dot org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2011-2025 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
( run in 1.000 second using v1.01-cache-2.11-cpan-39bf76dae61 )