{
    "mode": "perldoc",
    "parameter": "Test::Specio",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test%3A%3ASpecio/json",
    "generated": "2026-06-14T00:49:57Z",
    "synopsis": "use Test::Specio qw( testconstraint :vars );\ntestconstraint(\nt('Foo'), {\naccept => [ 'foo', 'bar' ],\nreject => [ 42,    {}, $EMPTYSTRING, $HASHREF ],\n}\n);",
    "sections": {
        "NAME": {
            "content": "Test::Specio - Test helpers for Specio\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 0.47\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Test::Specio qw( testconstraint :vars );\n\ntestconstraint(\nt('Foo'), {\naccept => [ 'foo', 'bar' ],\nreject => [ 42,    {}, $EMPTYSTRING, $HASHREF ],\n}\n);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This package provides some helper functions and variables for testing Specio types.\n",
            "subsections": []
        },
        "EXPORTS": {
            "content": "This module provides the following exports:\n\ntestconstraint( $type, $tests, [ $describer ] )\nThis subroutine accepts two arguments. The first should be a Specio type object. The second is\nhashref which can contain the keys \"accept\" and \"reject\". Each key should contain an arrayref of\nvalues which the type accepts or rejects.\n\nThe third argument is optional. This is a sub reference which will be called to generate a\ndescription of the value being tested. This defaults to calling this package's \"describe\" sub,\nbut you can provide your own.\n\ndescribe($value)\nGiven a value, this subroutine returns a string describing that value in a useful way for test\noutput. It know about the various classes used for the variables exported by this package and\nwill do something intelligent when such a variable.\n\nbuiltinstests( $GLOB, $GLOBOVERLOAD, $GLOBOVERLOADFH )\nThis subroutine returns a hashref containing test variables for all builtin types. The hashref\nhas a form like this:\n\n{\nBool => {\naccept => [\n$ZERO,\n$ONE,\n$BOOLOVERLOADTRUE,\n$BOOLOVERLOADFALSE,\n...,\n],\nreject => [\n$INT,\n$NEGINT,\n$NUM,\n$NEGNUM,\n...,\n$OBJECT,\n],\n},\nMaybe => {...},\n}\n\nYou need to pass in a glob, an object which overloads globification, and an object which\noverloads globification to return an open filehandle. See below for more details on how to\ncreate these things.\n",
            "subsections": [
                {
                    "name": "Variables",
                    "content": "This module also exports many variables containing values which are useful for testing\nconstraints. Note that references are always empty unless stated otherwise. You can import these\nvariables individually or import all of them with the \":vars\" import tag.\n\n*   $ZERO\n\n*   $ONE\n\n*   $INT\n\nAn arbitrary positive integer.\n\n*   $NEGINT\n\nAn arbitrary negative integer.\n\n*   $NUM\n\nAn arbitrary positive non-integer number.\n\n*   $NEGNUM\n\nAn arbitrary negative non-integer number.\n\n*   $EMPTYSTRING\n\n*   $STRING\n\nAn arbitrary non-empty string.\n\n*   $NUMINSTRING\n\nAn arbitrary string which contains a number.\n\n*   $INTWITHNL1\n\nAn string containing an integer followed by a newline.\n\n*   $INTWITHNL2\n\nAn string containing a newline followed by an integer.\n\n*   $SCALARREF\n\n*   $SCALARREFREF\n\nA reference containing a reference to a scalar.\n\n*   $ARRAYREF\n\n*   $HASHREF\n\n*   $CODEREF\n\n*   $GLOBREF\n\n*   $FH\n\nAn opened filehandle.\n\n*   $FHOBJECT\n\nAn opened IO::File object.\n\n*   $REGEX\n\nA regex created with \"qr//\".\n\n*   $REGEXOBJ\n\nA regex created with \"qr//\" that was then blessed into class.\n\n*   $FAKEREGEX\n\nA non-regex blessed into the \"Regexp\" class which Perl uses internally for \"qr//\" objects.\n\n*   $OBJECT\n\nAn arbitrary object.\n\n*   $UNDEF\n\n*   $CLASSNAME\n\nA string containing a loaded package name.\n\n*   $BOOLOVERLOADTRUE\n\nAn object which overloads boolification to return true.\n\n*   $BOOLOVERLOADFALSE\n\nAn object which overloads boolification to return false.\n\n*   $STROVERLOADEMPTY\n\nAn object which overloads stringification to return an empty string.\n\n*   $STROVERLOADFULL\n\nAn object which overloads stringification to return a non-empty string.\n\n*   $STROVERLOADCLASSNAME\n\nAn object which overloads stringification to return a loaded package name.\n\n*   $NUMOVERLOADZERO\n\n*   $NUMOVERLOADONE\n\n*   $NUMOVERLOADNEG\n\n*   $NUMOVERLOADDECIMAL\n\n*   $NUMOVERLOADNEGDECIMAL\n\n*   $CODEOVERLOAD\n\n*   $SCALAROVERLOAD\n\nAn object which overloads scalar dereferencing to return a non-empty string.\n\n*   $ARRAYOVERLOAD\n\nAn object which overloads array dereferencing to return a non-empty array.\n\n*   $HASHOVERLOAD\n\nAn object which overloads hash dereferencing to return a non-empty hash.\n"
                },
                {
                    "name": "Globs and the T::GlobOverload package",
                    "content": "To create a glob you can pass around for tests, use this code:\n\nmy $GLOB = do {\nno warnings 'once';\n*SOMEGLOB;\n};\n\nThe \"T::GlobOverload\" package is defined when you load \"Test::Specio\" so you can create your\nown glob overloading objects. Such objects cannot be exported because the glob they return does\nnot transfer across packages properly.\n\nYou can create such a variable like this:\n\nlocal *FOO;\nmy $GLOBOVERLOAD = T::GlobOverload->new( \\*FOO );\n\nIf you want to create a glob overloading object that returns a filehandle, do this:\n\nlocal *BAR;\nopen BAR, '<', $^X or die \"Could not open $^X for the test\";\nmy $GLOBOVERLOADFH = T::GlobOverload->new( \\*BAR );\n"
                }
            ]
        },
        "SUPPORT": {
            "content": "Bugs may be submitted at <https://github.com/houseabsolute/Specio/issues>.\n\nI am also usually active on IRC as 'autarch' on \"irc://irc.perl.org\".\n",
            "subsections": []
        },
        "SOURCE": {
            "content": "The source code repository for Specio can be found at <https://github.com/houseabsolute/Specio>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Dave Rolsky <autarch@urth.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is Copyright (c) 2012 - 2021 by Dave Rolsky.\n\nThis is free software, licensed under:\n\nThe Artistic License 2.0 (GPL Compatible)\n\nThe full text of the license can be found in the LICENSE file included with this distribution.\n",
            "subsections": []
        }
    },
    "summary": "Test::Specio - Test helpers for Specio",
    "flags": [],
    "examples": [],
    "see_also": []
}