內容

名稱

Test2::EventFacet::Info::Table - 表格的中介表示。

說明

表格的中介表示,用於產生 Test2::EventFacet::Info 面向的特殊 Test::API::Context 方法。

語法

use Test2::EventFacet::Info::Table;
use Test2::API qw/context/;

sub my_tool {
    my $ctx = context();

    ...

    $ctx->fail(
        $name,
        "failure diag message",
        Test2::EventFacet::Info::Table->new(
            # Required
            rows => [['a', 'b'], ['c', 'd'], ...],

            # Strongly Recommended
            as_string => "... string to print when table cannot be rendered ...",

            # Optional
            header => ['col1', 'col2'],
            collapse => $bool,
            no_collapse => ['col1', ...],
        ),
    );

    ...

    $ctx->release;
}

my_tool();

屬性

$header_aref = $t->header()
$rows_aref = $t->rows()
$bool = $t->collapse()
$aref = $t->no_collapse()

以上皆直接連結到 Test2::EventFacet::Info 中描述的表格雜湊結構。

$str = $t->as_string()

如果已設定,此函式會傳回表格的字串形式,否則會傳回字串 "<TABLE NOT DISPLAYED>"

$href = $t->as_hash()

此函式會傳回 Test2::EventFacet::Info 用於表格的資料結構。

%args = $t->info_args()

此函式會傳回用於建構適當 Test2::EventFacet::Info 結構的引數。

return (table => $t->as_hash(), details => $t->as_string());

SOURCE

Test2 的原始碼存放庫位於 http://github.com/Test-More/test-more/

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2020 Chad Granum <exodist@cpan.org>。

此程式為自由軟體;您可以在與 Perl 相同的條款下重新散布或修改它。

請參閱 http://dev.perl.org/licenses/