Test2::Tools::Exports(3pm) Perl Programmers Reference Guide Test2::Tools::Exports(3pm)

# [NAME](#NAME)

Test2::Tools::Exports - Tools for validating exporters.

# [DESCRIPTION](#DESCRIPTION)

These are tools for checking that symbols have been imported into your namespace.

# [SYNOPSIS](#SYNOPSIS)

```
    use Test2::Tools::Exports
    use Data::Dumper;
    imported_ok qw/Dumper/;
    not_imported_ok qw/dumper/;
```

# [EXPORTS](#EXPORTS)

All subs are exported by default.

[imported\_ok(@SYMBOLS)](#imported_ok%28@SYMBOLS%29)

Check that the specified symbols exist in the current package. This will not find inherited subs. This will only find symbols in the current package's symbol table. This **WILL NOT** confirm that the symbols were defined outside of the package itself.

```
    imported_ok( '$scalar', '@array', '%hash', '&sub', 'also_a_sub' );
    
```

@SYMBOLS can contain any number of symbols. Each item in the array must be a string. The string should be the name of a symbol. If a sigil is present then it will search for that specified type, if no sigil is specified it will be used as a sub name.

[not\_imported\_ok(@SYMBOLS)](#not_imported_ok%28@SYMBOLS%29)

Check that the specified symbols do not exist in the current package. This will not find inherited subs. This will only look at symbols in the current package's symbol table.

```
    not_imported_ok( '$scalar', '@array', '%hash', '&sub', 'also_a_sub' );
    
```

@SYMBOLS can contain any number of symbols. Each item in the array must be a string. The string should be the name of a symbol. If a sigil is present, then it will search for that specified type. If no sigil is specified, it will be used as a sub name.

# [CAVEATS](#CAVEATS)

Before Perl 5.10, it is very difficult to distinguish between a package scalar that is undeclared vs declared and undefined. Currently "imported\_ok" and "not\_imported\_ok" cannot see package scalars declared using "our $var" unless the variable has been assigned a defined value.

This will pass on recent perls, but fail on perls older than 5.10:

```
    use Test2::Tools::Exports;
    our $foo;
    # Fails on perl onlder than 5.10
    imported_ok(qw/$foo/);
```

If $foo is imported from another module, or imported using "use vars qw/$foo/;" then it will work on all supported perl versions.

```
    use Test2::Tools::Exports;
    use vars qw/$foo/;
    use Some::Module qw/$bar/;
    # Always works
    imported_ok(qw/$foo $bar/);
```

# [SOURCE](#SOURCE)

The source code repository for Test2-Suite can be found at *https://github.com/Test-More/test-more/*.

# [MAINTAINERS](#MAINTAINERS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad)

# [AUTHORS](#AUTHORS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad~2)

# [COPYRIGHT](#COPYRIGHT)

Copyright Chad Granum &lt;exodist@cpan.org&gt;.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See *http://dev.perl.org/licenses/*

2026-08-31 perl v5.44.0

---

Document: Test2::Tools::Exports(3pm) from perl 5.44.0-r1 (Chainguard OS)
Source: https://github.com/Perl/perl5.git
