1#!perl 2 3use strict; 4use warnings; 5 6use lib 't/lib'; 7use Test::More; 8use Test::Deep; 9use Test::Fatal 'lives_ok'; 10use List::Util 'first'; 11 12use TestSchema; 13use B; 14my $schema = TestSchema->deploy_or_connect(); 15$schema->prepopulate; 16 17# stolen from JSON::PP 18sub is_numeric { 19 my $value = shift; 20 my $b_obj = B::svref_2object(\$value); 21 my $flags = $b_obj->FLAGS; 22 return (( $flags & B::SVf_IOK or $flags & B::SVp_IOK 23 or $flags & B::SVf_NOK or $flags & B::SVp_NOK 24 ) and !($flags & B::SVf_POK )) 25} 26 27ok(is_numeric($schema->resultset('Foo')->first->bar_id),"bar_id has been 'numified' w/o is_numeric set"); 28 29for (map $_->id, $schema->resultset('Foo')->all) { 30 ok(is_numeric($_), "id $_ has been 'numified'"); 31} 32 33for (map +{$_->get_columns}, $schema->resultset('Foo')->all) { 34 ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'"); 35} 36 37for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) { 38 ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'"); 39} 40 41for (map +{$_->get_inflated_columns}, $schema->resultset('Foo')->all) { 42 ok(is_numeric($_->{id}), "id $_->{id} has been 'numified'"); 43} 44 45for ($schema->resultset('Foo')->search(undef, { 46 columns => { lol => 'id' }, 47})->all) { 48 lives_ok { $_->get_column('lol') } "doesn't break when using columns"; 49} 50 51done_testing; 52