Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use meta checks on arrays #131

andfarm opened this issue Sep 6, 2017 · 2 comments


Copy link

commented Sep 6, 2017

Attempting to make an assertion about the size of an array:

use Test2::V0;
use Test2::Tools::Compare;

is([0], array {
    prop size => 1;

doesn't work:

'Test2::Compare::Array=HASH(…)' does not support meta-checks

This seems like it should work -- it's certainly a lot clearer than asserting that item 0 exists.


This comment has been minimized.

Copy link

commented Mar 15, 2019

The original idea was that if you just want meta checks use the meta builder:
is([1], meta { prop size => 1 });
If you want to check both meta and regular then you have 2 options

Option 1: do 2 checks:

is([1], meta { prop size => 1 });
is([1], array { item 1; });
Option 2, nest an array check under meta:
is([1], meta { prop size => 1; prop this => array { item 1 })

That is all of course assuming this is a trivial example of something more complex. If you simply want to assert the value of some elements and insure there are no extra elements beyond it you have 'end':
is([1], array { item 1; end }) which will check the first item to make sure it is '1', then make sure there are no additional items in the array. This also works for bag and hash.

Now, I am open to arguments in favor of this feature, but I would like a compelling case where the options above are a burden compared to inline meta checks.


This comment has been minimized.

Copy link

commented Mar 16, 2019

#177 has been merged which fixes this.

@exodist exodist closed this Mar 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.