From Test::Simple to Test::Extreme - Bonus Material 49

Testing Domains

Data Types with Test::Data

  • Test::Data - test functions for particular variable types

    • whole mess of test functions to perform on Scalars, Arrays, Hashes, Functions

    • The theory here is that the easier it is for you to write the test, then you are more likely to write the test.

    • For instance, here are some tricky things it can test:

  • Scalars:

        blessed_ok( SCALAR )      # Ok if the SCALAR is a
                                  # blessed reference.
    
        readonly_ok( SCALAR )     # Ok is the SCALAR is read-only.
    
        ref_type_ok( REF1, REF2 ) # Ok if REF1 is the same reference
                                  # type as REF2.
    
        weak_ok( SCALAR )         # Ok if the SCALAR is a weak
                                  # reference.
    
        strong_ok( SCALAR )       # Ok if the SCALAR is not a weak
                                  # reference.
    
  • Arrays:

        array_none_ok( ITEM, ARRAY [, NAME] )     # Ok is no
                                                  # element of ARRAY
                                                  # is ITEM.
    
        array_once_ok( ITEM, ARRAY [, NAME] )     # Ok is only one
                                                  # element ARRAY
                                                  # is ITEM.
    
        array_multiple_ok( ITEM, ARRAY [, NAME] ) # Ok if more than
                                                  # one element of
                                                  # ARRAY is ITEM.
    
        array_minstr_ok( ITEM, ARRAY [, NAME] )   # Ok is all elements
                                                  # of ARRAY are
                                                  # asciibetically
                                                  # greater than or
                                                  # equal to MAX.
    
        array_maxstr_ok( ITEM, ARRAY [, NAME] ) # Ok is all elements
                                                # of ARRAY are
                                                # asciibetically less
                                                # than or equal to MAX.
    

 

YAPC::CA << Previous | Index | Next >>
Copyright © 2003 Michael Graham