Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Using Test::More to make sense of documentation

by ELISHEVA (Prior)
on May 01, 2009 at 11:39 UTC ( [id://761266]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
       is($actual, $expected, $descriptionOfWhatYouTried);
    
    ...
    
       # to check what got captured by a regular expression
       is(eval { 'abcdef' =~ /^(\w+)/; $1 }, 'ab', q{tried /^\w+/});
    
  2. or download this
    not ok 1 - tried /^\w+/
    #   Failed test 'tried /^\w+/'
    ...
    #     expected: 'ab'
    1..1
    # Looks like you failed 1 test of 1.
    
  3. or download this
       #changed is to isnt
       #This doesn't work. Captures 'abcdef' instead of just 'ab'
    
       isnt(eval { 'abcdef' =~ /^(\w+)/; $1 }, 'ab', q{tried /^\w+/});
    
  4. or download this
    #using perl MyExperiments.pl
    
    ...
    MyExperiments.pl....ok
    All tests successful.
    Files=1, Tests=10,  0 wallclock secs ( 0.05 cusr +  0.04 csys =  0.09 
    +CPU)
    
  5. or download this
    use strict;
    use warnings;
    ...
    
    #BINGO! this worked
    is(eval {'abcdeee' =~ /(.)(\1+)/;"$1$2"}, 'eee', q{using /(.)(\1+)/;"$
    +1$2"});
    
  6. or download this
    use strict;
    use warnings;
    ...
    
    regexRepeat('abcdeeef', 'eee');   #only one to find
    regexRepeat('abbb;eeef', 'bbb');  #should find first
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://761266]
Approved by ww
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found