WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
142772
Fix StringView misplaced implementations after
r181525
and
r181558
https://bugs.webkit.org/show_bug.cgi?id=142772
Summary
Fix StringView misplaced implementations after r181525 and r181558
Dhi Aurrahman
Reported
2015-03-16 21:48:03 PDT
Fix StringView typos after
r181525
and
r181558
Attachments
Patch
(8.60 KB, patch)
2015-03-16 21:54 PDT
,
Dhi Aurrahman
no flags
Details
Formatted Diff
Diff
Patch
(14.90 KB, patch)
2015-03-17 01:26 PDT
,
Dhi Aurrahman
no flags
Details
Formatted Diff
Diff
Patch
(15.63 KB, patch)
2015-03-17 21:25 PDT
,
Dhi Aurrahman
no flags
Details
Formatted Diff
Diff
Patch
(17.28 KB, patch)
2015-03-18 13:28 PDT
,
Dhi Aurrahman
no flags
Details
Formatted Diff
Diff
Patch for landing
(17.28 KB, patch)
2015-03-18 17:27 PDT
,
Dhi Aurrahman
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Dhi Aurrahman
Comment 1
2015-03-16 21:54:41 PDT
Created
attachment 248809
[details]
Patch
Benjamin Poulain
Comment 2
2015-03-16 23:03:46 PDT
Comment on
attachment 248809
[details]
Patch I messed up, thanks for fixing after me.
Darin Adler
Comment 3
2015-03-16 23:14:52 PDT
Comment on
attachment 248809
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248809&action=review
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:220 > + StringView reference(String("abcdefg"));
These tests look incorrect. This creates a dangling StringView that points to a String that has already been deleted. I’m surprised that tests written this way don’t immediately fail with the StringView string lifetime assertion when run in a debug build.
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:230 > + ASSERT_TRUE(reference.startsWith(oneLetterPrefix));
These should be using EXPECT, not ASSERT.
Benjamin Poulain
Comment 4
2015-03-16 23:42:29 PDT
Comment on
attachment 248809
[details]
Patch Oops, I did not notice the test issues :(
Dhi Aurrahman
Comment 5
2015-03-17 01:26:57 PDT
Created
attachment 248830
[details]
Patch
Darin Adler
Comment 6
2015-03-17 09:25:08 PDT
Comment on
attachment 248830
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248830&action=review
No 16-bit coverage in the tests?
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:228 > + RefPtr<StringImpl> reference = StringImpl::create(reinterpret_cast<const LChar*>("abcdefg")); > + RefPtr<StringImpl> emptyPrefix = StringImpl::create(reinterpret_cast<const LChar*>("")); > + RefPtr<StringImpl> oneLetterPrefix = StringImpl::create(reinterpret_cast<const LChar*>("a")); > + RefPtr<StringImpl> shortPrefix = StringImpl::create(reinterpret_cast<const LChar*>("ab")); > + RefPtr<StringImpl> longPrefix = StringImpl::create(reinterpret_cast<const LChar*>("abcd")); > + RefPtr<StringImpl> upperCasePrefix = StringImpl::create(reinterpret_cast<const LChar*>("AB")); > + RefPtr<StringImpl> notPrefix = StringImpl::create(reinterpret_cast<const LChar*>("cd")); > + RefPtr<StringImpl> withLatin1CharsPrefix = StringImpl::create(reinterpret_cast<const LChar*>("Ã b")); > + RefPtr<StringImpl> spacePrefix = StringImpl::create(reinterpret_cast<const LChar*>(" "));
Should just be: String reference = "abcdefg"; Direct use of StringImpl is unnecessary.
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:230 > + StringView referenceStringView(*reference.get());
If we are only testing 8-bit then this could just be: StringView referenceStringView(reinterpret_cast<const LChar*>("abcdefg"), 7); We could also make a helper function to make a StringView from a literal to make the test short and readable.
Dhi Aurrahman
Comment 7
2015-03-17 18:12:30 PDT
Comment on
attachment 248830
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248830&action=review
>> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:230 >> + StringView referenceStringView(*reference.get()); > > If we are only testing 8-bit then this could just be: > > StringView referenceStringView(reinterpret_cast<const LChar*>("abcdefg"), 7); > > We could also make a helper function to make a StringView from a literal to make the test short and readable.
Hi Darin, I'm not sure I completely understand. If I put something like: StringView stringViewFromLiteral(const char* characters) { return StringView(reinterpret_cast<const LChar*>(characters), strlen(characters)); } // I guess this one is for 16-bit StringView stringViewFromUTF8(const char* characters) { return String::fromUTF8(characters); } TEST(WTF, StringViewStartsWithBasic) { StringView reference = stringViewFromLiteral("abcdefg"); StringView referenceUTF8 = stringViewFromLiteral("àîûèô"); StringView prefix = stringViewFromLiteral("abc"); StringView prefixUTF8 = stringViewFromLiteral("àîû"); EXPECT_TRUE(reference.startsWith(prefix)); EXPECT_TRUE(referenceUTF8.startsWith(prefixUTF8)); } Got it pass in debug build. What do you think?
Dhi Aurrahman
Comment 8
2015-03-17 21:25:32 PDT
Created
attachment 248907
[details]
Patch
Dhi Aurrahman
Comment 9
2015-03-17 21:26:23 PDT
Comment on
attachment 248907
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248907&action=review
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:491 > + EXPECT_FALSE(referenceUTF8.endsWithIgnoringASCIICase(reference));
I'm not sure about this
Darin Adler
Comment 10
2015-03-18 08:35:32 PDT
Comment on
attachment 248907
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248907&action=review
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:221 > +StringView stringViewFromLiteral(const char* characters) > +{ > + return StringView(reinterpret_cast<const LChar*>(characters), strlen(characters)); > +}
This is great.
> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:226 > +StringView stringViewFromUTF8(const char* characters) > +{ > + return String::fromUTF8(characters); > +}
This won’t work. The string is deleted when the function returns and the StringView is left pointing to deleted memory.
Dhi Aurrahman
Comment 11
2015-03-18 09:17:56 PDT
Comment on
attachment 248907
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248907&action=review
>> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:226 >> +} > > This won’t work. The string is deleted when the function returns and the StringView is left pointing to deleted memory.
Honestly, I'm not sure how to create the 16-bit flavor of it.
Dhi Aurrahman
Comment 12
2015-03-18 13:28:19 PDT
Created
attachment 248956
[details]
Patch
Dhi Aurrahman
Comment 13
2015-03-18 13:31:34 PDT
Comment on
attachment 248956
[details]
Patch Hope this will work. Thanks to Benjamin for the tip.
Dhi Aurrahman
Comment 14
2015-03-18 17:27:18 PDT
Created
attachment 248994
[details]
Patch for landing
WebKit Commit Bot
Comment 15
2015-03-18 18:11:01 PDT
Comment on
attachment 248994
[details]
Patch for landing Clearing flags on attachment: 248994 Committed
r181717
: <
http://trac.webkit.org/changeset/181717
>
WebKit Commit Bot
Comment 16
2015-03-18 18:11:05 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug