The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Kantan::Expect - Assertion

SYNOPSIS

  expect($x)->to_be(3);

METHODS

expect($x)->to_be_defined()

Pass if the value is defined.

expect($x)->to_be_truthy()
expect($x)->to_be_true()

Pass if the value is truthy.

expect($x)->to_be_falsy()
expect($x)->to_be_false()

Pass if the value is falsy.

expect($x)->to_equal($y)
expect($x)->to_be($y)

Pass if the value to equal $y.

expect($code : CodeRef)->to_throw()

Take the coderef. Pass if the code throws exception.

expect($x)->to_match($re : Regexp)

Pass if $x matches $re.

expect($x)->to_be_a($v : Regexp)
expect($x)->to_be_an($v : Regexp)

Pass if $x->$_isa($v) is true.

expect($x)->to_equal_as_a_set_of($v : ArrayRef)
expect($x)->to_be_a_set_of($v : ArrayRef)
expect($x)->to_be_a_sub_set_of($v : ArrayRef)
expect($x)->to_be_a_super_set_of($v : ArrayRef)

Pass if $x to equal $v but ignores the order of the elements.

expect($x)->to_equal_as_a_bag_of($v : ArrayRef)
expect($x)->to_be_a_bag_of($v : ArrayRef)
expect($x)->to_be_a_sub_bag_of($v : ArrayRef)
expect($x)->to_be_a_super_bag_of($v : ArrayRef)

Pass if $x to equal $v but ignores the order of the elements and it ignores duplicate elements.

expect($x)->to_be_a_sub_hash_of($v : HashRef)
expect($x)->to_be_a_super_hash_of($v : HashRef)

Pass if $x is a "super-hash" or "sub-hash" of $v.