App-Actions

 view release on metacpan or  search on metacpan

t/function.t  view on Meta::CPAN

		isnt(App::Actions::Schema->invalid_exit, $_, "distinct from the run status $_") for 0 .. 2;
	};

	subtest '_is_type' => sub {
		my %cases = (
			null => [ [ undef ], [ 0, '' ] ],
			boolean => [ [ JSON::PP::true(), JSON::PP::false() ], [ 1, 0, 'true' ] ],
			array => [ [ [] ], [ {}, 'a' ] ],
			object => [ [ {} ], [ [], 'a' ] ],
			integer => [ [ 0, -3, '42' ], [ '1.0', '1e3', ' 1', "1\n", undef, [] ] ],
			number => [ [ 0, '-1.5', '.5', '1e-3', '3.' ], [ 'NaN', 'Inf', '1e', '', undef ] ],
			string => [ [ '', 'x', 0 ], [ undef, [], JSON::PP::true() ] ],
		);
		for my $type (sort keys %cases) {
			my ($yes, $no) = @{ $cases{$type} };
			is(App::Actions::Schema::_is_type($_, $type), 1, "$type accepts " . App::Actions::Schema::_show($_)) for @{$yes};
			is(App::Actions::Schema::_is_type($_, $type), 0, "$type refuses " . App::Actions::Schema::_show($_)) for @{$no};
		}
		is(App::Actions::Schema::_is_type('x', 'colour'), 0, 'an unknown type accepts nothing');
	};



( run in 0.856 second using v1.01-cache-2.11-cpan-60884a8df76 )