Class-Abstract

 view release on metacpan or  search on metacpan

t/extended_tests.t  view on Meta::CPAN

	}

	# new(): verify concrete class still works in the same context
	{
		local $Class::Abstract::BYPASS                 = 0;
		local $Class::Abstract::config{harness_bypass} = $config{harness_bypass_on};
		local $ENV{HARNESS_ACTIVE}                     = $config{harness_active_off};

		my $obj;
		lives_ok { $obj = ET::Concrete->new() }
			'new(concrete) lives in production context (only abstract class is blocked)';
		ok blessed($obj), 'concrete object is blessed in production context';
	}

	# check_abstract(): same production context
	{
		local $Class::Abstract::BYPASS                 = 0;
		local $Class::Abstract::config{harness_bypass} = $config{harness_bypass_on};
		local $ENV{HARNESS_ACTIVE}                     = $config{harness_active_off};

		throws_ok { Class::Abstract::check_abstract($config{pkg_abstract}) }

t/integration.t  view on Meta::CPAN


subtest 'end-to-end: enforcement in production context (no harness, default settings)' => sub {
	plan tests => 3;

	# Production: BYPASS=0, harness_bypass=1 (default), HARNESS_ACTIVE='' (no harness)
	{
		local $Class::Abstract::BYPASS                 = 0;
		local $Class::Abstract::config{harness_bypass} = 1;
		local $ENV{HARNESS_ACTIVE}                     = '';

		# Abstract class must be blocked
		throws_ok { IT::Vehicle->new() }
			qr/Cannot instantiate abstract class IT::Vehicle directly/,
			'abstract IT::Vehicle blocked in production context';

		# Concrete subclass must succeed
		lives_ok { IT::Car->new() }
			'concrete IT::Car succeeds in production context';
	}

	# Multi-level: IT::Animal (abstract), IT::Mammal (also abstract), IT::Dog (concrete)
	{
		local $Class::Abstract::BYPASS                 = 0;
		local $Class::Abstract::config{harness_bypass} = 1;

t/unit.t  view on Meta::CPAN

		'set_return() was called inside import() for the typed return';
};

# Purpose: import() must not add anything to Class::Abstract's own @ISA
subtest 'import() -- does not register Class::Abstract into its own @ISA' => sub {
	plan tests => 1;

	# Snapshot the ISA array before any call
	my @snapshot = @Class::Abstract::ISA;

	# Re-entering import() from the same module is blocked by the self-guard.
	# We verify the invariant directly: ISA must be identical before and after.
	is_deeply \@Class::Abstract::ISA, \@snapshot,
		'@Class::Abstract::ISA is unchanged (self-registration guard holds)';
};

# ===========================================================================
# SECTION: new()
#
# POD contract:
#   - Returns a blessed empty hashref of class $class



( run in 0.857 second using v1.01-cache-2.11-cpan-bbe5e583499 )