Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add tests for custom JavaScriptEncoder to cover the virtual code paths in TextEncoder, and address previous feedback.#42064

Merged
ahsonkhan merged 5 commits intodotnet:masterfrom
ahsonkhan:AddTextEncoderTests
Oct 30, 2019
Merged

Add tests for custom JavaScriptEncoder to cover the virtual code paths in TextEncoder, and address previous feedback.#42064
ahsonkhan merged 5 commits intodotnet:masterfrom
ahsonkhan:AddTextEncoderTests

Conversation

@ahsonkhan
Copy link

Adding some of the new tests from #42030 into master and fix some nits.

cc @GrabYourPitchforks, @tarekgh

@ahsonkhan ahsonkhan added this to the 5.0 milestone Oct 23, 2019
@ahsonkhan ahsonkhan changed the title Add tests for custom JavaScriptEncoder to cover the virtual code paths in TextEncoder Add tests for custom JavaScriptEncoder to cover the virtual code paths in TextEncoder, and address previous feedback. Oct 25, 2019

private static readonly Vector128<short> s_mask_UInt16_0x00 = Vector128<short>.Zero; // Null

private static readonly Vector128<short> s_mask_UInt16_0x20 = Vector128.Create((short)0x20); // Space ' '
Copy link
Author

@ahsonkhan ahsonkhan Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming these to address some of the leftover feedback from #41845 (comment)

cc @tannergooding

Copy link
Author

@ahsonkhan ahsonkhan Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up @gfoidl - since this will likely conflict with your changes being built-on-top (specifically #42073).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint -- I'll incorporate this, so no conflict will occur.

private static readonly Vector128<sbyte> s_mask_SByte_0x3E = Vector128.Create((sbyte)0x3E); // Greater Than Sign '>'
private static readonly Vector128<sbyte> s_mask_SByte_0x5C = Vector128.Create((sbyte)0x5C); // Reverse Solidus '\'
private static readonly Vector128<sbyte> s_mask_SByte_0x60 = Vector128.Create((sbyte)0x60); // Grave Access '`'
private static readonly Vector128<short> s_nullMaskInt16 = Vector128<short>.Zero;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe s_zeroMaskInt16?

Copy link
Author

@ahsonkhan ahsonkhan Oct 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in the context of characters, I have been using character names. In this case, that's null (not zero, which just happens to be the value):
https://www.fileformat.info/info/unicode/char/0000/index.htm

I can see why using zero could be useful (similar to using s_maxAsciiCharacterMaskInt16 rather than delete for 0x7F), but not sure if it's worth changing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null reminds me of null 😉
The vector consists of 0s, so zero. It's usage is in CompareLessThan so it's more a comparison against a value, rather than null.

But this is more or less a quibble, and so it's up to you whether it's changed or not.

@ahsonkhan ahsonkhan merged commit 62e6ccf into dotnet:master Oct 30, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…s in TextEncoder, and address previous feedback. (dotnet/corefx#42064)

* Move using directive within ifdef to make it clear when its used.

* Add more tests for custom text encoder case.

* Fix typo in comment gaurd -> guard

* Fix up the using directives that got removed during merge conflict
resolution.

* Address feedback - fix 0x7F case, rename vectors to be self-documenting.


Commit migrated from dotnet/corefx@62e6ccf
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants