A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Test2 cheat sheet for Perl

Cheat sheet

Links

Docs entry point

  • Test2::Tools::Compare
    • is like isnt unlike
    • match mismatch validator
    • hash array bag object meta number float rounded within string subset bool
    • in_set not_in_set check_set
    • item field call call_list call_hash prop check all_items all_keys all_vals all_values
    • etc end filter_items
    • T F D DF E DNE FDNE U L
    • event fail_events
    • exact_ref

Summary

=head2 SYNOPSIS

use Test2::V0;

# Match regex in a hash
like( $some_hash, hash {                        # <-- Must use `like` keyword to make regex below work
    field 'message' => qr/Caught exception/;    # <-- Note `field` keyword and trailing semicolon. Quotes around key optional
    end();                                      # <-- Enforce that no other keys are present, optional
}, 'Logged error correctly');                   # <-- Test description and parentheses () are optional

Comparisons

is(
    {
        a => 1,
        b => 'foo',
    },
    {
        a => D(),   # value is Defined
        b => E(),   # value Exists
        c => DNE(), # key/value Does Not Exist
    },
    'I can haz Test2?'
);

Todo - legacy

use Test::More;

TODO: {
    local $TODO = 'Still working on this';
    ok(0, "work in progress");
}

Todo2

use Test2::Tools::Tiny qw/todo/;

todo 'Still working on this' => sub {
    ok(0, "failing test gonna fail");
}; # <--- remember the semicolon!

See t/regression/todo_and_facets.t


Chrome extensions: Download manager reviews


  • DownThemAll: Queues, but doesn't intercept
  • Thunder Download Manager: Intercepts, but doesn't queue
  • Free Download Manager: Just says "Loading..." (on Ubuntu)
  • Chrono Download Manager: Intercepts and queues! And resumes. Perfect!