Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: solution wanted for break-on-spaces (w/specifics)

by LanX (Sage)
on Oct 24, 2021 at 09:44 UTC ( #11137952=note: print w/replies, xml ) Need Help??


in reply to Re: solution wanted for break-on-spaces (w/specifics)
in thread solution wanted for break-on-spaces (w/specifics)

> Testing for the number of elements is a weak test; you really need qualitative tests as well.

> I've included most of your tests;

I think the best way to test this, is to create these strings from joining @expected arrays.

By generating these arrays one can make sure to cover all edge cases.

As a side product you'll define a formal grammar. Like:

  • how are unpaired quotes to be handled?
  • what about multiple whitespaces in a row?
  • what about multi-line input?
  • what about whitespace at start and end of string?
It would also help testing sub-regexes individually.

Crafting the strings by hand is error prone, because there are far too many cases to handle.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^2: solution wanted for break-on-spaces (w/specifics)

Replies are listed 'Best First'.
Re^3: solution wanted for break-on-spaces (w/specifics)
by perl-diddler (Chaplain) on Oct 26, 2021 at 16:56 UTC
    Why do I need qualitative tests? I just wanted to know if the RE's broke the line into the expected number of sections. The original test strings were read from a data file, which was several pared down representations of what one might find as attr-value fields after an initial xml or html element.

    How are unpaired quotes handled? That's really a bit undefined, but I thought terminating them at the end of the "string", would be most forgiving. For multi-whitespace -- I would assume shell semantics. Multi-line input -- in some larger more general case, lf+cr are both types of white space, but I didn't want to clutter my question and test cases. As for whitespace prefixes and suffixes -- in both cases, there is no "non-whitespace" before or after (respectivly) those, so they make no difference in the final answer.

    As I tried to stress, the program wasn't really important, it was just something I threw together over a few hours that grew by "whim", to test the regex's against the input lines in the test-data.txt file. It wasn't meant as a formal test harness.

      > Why do I need qualitative tests?

      because it's far from simple. Even defining the edge-cases isn't trivial.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137952]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2021-11-30 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?