Re: Does tcltest2.2 have a set equivalence-relation?

From: Bob Techentin (techentin.robert_at_mayo.edu)
Date: 10/02/03


Date: Thu, 2 Oct 2003 10:53:16 -0500


"Cameron Laird" <claird@lairds.com> wrote
>
> In coding terms, the situation is this: suppose I write
> test array_names {Note that order isn't guaranteed} {
> set a(1) one_thing
> set a(2) another
> array names a
> } {1 2}
> What I *really* want the answer to be is "{1 2} OR {2 1}, that is,
call
> the lists equal if they're equal as 'sets' or 'bags' or
'collections'."
> Does tcltest give me a succinct way to express that?

Cameron,

It looks like you could use customMatch to define an out-of-order list
matching script, then use the -match switch on your test. I've never
tried it, but as I look at the docs, it appears to be one of those
enormously flexible options that is just dying to be exploited.

Or, if you want to solve just this specific case , just change the
test script to return [lsort [array names x]]. Throw in a -unique
flag if you want a 'bag' comparison.

Bob

-- 
Bob Techentin                   techentin.robert@NOSPAMmayo.edu
Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/


Relevant Pages

  • Using "Perl Best Practices" inside-out objects
    ... I'm having trouble returning an array from a class implemented ... The test script where I am attempting to retrieve an array from an ... sub getData{ ...
    (comp.lang.perl.misc)
  • Re: Using "Perl Best Practices" inside-out objects
    ... Below are two snippets of code: ... The test script where I am attempting to retrieve an array from an ... I think the main problem is on the line where I am assigning an array ...
    (comp.lang.perl.misc)
  • Re: Encryption with Python
    ... I'm also puzzeld with your results. ... Here is a little test script, ... which generates 16mb array and scans it. ... crypto method you are using is a secret, please give the basic idea, ...
    (comp.lang.python)
  • global array?
    ... Is there any ways to have global variable that is array? ... *my test script ... submitting this varaible"); ... echo $list; ...
    (comp.lang.php)
  • Re: removing element of array
    ... Charles K. Clarkson wrote: ... I tried to write a small test script to figure this out, ... I used array references in my ... > the original array ref. ...
    (perl.beginners)