Test2::...e::Delta(3)
π Test2::Compare::Delta β the manual, bestie π
okay so this is the User Contributed Perl Documentation page for Test2::...e::Delta(3), aka Test2::Compare::Delta. no cap, it's the whole manual, just with the vibes turned all the way up. π
β¨ NAME β¨
Test2::Compare::Delta β Representation of differences between nested data structures. literally the receipts for why your data didn't match. π§Ύ
π¦ DESCRIPTION π¦
This is used by Test2::Compare. When data structures are compared a delta will be returned. Deltas are a tree data structure that represent all the differences between two other data structures.
so yeah, it's a whole tree of "here's what's off." it's giving detective work but make it data structures. π³π
π METHODS π
π§ͺ CLASS METHODS π§ͺ
$class->add_column($NAME => sub { ... })and$class->add_column($NAME, %PARAMS)β this can be used to add columns to the table that it produced when a comparison fails. The first argument should always be the column name, which must be unique.
The first form simply takes a coderef that produces the value that should be displayed in the column for any given delta. The arguments passed into the sub are the delta, and the row ID.
Test2::Compare::Delta->add_column(
Foo => sub {
my ($delta, $id) = @_;
return $delta->... ? 'foo' : 'bar'
},
);
The second form allows you some extra options. The value key is required, and must be a coderef. All other keys are optional.
Test2::Compare::Delta->add_column(
'Foo', # column name
value => sub { ... }, # how to get the cell value
alias => 'FOO', # Display name (used in table header)
no_collapse => $bool, # Show column even if it has no values?
);
$bool = $class->remove_column($NAME)β this will remove the specified column. This will return true if the column existed and was removed. This will return false if the column did not exist. No exceptions are thrown. If a missing column is a problem then you need to check the return yourself. that's the whole tea, bestie. π΅$class->set_column_alias($NAME, $ALIAS)β this can be used to change the table header, overriding the default column names with new ones.
π ATTRIBUTES π
$bool = $delta->verified,$delta->set_verified($bool)β this will be true if the delta itself matched, if the delta matched then the problem is in the delta's children, not the delta itself. so the delta is fine, it's the kids. π$aref = $delta->id,$delta->set_id([$type, $name])β ID for the delta, used to produce the path into the data structure. An example is['HASH' => 'foo']which means the delta is in the path...->{'foo'}. Valid types areHASH,ARRAY,SCALAR,META, andMETHOD.$val = $delta->got,$delta->set_got($val)β Deltas are produced by comparing a received data structuregotagainst a check data structurecheck. Thegotattribute contains the value that was received for comparison.$check = $delta->chk,$check = $delta->check,$delta->set_chk($check),$delta->set_check($check)β Deltas are produced by comparing a received data structuregotagainst a check data structurecheck. Thecheckattribute contains the value that was expected in the comparison.
check and chk are aliases for the same attribute. iykyk. π«Ά
$aref = $delta->children,$delta->set_children([$delta1, $delta2, ...])β a Delta may have child deltas. If it does then this is an arrayref with those children.$dne = $delta->dne,$delta->set_dne($dne)β sometimes a comparison results in one side or the other not existing at all, in which case this is set to the name of the attribute that does not exist. This can be set togotorcheck.$e = $delta->exception,$delta->set_exception($e)β this will be set to the exception in cases where the comparison failed due to an exception being thrown.
π OTHER π
$string = $delta->render_gotβ renders the string that should be used in a table to represent the received value in a comparison.$string = $delta->render_checkβ renders the string that should be used in a table to represent the expected value in a comparison.$bool = $delta->should_showβ this will return true if the delta should be shown in the table. This is normally true for any unverified delta. This will also be true for deltas that contain extra useful debug information.$aref = $delta->filter_visibleβ this will produce an arrayref of[ $path => $delta ]for all deltas that should be displayed in the table.$aref = $delta->table_headerβ this returns an array ref of the headers for the table.$string = $delta->table_opβ this returns the operator that should be shown in the table.$string = $delta->table_check_linesβ this returns the defined lines (extra debug info) that should be displayed.$string = $delta->table_got_linesβ this returns the generated lines (extra debug info) that should be displayed.$aref = $delta->table_rowsβ this returns an arrayref of table rows, each row is itself an arrayref.@table_lines = $delta->tableβ returns all the lines of the table that should be displayed.
π SOURCE π
The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/.
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
βοΈ COPYRIGHT βοΈ
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
okay that's the whole manual, bestie β you ate. this was perl v5.42.0, dated 2025-07-28, for Test2::...e::Delta(3). πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms