Name for #=== based assertion

I’ve had several requests that an assertion based on #=== be added to
Test::Unit. While I think it’s a fine idea, I haven’t yet found a name
that seems to fit, so I thought I’d ask and see if anyone else can come
up with something decent.

Nathaniel

<:((><

···

RoleModel Software, Inc.
EQUIP VI

nathaniel@NOSPAMtalbott.ws writes:

I’ve had several requests that an assertion based on #=== be added to
Test::Unit. While I think it’s a fine idea, I haven’t yet found a name
that seems to fit, so I thought I’d ask and see if anyone else can come
up with something decent.

Maybe…

assert_case_equal
assert_not_case_equal

This comes from ri, which calls === “case equality”

squeaker% ri Object.===
------------------------------------------------------------- Object#===
obj === anObject → true or false

···
 Case Equality---A synonym for Object#==, but typically overridden
 by descendents to provide meaningful semantics in case statements.

Has a double meaning – case insensitive string compare, but I can’t
think of anything better.


matt

I’ve heard this operator called the “threequal” operator.

I’ve also heard it called the “case equality” operator (since it is used
by ‘case’). I’m not sure if this is a good name, because /123/ ===
‘foo123’ has a truthful value, but I wouldn’t call /123/ and ‘foo123’
equal.

Paul

···

On Wed, Feb 12, 2003 at 12:05:05PM +0900, nathaniel@NOSPAMtalbott.ws wrote:

I’ve had several requests that an assertion based on #=== be added to
Test::Unit. While I think it’s a fine idea, I haven’t yet found a name
that seems to fit, so I thought I’d ask and see if anyone else can come
up with something decent.

Hi –

···

On Wed, 12 Feb 2003 nathaniel@NOSPAMtalbott.ws wrote:

I’ve had several requests that an assertion based on #=== be added to
Test::Unit. While I think it’s a fine idea, I haven’t yet found a name
that seems to fit, so I thought I’d ask and see if anyone else can come
up with something decent.

irb(main):007:0> def assert_case_of(x,y); x === y; end
=> nil
irb(main):008:0> assert_case_of(String, “abc”)
=> true

David


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

Thu, 13 Feb 2003 00:24:16 +0900, Paul Brannan pbrannan@atdesk.com pisze:

I’ve heard this operator called the “threequal” operator.

I’ve also heard it called the “case equality” operator (since it is used
by ‘case’). I’m not sure if this is a good name, because /123/ ===
‘foo123’ has a truthful value, but I wouldn’t call /123/ and ‘foo123’
equal.

I would call it matching.

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ Blog człowieka poczciwego.

I think “case equality” is the common term for it.
That term bothers me for essentially the reasons
you mention – it isn’t really “equality.”

“Threequal” is cute. Never heard that one.

In TRW, I tended to say “relationship operator.”
That’s a little vague, and I can’t remember where
I heard it. I’m pretty sure I didn’t make it up.

Off the top of my head, I think “equivalence
operator” might be a good term. And I did make
that one up just now. :wink:

Hal

···

----- Original Message -----
From: “Paul Brannan” pbrannan@atdesk.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, February 12, 2003 9:24 AM
Subject: Re: Name for #=== based assertion

On Wed, Feb 12, 2003 at 12:05:05PM +0900, nathaniel@NOSPAMtalbott.ws wrote:

I’ve had several requests that an assertion based on #=== be added to
Test::Unit. While I think it’s a fine idea, I haven’t yet found a name
that seems to fit, so I thought I’d ask and see if anyone else can come
up with something decent.

I’ve heard this operator called the “threequal” operator.

I’ve also heard it called the “case equality” operator (since it is used
by ‘case’). I’m not sure if this is a good name, because /123/ ===
‘foo123’ has a truthful value, but I wouldn’t call /123/ and ‘foo123’
equal.

Hal E. Fulton said:

Off the top of my head, I think “equivalence
operator” might be a good term. And I did make
that one up just now. :wink:

So you would suggest #assert_equivalent? It has a nice ring to it.
Objections?

Nathaniel

Hmm, I had ranged afield from the original topic.
I was talking terminology in general. :slight_smile: I don’t
have an opinion on that method name.

Probably assert_case_equal would be more intuitive
to more people. But as I said, I don’t
really have an opinion.

Hal

···

----- Original Message -----
From: “Nathaniel Talbott” ntalbott@rolemodelsoftware.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, February 12, 2003 4:50 PM
Subject: Re: Name for #=== based assertion

Hal E. Fulton said:

Off the top of my head, I think “equivalence
operator” might be a good term. And I did make
that one up just now. :wink:

So you would suggest #assert_equivalent? It has a nice ring to it.
Objections?

“Nathaniel Talbott” ntalbott@rolemodelsoftware.com writes:

Hal E. Fulton said:

Off the top of my head, I think “equivalence
operator” might be a good term. And I did make
that one up just now. :wink:

So you would suggest #assert_equivalent? It has a nice ring to it.
Objections?

Yes, since in English “equivalent” and “equal” are more or less
equivalent. :wink:

I would expect all of these to fail because the things are not
“equivalent”:

assert_equivalent(String, "foo")
assert_equivalent((0..10), 5)
assert_equivalent(/d/, "abcdefgh")

From Webster’s Revised Unabridged Dictionary (1913) [web1913]:

Equivalent \Equiv"alent, v. t.
To make the equivalent to; to equal; equivalence. [R.]

Test::Unit should try to play on ==='s use in case statements, or make
something up. E.g. in Ruby source === is called eqq:

enum.c: id_eqq = rb_intern(“===”);
object.c: rb_define_method(rb_cModule, “===”, rb_mod_eqq, 1);
parse.c: {tEQQ, “===”},
re.c: rb_define_method(rb_cRegexp, “===”, rb_reg_eqq, 1);

Mabye assert_eqqual? :stuck_out_tongue:

···


matt

Yes, since in English “equivalent” and “equal” are more or less
equivalent. :wink:

They may be equivalent, but they’re not equal. ;-)*2

Just kidding. I see your point.

From Webster’s Revised Unabridged Dictionary (1913) [web1913]:

Equivalent \Equiv"alent, v. t.
To make the equivalent to; to equal; equivalence. [R.]

This entry really confuses me. A transitive verb???
“A equivalents B.” Never heard the like before. Is there
an entry for the adjective?

But in all seriousness, I personally think that “equivalent”
carries a connotation different from “equal.” dictionary.com
(FWIW) says “something that is essentially equal to another.”
I sumbit they say “essentially” for a reason. They also say
“equal, as in value, force, or meaning” (but they don’t say
identity). Also: “having virtually identical or corresponding
parts.” (Note “virtually.”) However, in fairness, they also
say “Having similar or identical effects” where “identical”
implies more than similarity, but then they are talking about
the “effects” of the thing, not the thing itself.

Feel free to disagree. :slight_smile: I promise I won’t respond if you
do, as the subject rapidly grows silly.

Cheers,
Hal

···

----- Original Message -----
From: “Matt Armstrong” matt@lickey.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, February 12, 2003 5:28 PM
Subject: Re: Name for #=== based assertion

“Nathaniel Talbott” ntalbott@rolemodelsoftware.com writes:

Hal E. Fulton said:

Off the top of my head, I think “equivalence
operator” might be a good term. And I did make
that one up just now. :wink:

So you would suggest #assert_equivalent? It has a nice ring to it.
Objections?

Yes, since in English “equivalent” and “equal” are more or
less equivalent. :wink:

Well, yes… although if I saw #assert_equivalent, it would at least
make me go, “What’s the difference between that and #assert_equal?” Of
course, the fact that the name doesn’t immediately spell out what that
difference is is an immediate point against it…

Test::Unit should try to play on ==='s use in case
statements, or make something up. E.g. in Ruby source === is
called eqq:

enum.c: id_eqq = rb_intern(“===”);
object.c: rb_define_method(rb_cModule, “===”, rb_mod_eqq, 1);
parse.c: {tEQQ, “===”},
re.c: rb_define_method(rb_cRegexp, “===”, rb_reg_eqq, 1);

Mabye assert_eqqual? :stuck_out_tongue:

Or #assert_eqq? While a bit bizarre, that does have the advantage of
being short, distinguishable and memorable.

At this point I’m debating between #assert_case_equal and #assert_eqq. I
like the former’s tie to the case statement, but dislike its
confusability with string case (upper or lower) and its length. Plus, it
just doesn’t flow for me. The latter, well, I guess I already spelled
out what I do and don’t like about it.

Nathaniel

<:((><

···

Matt Armstrong [mailto:matt@lickey.com] wrote:

RoleModel Software, Inc.
EQUIP VI

How about assert_related

···

On Wednesday, February 12, 2003, at 11:08 PM, nathaniel@NOSPAMtalbott.ws wrote:

[snip]

At this point I’m debating between #assert_case_equal and #assert_eqq.
[snip]

nathaniel@NOSPAMtalbott.ws writes:

Or #assert_eqq? While a bit bizarre, that does have the advantage of
being short, distinguishable and memorable.

Yes, maybe there is no good English word for “the === operator” so
inventing one is reasonable.

“Pit Capitain” pit@capitain.de writes:

Someone suggested “assert_case_of” and “assert_not_case_of” recently
in this thread.

I like it:

assert_case_of( String, “hi” )

These works less well for Regexp. E.g. this is true:

assert_case_of(/x/, "fooxfoo")

Maybe borrow from Ruby’s own use of === in “when” statements:

assert_when(/x/, "fooxfoo")
assert_when(String, "bar")
assert_not_when(Array, "bar")
···


matt

From dict.org:

From Webster’s Revised Unabridged Dictionary (1913) [web1913]:

Equivalent \Equiv"alent, a. [L. aequivalens, -entis, p. pr.
of aequivalere to have equal power; aequus equal + valere to
be strong, be worth: cf. F. ['e]quivalent. See {Equal}, and
{Valiant}.]
1. Equal in wortir or value, force, power, effect, import,
and the like; alike in significance and value; of the same
import or meaning.

          For now to serve and to minister, servile and
          ministerial, are terms equivalent.    --South.

 2. (Geom.) Equal in measure but not admitting of
    superposition; -- applied to magnitudes; as, a square may
    be equivalent to a triangle.

(there is also a noun and a verb, but I don’t think either is what we’re
looking for).

Paul

···

On Thu, Feb 13, 2003 at 08:45:36AM +0900, Hal E. Fulton wrote:

----- Original Message -----
From: “Matt Armstrong” matt@lickey.com

From Webster’s Revised Unabridged Dictionary (1913) [web1913]:

Equivalent \Equiv"alent, v. t.
To make the equivalent to; to equal; equivalence. [R.]

This entry really confuses me. A transitive verb???
“A equivalents B.” Never heard the like before. Is there
an entry for the adjective?

Someone suggested “assert_case_of” and “assert_not_case_of” recently
in this thread.

I like it:

assert_case_of( String, “hi” )

Regards,
Pit

Someone suggested “assert_case_of” and “assert_not_case_of” recently
in this thread.

I like it:

assert_case_of( String, “hi” )

These works less well for Regexp. E.g. this is true:

assert_case_of(/x/, "fooxfoo")

Just as it was meant to :slight_smile:

In pseudo-code:

def assert_case_of( arg1, arg2 )
case arg2
when arg1
# ok
else
fail( … )
end
end
end

Maybe borrow from Ruby’s own use of === in “when” statements:

I think it is called “case statement” and “when clause”, but I’m not
sure.

assert_when(/x/, "fooxfoo")
assert_when(String, "bar")
assert_not_when(Array, "bar")

To me as a non-native English speaker this doesn’t read as good as
the others.

Regards,
Pit

···

On 13 Feb 2003 at 18:34, Matt Armstrong wrote: