Intertangle-Yarn

 view release on metacpan or  search on metacpan

t/Intertangle/Yarn/Graphene/Matrix.t  view on Meta::CPAN

#!/usr/bin/env perl

use Test::Most tests => 6;
use Modern::Perl;
use Intertangle::Yarn::Graphene;

subtest "Matrix stringify" => sub {
	my $m = Intertangle::Yarn::Graphene::Matrix->new;
	$m->init_from_float([ 0..15 ]);

	is "$m", <<EOF;
[
    0 1 2 3
    4 5 6 7
    8 9 10 11
    12 13 14 15
]
EOF
};

subtest "Matrix from ArrayRef" => sub {
	my $m = Intertangle::Yarn::Graphene::Matrix->new_from_arrayref(
		[
			[ 1, 0, 0, 0 ],
			[ 0, 1, 0, 0 ],
			[ 0, 0, 1, 0 ],
			[ 0, 0, 0, 0 ],
		]
	);

	is "$m", <<EOF;
[
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 0
]
EOF
};

subtest "Matrix from ArrayRef must be correct size" => sub {
	throws_ok {
		Intertangle::Yarn::Graphene::Matrix->new_from_arrayref(
			[
				[ 1, 0, 0, 0 ],
				[ 0, 0, 1, 0 ],
				[ 0, 0, 0, 0 ],
			]
		);
	} qr/4x4/, 'too few rows';

	throws_ok {
		Intertangle::Yarn::Graphene::Matrix->new_from_arrayref(
			[
				[ 1, 0, 0, 0 ],
				[ 0, 0, 1, 0 ],
				[ 0, 0, 0, 0 ],
				[ 0, 0, 0, 0 ],
				[ 0, 0, 0, 0 ],
			]
		);
	} qr/4x4/, 'too many rows';

	throws_ok {



( run in 2.901 seconds using v1.01-cache-2.11-cpan-d8267643d1d )