|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Test case modularityWith the [chan pipe] patch and also with other, not-yet-TIPped stuff
of mine, I noticed that the checking of error messages in the test suite is often made with strict string equality. This makes sense for many messages which are likely frozen for eternity, but there is a specific subpopulation which is more dynamic: messages enumerating subcommands of an ensemble. This means that every extension of an ensemble in the core needs fixing test cases that are completely unrelated to the new subcommand: tests expecting the message bad subcommand "foo": must be a, b, c, or d. must be updated to check for bad subcommand "foo": must be a, b, c, d, or e. Is there a good reason to do so ? Why not [regexp {^bad subcommand}] ? -Alex ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Tcl-Core mailing list Tcl-Core@... https://lists.sourceforge.net/lists/listinfo/tcl-core |
|
|
Re: Test case modularityAlexandre Ferrieux wrote:
> This means that every extension of an ensemble in the core needs > fixing test cases that are completely unrelated to the new subcommand: > tests expecting the message > > bad subcommand "foo": must be a, b, c, or d. > > must be updated to check for > > bad subcommand "foo": must be a, b, c, d, or e. > > Is there a good reason to do so ? Why not [regexp {^bad subcommand}] ? I've wondered about that in the past too. I'm not sure; perhaps it is wiser to allow the checking that the list of subcommands is what it is expected to be as it helps enforce coverage. But if you do want to do a non-exact match, please do this instead: -match glob -result {bad subcommand "foo": must be *} It's easier to read, and doesn't obscure what the string was when a failure happens. A more complete example might be this: test chan-0.1 {bad chan subcommand} -returnCodes error -body { chan foobar } -match glob -result {bad subcommand "foobar": must be *} Let's compare that with the traditional way of doing this (assuming we're doing glob matching; regexps don't make this easier). test chan-0.1 {bad chan subcommand} { string match {1 {bad subcommand "foobar": must be *}} \ [list [catch {chan foobar} msg] $msg] } 1 I think the new-style one is clearer, especially when things go wrong! YMMV (but I hope not...) Donal. ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Tcl-Core mailing list Tcl-Core@... https://lists.sourceforge.net/lists/listinfo/tcl-core |
|
|
|
|
|
Re: Test case modularityOn 7/5/08, Donal K. Fellows <donal.k.fellows@...> wrote:
> > test chan-0.1 {bad chan subcommand} -returnCodes error -body { > chan foobar > } -match glob -result {bad subcommand "foobar": must be *} > FWIW, I have updated the ref impl of 304 to include these more generic (and more modern) test cases in the three places where the addition of [chan pipe] required updating anyway. Also, thanks to TCT members who have already voted for 304. I will be offline from now to July 21st, so when the deadline comes on next Wednesday, if the outcome is positive, feel free to commit for me. -Alex ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Tcl-Core mailing list Tcl-Core@... https://lists.sourceforge.net/lists/listinfo/tcl-core |
| Free Forum Powered by Nabble | Forum Help |