BoutrosLab-TSVStream

 view release on metacpan or  search on metacpan

t/01-tsvstreamdyn.t  view on Meta::CPAN

### 00-tsvstream.t #############################################################
# Basic tests for tsvstream objects

### Includes ###################################################################

# Safe Perl
use warnings;
use strict;

use Carp;
use File::Temp;
use FindBin qw($Bin);
use lib "$Bin/../lib";

use Test::More tests => 122;
use Test::Exception;

### Tests ######################################################################

package TestFooBar;

use Moose;
use namespace::autoclean;
use MooseX::ClassAttribute;

class_has '_fields' => (is => 'ro', isa => 'ArrayRef', default => sub { [ qw(foo bar) ] } );

with 'BoutrosLab::TSVStream::IO::Role::Dyn';

has 'foo'    => ( is => 'rw', isa => 'Str' );
has 'bar'    => ( is => 'rw', isa => 'Str' );

around BUILDARGS => sub {
	my $orig  = shift;
	my $class = shift;
	my $arg   = ref($_[0]) ? $_[0] : { @_ };
	$class->$orig( $arg );
	};

# __PACKAGE__->meta->make_immutable;

package TestOnlyDyn;

use Moose;

with 'BoutrosLab::TSVStream::IO::Role::Dyn';

{
my $_fields = [ ];
sub _fields { return $_fields }
}

around BUILDARGS => sub {
	my $orig  = shift;
	my $class = shift;
	my $arg   = ref($_[0]) ? $_[0] : { @_ };
	$class->$orig( $arg );
	};

# __PACKAGE__->meta->make_immutable;

package main;

sub _from_here {
	my $text = shift;
	$text =~ s/^\s*://gxms;
	$text;
	}

sub _strip_2_cols {
	my $t = shift;
	$t =~ s/^[^\t\n]+\t[^\t\n]+\t?//gxms;
	return $t;
	}

sub _strip_header {
	my $t = shift;
	$t =~ s/^[^\n]*\n//xms;
	return $t;
	}

sub _strip_body {
	my $t = shift;
	$t =~ m/(^[^\n]*\n)/xms;
	return $1;
	}



( run in 2.579 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )