* FYI: GapContent test fix
@ 2006-02-02 10:50 Roman Kennke
2006-02-02 11:09 ` David Gilbert
0 siblings, 1 reply; 3+ messages in thread
From: Roman Kennke @ 2006-02-02 10:50 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 997 bytes --]
In the test for GapContent.insertString() we have tested the insertion of
a string at the index after the last character. There was a comment in
it saying that it is a bug in the JDK to not throw a
BadLocationException. However, AFAICS this is not the case. Suppose you
have the following content:
ABCDEFG
and now call GapContent.insertString(7, "XYZ"), then this will (quite
logically IMO) append this:
ABCDEFGXYZ
There is no need to throw a BadLocationException here. What might have
caused confusion here is the fact that the GapContent usually has a
trailing \n character, and normal insertion from an AbstractDocument
never inserts after the \n, but this is an implementation detail of the
document and not GapContent.
I checked in the appended patch to fix this problem.
2006-02-02 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/text/GapContent/insertString.java
(testGeneral): Fixed boundary case to pass with the JDK.
/Roman
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch; name="patch.diff", Size: 1176 bytes --]
Index: gnu/testlet/javax/swing/text/GapContent/insertString.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/GapContent/insertString.java,v
retrieving revision 1.3
diff -u -r1.3 insertString.java
--- gnu/testlet/javax/swing/text/GapContent/insertString.java 24 Jan 2006 17:18:56 -0000 1.3
+++ gnu/testlet/javax/swing/text/GapContent/insertString.java 2 Feb 2006 10:44:05 -0000
@@ -215,19 +215,17 @@
}
harness.check(gc.length(), 7);
- // insert at index of last character + 1 - the API docs say this should
- // raise a BadLocationException, but JDK1.5.0_06 doesn't (I reported this
- // to Sun as a bug in their implementation, will add a bug ID if one is assigned)
- pass = false;
+ // Insert at index of last character + 1. This appends the new string to
+ // the existing string.
try
{
gc.insertString(7, "XYZ");
}
catch (BadLocationException e)
{
- pass = true;
+ pass = false;
}
- harness.check(pass);
+ harness.check(gc.length(), 10);
// insert at index of last character + 2
pass = false;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FYI: GapContent test fix
2006-02-02 10:50 FYI: GapContent test fix Roman Kennke
@ 2006-02-02 11:09 ` David Gilbert
[not found] ` <1138879332.9591.57.camel@localhost.localdomain>
0 siblings, 1 reply; 3+ messages in thread
From: David Gilbert @ 2006-02-02 11:09 UTC (permalink / raw)
To: Roman Kennke; +Cc: mauve-patches
Hi Roman,
The API docs describe the first parameter (where) as:
|"where| - the starting position >= 0, < length()"
...and in this particular test I've used length(), so I'd expect the
BadLocationException to be thrown. To back this up further, the exact
same test on StringContent *does* throw the exception. I didn't hear
back from Sun yet on the bug report (apart from the automated response),
but I do expect that they'll accept it and fix it eventually.
Anyway, I'll let you know when I hear from them.
Regards,
Dave
Roman Kennke wrote:
>In the test for GapContent.insertString() we have tested the insertion of
>a string at the index after the last character. There was a comment in
>it saying that it is a bug in the JDK to not throw a
>BadLocationException. However, AFAICS this is not the case. Suppose you
>have the following content:
>
>ABCDEFG
>
>and now call GapContent.insertString(7, "XYZ"), then this will (quite
>logically IMO) append this:
>
>ABCDEFGXYZ
>
>There is no need to throw a BadLocationException here. What might have
>caused confusion here is the fact that the GapContent usually has a
>trailing \n character, and normal insertion from an AbstractDocument
>never inserts after the \n, but this is an implementation detail of the
>document and not GapContent.
>
>I checked in the appended patch to fix this problem.
>
>2006-02-02 Roman Kennke <kennke@aicas.com>
>
> * gnu/testlet/javax/swing/text/GapContent/insertString.java
> (testGeneral): Fixed boundary case to pass with the JDK.
>
>/Roman
>
>
>------------------------------------------------------------------------
>
>Index: gnu/testlet/javax/swing/text/GapContent/insertString.java
>===================================================================
>RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/GapContent/insertString.java,v
>retrieving revision 1.3
>diff -u -r1.3 insertString.java
>--- gnu/testlet/javax/swing/text/GapContent/insertString.java 24 Jan 2006 17:18:56 -0000 1.3
>+++ gnu/testlet/javax/swing/text/GapContent/insertString.java 2 Feb 2006 10:44:05 -0000
>@@ -215,19 +215,17 @@
> }
> harness.check(gc.length(), 7);
>
>- // insert at index of last character + 1 - the API docs say this should
>- // raise a BadLocationException, but JDK1.5.0_06 doesn't (I reported this
>- // to Sun as a bug in their implementation, will add a bug ID if one is assigned)
>- pass = false;
>+ // Insert at index of last character + 1. This appends the new string to
>+ // the existing string.
> try
> {
> gc.insertString(7, "XYZ");
> }
> catch (BadLocationException e)
> {
>- pass = true;
>+ pass = false;
> }
>- harness.check(pass);
>+ harness.check(gc.length(), 10);
>
> // insert at index of last character + 2
> pass = false;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FYI: GapContent test fix
[not found] ` <1138879332.9591.57.camel@localhost.localdomain>
@ 2006-02-02 15:47 ` David Gilbert
0 siblings, 0 replies; 3+ messages in thread
From: David Gilbert @ 2006-02-02 15:47 UTC (permalink / raw)
To: Roman Kennke; +Cc: Roman Kennke, mauve-patches
Roman Kennke wrote:
>Hi David,
>
>Am Donnerstag, den 02.02.2006, 11:16 +0000 schrieb David Gilbert:
>
>
>>Hi Roman,
>>
>>The API docs describe the first parameter (where) as:
>>
>>|"where| - the starting position >= 0, < length()"
>>
>>...and in this particular test I've used length(), so I'd expect the
>>BadLocationException to be thrown. To back this up further, the exact
>>same test on StringContent *does* throw the exception. I didn't hear
>>back from Sun yet on the bug report (apart from the automated response),
>>but I do expect that they'll accept it and fix it eventually.
>>
>>
>
>Now that is interesting. So I was a little too quick with my fix. It
>seemed to make sense to be able to append, but if StringContent behaves
>differently, I am not so sure anymore. So you think we should revert my
>patch?
>
>/Roman
>
>
>
I think so, but if you're busy it's not so important - I'll revisit it
when I hear back from Sun on the bug report.
Regards,
Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-02-02 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-02 10:50 FYI: GapContent test fix Roman Kennke
2006-02-02 11:09 ` David Gilbert
[not found] ` <1138879332.9591.57.camel@localhost.localdomain>
2006-02-02 15:47 ` David Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).