Test::...Scalar(3pm)
π Test::...Scalar β the manual page, bestie edition π
okay so real talk, this is the Test::...Scalar page from the User Contributed Perl Documentation, and it's about testing scalar variables. no cap, it's a whole vibe. let's get into it π
β¨ NAME β¨
Test::Data::Scalar β test functions for scalar variables π
πΈ SYNOPSIS πΈ
use Test::Data qw(Scalar);
that's it. that's the whole summoning ritual π¦
π DESCRIPTION π
so this module is literally just a little collection of test utilities for scalar variables, periodt. you don't load it directly β you load it through Test::Data. that's the way that works, iykyk.
π§ Functions π§
blessed_ok( SCALAR )
ok if the SCALAR is a blessed reference. slay, it's got a class π
defined_ok( SCALAR )
ok if the SCALAR is defined. exists, present, main character.
undef_ok( SCALAR )
ok if the SCALAR is undefined. ghosting as a feature, honestly iconic.
dualvar_ok( SCALAR )
ok if the scalar is a dualvar.
How do I test this?
not me including that verbatim, but bestie, that's literally what the page says. the author is asking the void. we don't know. π
greater_than( SCALAR, BOUND )
ok if the SCALAR is numerically greater than BOUND. bigger number energy.
length_ok( SCALAR, LENGTH )
ok if the length of SCALAR is LENGTH. exactly that many characters, no more no less, we're measuring fr fr π
less_than( SCALAR, BOUND )
ok if the SCALAR is numerically less than BOUND. small but mighty.
maxlength_ok( SCALAR, LENGTH )
ok is the length of SCALAR is less than or equal to LENGTH. (yes, the original says "is the length", we're keeping it, it's part of the charm π)
minlength_ok( SCALAR, LENGTH )
ok is the length of SCALAR is greater than or equal to LENGTH. same grammar situation, same energy.
number_ok( SCALAR )
ok if the SCALAR is a number (or a string that represents a number).
At the moment, a number is just a string of digits. This needs work.
yeah. it's giving "shipped it, will fix later." we love honesty β¨
number_between_ok( SCALAR, LOWER, UPPER )
ok if the number in SCALAR sorts between the number in LOWER and the number in UPPER, numerically. numerically!! not alphabetically!! do not confuse these two, bestie.
β οΈ If you put something that isn't a number into UPPER or LOWER, Perl will try to make it into a number and you may get unexpected results. π«
perl is gonna do perl things. you've been warned.
string_between_ok( SCALAR, LOWER, UPPER )
ok if the string in SCALAR sorts between the string in LOWER and the string in UPPER, ASCII-betically. the string version. the other one. keep them straight π₯
readonly_ok( SCALAR )
ok is the SCALAR is read-only. it's locked in. literally.
ref_ok( SCALAR )
ok if the SCALAR is a reference. pointing at something, holding a little pointer to another thing, iconic behavior.
ref_type_ok( REF1, REF2 )
ok if REF1 is the same reference type as REF2. same kind of reference, matching vibes check out β
strong_ok( SCALAR )
ok is the SCALAR is not a weak reference. it's holding on. strong grip, main character energy πͺ
tainted_ok( SCALAR )
ok is the SCALAR is tainted.
(Tainted values may seem like a not-Ok thing, but remember, when you use taint checking, you want Perl to taint data, so you should have a test to make sure it happens.)
right?? it's not a bug, it's a feature, and you're testing that the feature is featuring π
untainted_ok( SCALAR )
ok if the SCALAR is not tainted. clean. fresh. no suspicious vibes.
weak_ok( SCALAR )
ok if the SCALAR is a weak reference. it's not holding on, and that's the point π
π TO DO π
the author's lil wishlist, we stan a transparent roadmap:
- add
is_a_filehandletest - add
is_vstringtest
one day bestie, one day π
π SEE ALSO π
go read these too, they're all in the same friend group:
Scalar::Util, Test::Data, Test::Data::Array, Test::Data::Function, Test::Data::Hash, Test::Builder
π SOURCE AVAILABILITY π
the source lives on Github, go be nosy (affectionate):
https://github.com/briandfoy/test-data
π«Ά AUTHOR π«Ά
brian d foy, "<briandfoy@pobox.com>" β absolute legend, thank you for your service π
Β©οΈ COPYRIGHT AND LICENSE Β©οΈ
Copyright Β© 2002-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
and that's the whole page!! perl v5.40.1, dated 2025-04-17 β mwah, go write some tests bestie, you're gonna eat π β¨π
π¦ where this page comes from
- debian trixie: libtest-data-perl 1.248-1 Β· Artistic-2.0
- ubuntu resolute: libtest-data-perl 1.248-1 Β· Artistic-2.0
- ubuntu stonking: libtest-data-perl 1.248-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms