harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Loenko" <mloe...@gmail.com>
Subject Re: should strings in exceptions match the reference implementation?
Date Mon, 17 Apr 2006 11:02:12 GMT
Andrew,

2006/4/17, Andrew Zhang <zhanghuangzhu@gmail.com>:
> Hi, MIkhail,
>
> Thanks for the information.
>
> I took a quick look
> at  tests/api/java/util/regex/PatternSyntaxExceptionTest.
> Yes, the exception description is important to developers, however, I can't
> find the message defination in java spec.
> Am I missing something?

Being compatible to the spec is required but not sufficient for the success.
For example we follow common sense, not only the spec.

> If no,  don't you think test case such as
> "assertTrue(e.getDescription().equals("')'
> is expected."));" is a bit arbitrary?
> Is there anything wrong if the message is sth. like "Expected ")" is not
> found" ? Both are meaningful to developers.

Both messages are correct. Example of incorrect message for given password are
"Missing ;" or "Incorrect password" or etc

We have to have tests that catch improper change in the source code.
For example, if the message "Expected )" is designed then we have
to verify that exactly that message is thrown. And if someone tries
to make a change in the logic so that "Incorrect password" is thrown then
our unit test will catch it.

I know that test will not pass on RI but that is expected - it tests specifics
of Harmony implementation and should not pass on RI

Thanks,
Mikhail










>
> As Anton Avtamonov metioned(most of us agreeed) ,we should not regard such
> difference as a failure.
> Then, How to solve such problems? IMHO, we'd better avoid such cases, or at
> most, checking some key information instead of using "equals", e.g, in this
> case,
> checking whether the message is not null and contains ")" or sth like.
>
> I don't think change to code as following would solve the problem:
> if(Util.IsHarmony()){
> assertTrue(e.getDescription().equals("')' is expected."));
> }
> Then who's the rule maker? PatternSyntaxException class developers?
> Maybe if there are some spec or documents which define these messages, I'll
> support such testing way. :-)
>
> On 4/17/06, Mikhail Loenko <mloenko@gmail.com> wrote:
> >
> >
> >
> > Hi Andrew
> >
> > Look at tests/api/java/util/regex/PatternSyntaxExceptionTest to get some
> > ideas. When you parse something and that something is incorrect the
> > message does matter.
> >
> > And you have a test to verify that you do not report ()s mismatch when
> > the problem is somewhere else.
> >
> > Thanks,
> > Mikhail
> >
> > > I think RI should contain similiar information so that we can write some
> > > test cases, which both RI and Harmony could pass, by verifying keywords
> > > instead.
> > > If "isHarmony()" is used, then what's the expected message? I don't
> > think
> > > there's a "Harmony exception message spec" :-)
> > > People may argue which message is best or more meanfuling :)
> > >
> > > Wishes,
> > > > --
> > > > Anton Avtamonov,
> > > > Intel Middleware Products Division
> > > >
> > > > ---------------------------------------------------------------------
> > > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Andrew Zhang
> > > China Software Development Lab, IBM
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Andrew Zhang
> China Software Development Lab, IBM
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message