Test::S...m::Delta(3)
π Test::S...m::Delta π
okay so bestie, this is a page from the User Contributed Perl Documentation section, and it's all about Test::Stream::Delta β the little data structure that holds every single difference between two nested data structures. it's giving forensic scientist energy honestly πβ¨
π« DEPRECATED π«
bestie. sit down. i need to tell you something.
This distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow.
it's not you, it's the ecosystem. if you need a conversion guide, go read Test::Stream::Manual::ToTest2 β it'll walk you through the whole glow-up. π
πΈ DESCRIPTION πΈ
This is used by Test::Stream::Compare. When data structures are compared, a delta gets returned. Deltas are a tree datastructure that represent all the differences between 2 other data structures.
like, imagine two nested data structures walk into a room and the delta is the receipts of everything they disagreed on. no cap. π
π METHODS π
β CLASS METHODS β
$class->add_column($NAME => sub { ... })$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. (yes bestie, unique. the table will not tolerate duplicates.)
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.
Test::Stream::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.
Test::Stream::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.
lowkey this one's a "you get what you get" situation. it will not hold your hand, it will not yell at you, it will just return false and let you deal. π
π¦ 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 deltas children, not the delta itself. (main character delta said "not my fault, check my kids" π)
$aref = $delta->id$delta->set_id([$type, $name])
Id for the delta, this is 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 are "HASH", "ARRAY", "SCALAR", "META", and "METHOD".
$val = $delta->got$delta->set_got($val)
Deltas are produced by comparing a received data structure 'got' against a check data structure 'check'. The 'got' attribute 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 structure 'got' against a check data structure 'check'. The 'check' attribute contains the value that was expected in the comparison.
"check" and "chk" are aliases for the same attribute. two names, one icon, periodt. π
$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 to 'got' or 'check'.
$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 Test::Stream can be found at http://github.com/Test-More/Test-Stream/.
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright 2015 Chad Granum <exodist7@gmail.com>.
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/
and that's the whole page bestie!! ππ
cute little sign-off for you: this was rendered from the perl v5.42.0 docs, dated 2025-07-25, filed under Test::S...m::Delta(3) in the User Contributed Perl Documentation section. go forth and diff your data structures, you absolute legend. π«Άβ¨π
π¦ where this page comes from
- fedora 43: perl-Test-Stream 1.302027-35.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms