diff options
author | Ganbarukamo41 <ganbarukamo@gmail.com> | 2019-06-25 04:44:50 +0900 |
---|---|---|
committer | Tanner Gooding <tagoo@outlook.com> | 2019-06-24 12:44:50 -0700 |
commit | d505b49a285f6cd7776230fb7f0d73d3ac20b73a (patch) | |
tree | ad83bc15ba5466956adec7c44864a238ca1709ba | |
parent | 0e32c3041e4b372565c700b7948da645f496c5c1 (diff) | |
download | coreclr-d505b49a285f6cd7776230fb7f0d73d3ac20b73a.tar.gz coreclr-d505b49a285f6cd7776230fb7f0d73d3ac20b73a.tar.bz2 coreclr-d505b49a285f6cd7776230fb7f0d73d3ac20b73a.zip |
Make Vector*.ToString() Culture invariant (#25343)
* Remove IFormattable
* Hardcode characters
* Add tests
50 files changed, 1838 insertions, 84 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs index 9f609eabe4..4fda50c045 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs @@ -27,7 +27,7 @@ namespace System.Runtime.Intrinsics [DebuggerDisplay("{DisplayString,nq}")] [DebuggerTypeProxy(typeof(Vector128DebugView<>))] [StructLayout(LayoutKind.Sequential, Size = Vector128.Size)] - public readonly struct Vector128<T> : IEquatable<Vector128<T>>, IFormattable + public readonly struct Vector128<T> : IEquatable<Vector128<T>> where T : struct { // These fields exist to ensure the alignment is 8, rather than 1. @@ -173,42 +173,22 @@ namespace System.Runtime.Intrinsics /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> public override string ToString() { - return ToString("G"); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format) - { - return ToString(format, formatProvider: null); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <param name="formatProvider">The format provider used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format, IFormatProvider? formatProvider) - { ThrowHelper.ThrowForUnsupportedVectorBaseType<T>(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; int lastElement = Count - 1; + StringBuilder sb = StringBuilderCache.Acquire(); + CultureInfo invariant = CultureInfo.InvariantCulture; - var sb = StringBuilderCache.Acquire(); sb.Append('<'); - for (int i = 0; i < lastElement; i++) { - sb.Append(((IFormattable)(this.GetElement(i))).ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); + sb.Append(((IFormattable)this.GetElement(i)).ToString("G", invariant)) + .Append(',') + .Append(' '); } - sb.Append(((IFormattable)(this.GetElement(lastElement))).ToString(format, formatProvider)); + sb.Append(((IFormattable)this.GetElement(lastElement)).ToString("G", invariant)) + .Append('>'); - sb.Append('>'); return StringBuilderCache.GetStringAndRelease(sb); } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs index 0a9b99347b..59f8102908 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs @@ -27,7 +27,7 @@ namespace System.Runtime.Intrinsics [DebuggerDisplay("{DisplayString,nq}")] [DebuggerTypeProxy(typeof(Vector256DebugView<>))] [StructLayout(LayoutKind.Sequential, Size = Vector256.Size)] - public readonly struct Vector256<T> : IEquatable<Vector256<T>>, IFormattable + public readonly struct Vector256<T> : IEquatable<Vector256<T>> where T : struct { // These fields exist to ensure the alignment is 8, rather than 1. @@ -174,42 +174,22 @@ namespace System.Runtime.Intrinsics /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> public override string ToString() { - return ToString("G"); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format) - { - return ToString(format, formatProvider: null); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <param name="formatProvider">The format provider used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format, IFormatProvider? formatProvider) - { ThrowHelper.ThrowForUnsupportedVectorBaseType<T>(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; int lastElement = Count - 1; + StringBuilder sb = StringBuilderCache.Acquire(); + CultureInfo invariant = CultureInfo.InvariantCulture; - var sb = StringBuilderCache.Acquire(); sb.Append('<'); - for (int i = 0; i < lastElement; i++) { - sb.Append(((IFormattable)(this.GetElement(i))).ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); + sb.Append(((IFormattable)this.GetElement(i)).ToString("G", invariant)) + .Append(',') + .Append(' '); } - sb.Append(((IFormattable)(this.GetElement(lastElement))).ToString(format, formatProvider)); + sb.Append(((IFormattable)this.GetElement(lastElement)).ToString("G", invariant)) + .Append('>'); - sb.Append('>'); return StringBuilderCache.GetStringAndRelease(sb); } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64_1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64_1.cs index 7b8f75ad66..af66c55667 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64_1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64_1.cs @@ -15,7 +15,7 @@ namespace System.Runtime.Intrinsics [DebuggerDisplay("{DisplayString,nq}")] [DebuggerTypeProxy(typeof(Vector64DebugView<>))] [StructLayout(LayoutKind.Sequential, Size = Vector64.Size)] - public readonly struct Vector64<T> : IEquatable<Vector64<T>>, IFormattable + public readonly struct Vector64<T> : IEquatable<Vector64<T>> where T : struct { // These fields exist to ensure the alignment is 8, rather than 1. @@ -127,42 +127,22 @@ namespace System.Runtime.Intrinsics /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> public override string ToString() { - return ToString("G"); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format) - { - return ToString(format, formatProvider: null); - } - - /// <summary>Converts the current instance to an equivalent string representation using the specified format.</summary> - /// <param name="format">The format specifier used to format the individual elements of the current instance.</param> - /// <param name="formatProvider">The format provider used to format the individual elements of the current instance.</param> - /// <returns>An equivalent string representation of the current instance.</returns> - /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> - public string ToString(string? format, IFormatProvider? formatProvider) - { ThrowHelper.ThrowForUnsupportedVectorBaseType<T>(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; int lastElement = Count - 1; + StringBuilder sb = StringBuilderCache.Acquire(); + CultureInfo invariant = CultureInfo.InvariantCulture; - var sb = StringBuilderCache.Acquire(); sb.Append('<'); - for (int i = 0; i < lastElement; i++) { - sb.Append(((IFormattable)(this.GetElement(i))).ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); + sb.Append(((IFormattable)this.GetElement(i)).ToString("G", invariant)) + .Append(',') + .Append(' '); } - sb.Append(((IFormattable)(this.GetElement(lastElement))).ToString(format, formatProvider)); + sb.Append(((IFormattable)this.GetElement(lastElement)).ToString("G", invariant)) + .Append('>'); - sb.Append('>'); return StringBuilderCache.GetStringAndRelease(sb); } } diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_r.csproj b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_r.csproj index ac76cd8853..37b92fe4b9 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_r.csproj @@ -66,6 +66,7 @@ <Compile Include="Vector64WithElement0.cs" /> <Compile Include="Vector64WithElementMaxValue.cs" /> <Compile Include="Vector64ToScalar.cs" /> + <Compile Include="Vector64ToString.cs" /> <Compile Include="Vector64ToVector128.cs" /> <Compile Include="Vector64ToVector128Unsafe.cs" /> <Compile Include="Vector128Zero.cs" /> @@ -111,6 +112,7 @@ <Compile Include="Vector128GetUpper.cs" /> <Compile Include="Vector128WithUpper.cs" /> <Compile Include="Vector128ToScalar.cs" /> + <Compile Include="Vector128ToString.cs" /> <Compile Include="Vector128ToVector256.cs" /> <Compile Include="Vector128ToVector256Unsafe.cs" /> <Compile Include="Vector256Zero.cs" /> @@ -156,6 +158,7 @@ <Compile Include="Vector256GetUpper.cs" /> <Compile Include="Vector256WithUpper.cs" /> <Compile Include="Vector256ToScalar.cs" /> + <Compile Include="Vector256ToString.cs" /> <Compile Include="Program.NotSupported.cs" /> <Compile Include="..\Shared\Program.cs" /> </ItemGroup> diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_ro.csproj b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_ro.csproj index 513293640e..81dbe9ca88 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/NotSupported_ro.csproj @@ -66,6 +66,7 @@ <Compile Include="Vector64WithElement0.cs" /> <Compile Include="Vector64WithElementMaxValue.cs" /> <Compile Include="Vector64ToScalar.cs" /> + <Compile Include="Vector64ToString.cs" /> <Compile Include="Vector64ToVector128.cs" /> <Compile Include="Vector64ToVector128Unsafe.cs" /> <Compile Include="Vector128Zero.cs" /> @@ -111,6 +112,7 @@ <Compile Include="Vector128GetUpper.cs" /> <Compile Include="Vector128WithUpper.cs" /> <Compile Include="Vector128ToScalar.cs" /> + <Compile Include="Vector128ToString.cs" /> <Compile Include="Vector128ToVector256.cs" /> <Compile Include="Vector128ToVector256Unsafe.cs" /> <Compile Include="Vector256Zero.cs" /> @@ -156,6 +158,7 @@ <Compile Include="Vector256GetUpper.cs" /> <Compile Include="Vector256WithUpper.cs" /> <Compile Include="Vector256ToScalar.cs" /> + <Compile Include="Vector256ToString.cs" /> <Compile Include="Program.NotSupported.cs" /> <Compile Include="..\Shared\Program.cs" /> </ItemGroup> diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Program.NotSupported.cs b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Program.NotSupported.cs index 6c3a923e04..8c6ac23047 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Program.NotSupported.cs +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Program.NotSupported.cs @@ -53,6 +53,7 @@ namespace JIT.HardwareIntrinsics.General ["Vector64ToScalar"] = Vector64ToScalar, ["Vector64ToVector128"] = Vector64ToVector128, ["Vector64ToVector128Unsafe"] = Vector64ToVector128Unsafe, + ["Vector64ToString"] = Vector64ToString, ["Vector128Zero"] = Vector128Zero, ["Vector128BooleanAsGeneric_Boolean"] = Vector128BooleanAsGeneric_Boolean, ["Vector128ByteAsGeneric_Boolean"] = Vector128ByteAsGeneric_Boolean, @@ -98,6 +99,7 @@ namespace JIT.HardwareIntrinsics.General ["Vector128ToScalar"] = Vector128ToScalar, ["Vector128ToVector256"] = Vector128ToVector256, ["Vector128ToVector256Unsafe"] = Vector128ToVector256Unsafe, + ["Vector128ToString"] = Vector128ToString, ["Vector256Zero"] = Vector256Zero, ["Vector256BooleanAsGeneric_Boolean"] = Vector256BooleanAsGeneric_Boolean, ["Vector256ByteAsGeneric_Boolean"] = Vector256ByteAsGeneric_Boolean, @@ -141,6 +143,7 @@ namespace JIT.HardwareIntrinsics.General ["Vector256GetUpper"] = Vector256GetUpper, ["Vector256WithUpper"] = Vector256WithUpper, ["Vector256ToScalar"] = Vector256ToScalar, + ["Vector256ToString"] = Vector256ToString, }; } } diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector128ToString.cs b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector128ToString.cs new file mode 100644 index 0000000000..8cbafad1a3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector128ToString.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private static void Vector128ToString() + { + bool succeeded = false; + + try + { + string result = default(Vector128<bool>).ToString(); + } + catch (NotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128ToString: RunNotSupportedScenario failed to throw NotSupportedException."); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector256ToString.cs b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector256ToString.cs new file mode 100644 index 0000000000..83a8d26111 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector256ToString.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private static void Vector256ToString() + { + bool succeeded = false; + + try + { + string result = default(Vector256<bool>).ToString(); + } + catch (NotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256ToString: RunNotSupportedScenario failed to throw NotSupportedException."); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector64ToString.cs b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector64ToString.cs new file mode 100644 index 0000000000..c96a1ffe20 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/NotSupported/Vector64ToString.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private static void Vector64ToString() + { + bool succeeded = false; + + try + { + string result = default(Vector64<bool>).ToString(); + } + catch (NotSupportedException) + { + succeeded = true; + } + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64ToString: RunNotSupportedScenario failed to throw NotSupportedException."); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/General/Shared/GenerateTests.csx index 71edaa98a2..28dca4fad5 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Shared/GenerateTests.csx +++ b/tests/src/JIT/HardwareIntrinsics/General/Shared/GenerateTests.csx @@ -118,6 +118,17 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "ToVector128", ["VectorType"] = "Vector64", ["BaseType"] = "UInt16", ["TgtVectorType"] = "Vector128", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "ToVector128", ["VectorType"] = "Vector64", ["BaseType"] = "UInt32", ["TgtVectorType"] = "Vector128", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1]" }), ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "ToVector128", ["VectorType"] = "Vector64", ["BaseType"] = "UInt64", ["TgtVectorType"] = "Vector128", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0]" }), + + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetSByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt32()", ["ConsumeValues"] = "values[0], values[1]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetSingle()", ["ConsumeValues"] = "values[0], values[1]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetDouble()", ["ConsumeValues"] = "values[0]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt64()", ["ConsumeValues"] = "values[0]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector64", ["Method"] = "ToString", ["VectorType"] = "Vector64", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0]" }), }; private static readonly (string templateFileName, Dictionary<string, string> templateData)[] Vector128Inputs = new [] @@ -260,6 +271,17 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector128", ["Method"] = "ToVector256", ["VectorType"] = "Vector128", ["BaseType"] = "UInt16", ["TgtVectorType"] = "Vector256", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector128", ["Method"] = "ToVector256", ["VectorType"] = "Vector128", ["BaseType"] = "UInt32", ["TgtVectorType"] = "Vector256", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), ("VectorExtendTest.template", new Dictionary<string, string> { ["Isa"] = "Vector128", ["Method"] = "ToVector256", ["VectorType"] = "Vector128", ["BaseType"] = "UInt64", ["TgtVectorType"] = "Vector256", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0], values[1]" }), + + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetSByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetSingle()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetDouble()", ["ConsumeValues"] = "values[0], values[1]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetInt64()", ["ConsumeValues"] = "values[0], values[1]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector128", ["Method"] = "ToString", ["VectorType"] = "Vector128", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0], values[1]" }), }; private static readonly (string templateFileName, Dictionary<string, string> templateData)[] Vector256Inputs = new [] @@ -401,6 +423,17 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorToScalarTest.template", new Dictionary<string, string> { ["Isa"] = "Vector256", ["Method"] = "ToScalar", ["VectorType"] = "Vector256", ["BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]" }), ("VectorToScalarTest.template", new Dictionary<string, string> { ["Isa"] = "Vector256", ["Method"] = "ToScalar", ["VectorType"] = "Vector256", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), ("VectorToScalarTest.template", new Dictionary<string, string> { ["Isa"] = "Vector256", ["Method"] = "ToScalar", ["VectorType"] = "Vector256", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15], values[16], values[17], values[18], values[19], values[20], values[21], values[22], values[23], values[24], values[25], values[26], values[27], values[28], values[29], values[30], values[31]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetSByte()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15], values[16], values[17], values[18], values[19], values[20], values[21], values[22], values[23], values[24], values[25], values[26], values[27], values[28], values[29], values[30], values[31]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetSingle()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetDouble()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetInt64()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), + ("VectorToStringTest.template", new Dictionary<string, string> {["Isa"] = "Vector256", ["Method"] = "ToString", ["VectorType"] = "Vector256", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ConsumeValues"] = "values[0], values[1], values[2], values[3]" }), }; private static readonly (string templateFileName, Dictionary<string, string> templateData)[] NotSupportedInputs = new [] @@ -446,6 +479,7 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector64ToScalar", ["TargetType"] = "bool", ["Source"] = "default(Vector64<bool>)", ["Method"] = "ToScalar()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector64ToVector128", ["TargetType"] = "Vector128<bool>", ["Source"] = "default(Vector64<bool>)", ["Method"] = "ToVector128()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector64ToVector128Unsafe", ["TargetType"] = "Vector128<bool>", ["Source"] = "default(Vector64<bool>)", ["Method"] = "ToVector128Unsafe()" }), + ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector64ToString", ["TargetType"] = "string", ["Source"] = "default(Vector64<bool>)", ["Method"] = "ToString()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128Zero", ["TargetType"] = "Vector128<bool>", ["Source"] = "Vector128<bool>", ["Method"] = "Zero" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128BooleanAsGeneric_Boolean", ["TargetType"] = "Vector128<bool>", ["Source"] = "default(Vector128<bool>)", ["Method"] = "As<bool, bool>()" }), @@ -492,6 +526,7 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128ToScalar", ["TargetType"] = "bool", ["Source"] = "default(Vector128<bool>)", ["Method"] = "ToScalar()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128ToVector256", ["TargetType"] = "Vector256<bool>", ["Source"] = "default(Vector128<bool>)", ["Method"] = "ToVector256()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128ToVector256Unsafe", ["TargetType"] = "Vector256<bool>", ["Source"] = "default(Vector128<bool>)", ["Method"] = "ToVector256Unsafe()" }), + ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector128ToString", ["TargetType"] = "string", ["Source"] = "default(Vector128<bool>)", ["Method"] = "ToString()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256Zero", ["TargetType"] = "Vector256<bool>", ["Source"] = "Vector256<bool>", ["Method"] = "Zero" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256BooleanAsGeneric_Boolean", ["TargetType"] = "Vector256<bool>", ["Source"] = "default(Vector256<bool>)", ["Method"] = "As<bool, bool>()" }), @@ -536,6 +571,7 @@ private static readonly (string templateFileName, Dictionary<string, string> tem ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256GetUpper", ["TargetType"] = "Vector128<bool>", ["Source"] = "default(Vector256<bool>)", ["Method"] = "GetUpper()" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256WithUpper", ["TargetType"] = "Vector256<bool>", ["Source"] = "default(Vector256<bool>)", ["Method"] = "WithUpper(default(Vector128<bool>))" }), ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256ToScalar", ["TargetType"] = "bool", ["Source"] = "default(Vector256<bool>)", ["Method"] = "ToScalar()" }), + ("VectorNotSupportedTest.template", new Dictionary<string, string> { ["Isa"] = "NotSupported", ["Name"] = "Vector256ToString", ["TargetType"] = "string", ["Source"] = "default(Vector256<bool>)", ["Method"] = "ToString()" }), }; private static void ProcessInputs(string groupName, (string templateFileName, Dictionary<string, string> templateData)[] inputs) diff --git a/tests/src/JIT/HardwareIntrinsics/General/Shared/VectorToStringTest.template b/tests/src/JIT/HardwareIntrinsics/General/Shared/VectorToStringTest.template new file mode 100644 index 0000000000..a54dc13aa6 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Shared/VectorToStringTest.template @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void {Method}{BaseType}() + { + int size = Unsafe.SizeOf<{VectorType}<{BaseType}>>() / sizeof({BaseType}); + {BaseType}[] values = new {BaseType}[size]; + + for (int i = 0; i < size; i++) + { + values[i] = {NextValueOp}; + } + + {VectorType}<{BaseType}> vector = {VectorType}.Create({ConsumeValues}); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"{Isa}{BaseType}{Method}: {VectorType}<{BaseType}>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Program.Vector128_1.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Program.Vector128_1.cs index 24fed272d4..370d6dcd84 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Program.Vector128_1.cs +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Program.Vector128_1.cs @@ -89,6 +89,16 @@ namespace JIT.HardwareIntrinsics.General ["ToVector256.UInt16"] = ToVector256UInt16, ["ToVector256.UInt32"] = ToVector256UInt32, ["ToVector256.UInt64"] = ToVector256UInt64, + ["ToString.Byte"] = ToStringByte, + ["ToString.SByte"] = ToStringSByte, + ["ToString.Int16"] = ToStringInt16, + ["ToString.UInt16"] = ToStringUInt16, + ["ToString.Int32"] = ToStringInt32, + ["ToString.UInt32"] = ToStringUInt32, + ["ToString.Single"] = ToStringSingle, + ["ToString.Double"] = ToStringDouble, + ["ToString.Int64"] = ToStringInt64, + ["ToString.UInt64"] = ToStringUInt64, }; } } diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Byte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Byte.cs new file mode 100644 index 0000000000..3e183666dd --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Byte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringByte() + { + int size = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); + Byte[] values = new Byte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetByte(); + } + + Vector128<Byte> vector = Vector128.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128ByteToString: Vector128<Byte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Double.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Double.cs new file mode 100644 index 0000000000..031ce53d54 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Double.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringDouble() + { + int size = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); + Double[] values = new Double[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetDouble(); + } + + Vector128<Double> vector = Vector128.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128DoubleToString: Vector128<Double>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int16.cs new file mode 100644 index 0000000000..ba99452ce1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt16() + { + int size = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); + Int16[] values = new Int16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt16(); + } + + Vector128<Int16> vector = Vector128.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128Int16ToString: Vector128<Int16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int32.cs new file mode 100644 index 0000000000..49dd98f9de --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt32() + { + int size = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); + Int32[] values = new Int32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt32(); + } + + Vector128<Int32> vector = Vector128.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128Int32ToString: Vector128<Int32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int64.cs new file mode 100644 index 0000000000..96efb0242f --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Int64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt64() + { + int size = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); + Int64[] values = new Int64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt64(); + } + + Vector128<Int64> vector = Vector128.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128Int64ToString: Vector128<Int64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.SByte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.SByte.cs new file mode 100644 index 0000000000..2894cd64d3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.SByte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSByte() + { + int size = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); + SByte[] values = new SByte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSByte(); + } + + Vector128<SByte> vector = Vector128.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128SByteToString: Vector128<SByte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Single.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Single.cs new file mode 100644 index 0000000000..98d98b9822 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.Single.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSingle() + { + int size = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); + Single[] values = new Single[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSingle(); + } + + Vector128<Single> vector = Vector128.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128SingleToString: Vector128<Single>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt16.cs new file mode 100644 index 0000000000..122f15ebf4 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt16() + { + int size = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); + UInt16[] values = new UInt16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt16(); + } + + Vector128<UInt16> vector = Vector128.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128UInt16ToString: Vector128<UInt16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt32.cs new file mode 100644 index 0000000000..5f8f9f6387 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt32() + { + int size = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); + UInt32[] values = new UInt32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt32(); + } + + Vector128<UInt32> vector = Vector128.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128UInt32ToString: Vector128<UInt32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt64.cs new file mode 100644 index 0000000000..192535630b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/ToString.UInt64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt64() + { + int size = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); + UInt64[] values = new UInt64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt64(); + } + + Vector128<UInt64> vector = Vector128.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector128UInt64ToString: Vector128<UInt64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_r.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_r.csproj index 7d92e92129..ee13514892 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_r.csproj @@ -85,6 +85,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="ToVector256.Byte.cs" /> <Compile Include="ToVector256.Double.cs" /> <Compile Include="ToVector256.Int16.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_ro.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_ro.csproj index 1e524979c6..fe13f4ec24 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector128_1/Vector128_1_ro.csproj @@ -84,6 +84,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="ToVector256.Byte.cs" /> <Compile Include="ToVector256.Double.cs" /> <Compile Include="ToVector256.Int16.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Program.Vector256_1.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Program.Vector256_1.cs index 10918b027d..5d28a4fdcd 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Program.Vector256_1.cs +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Program.Vector256_1.cs @@ -89,6 +89,16 @@ namespace JIT.HardwareIntrinsics.General ["ToScalar.UInt16"] = ToScalarUInt16, ["ToScalar.UInt32"] = ToScalarUInt32, ["ToScalar.UInt64"] = ToScalarUInt64, + ["ToString.Byte"] = ToStringByte, + ["ToString.SByte"] = ToStringSByte, + ["ToString.Int16"] = ToStringInt16, + ["ToString.UInt16"] = ToStringUInt16, + ["ToString.Int32"] = ToStringInt32, + ["ToString.UInt32"] = ToStringUInt32, + ["ToString.Single"] = ToStringSingle, + ["ToString.Double"] = ToStringDouble, + ["ToString.Int64"] = ToStringInt64, + ["ToString.UInt64"] = ToStringUInt64, }; } } diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Byte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Byte.cs new file mode 100644 index 0000000000..d586a37f94 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Byte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringByte() + { + int size = Unsafe.SizeOf<Vector256<Byte>>() / sizeof(Byte); + Byte[] values = new Byte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetByte(); + } + + Vector256<Byte> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15], values[16], values[17], values[18], values[19], values[20], values[21], values[22], values[23], values[24], values[25], values[26], values[27], values[28], values[29], values[30], values[31]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256ByteToString: Vector256<Byte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Double.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Double.cs new file mode 100644 index 0000000000..e348cc8f65 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Double.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringDouble() + { + int size = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); + Double[] values = new Double[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetDouble(); + } + + Vector256<Double> vector = Vector256.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256DoubleToString: Vector256<Double>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int16.cs new file mode 100644 index 0000000000..81cff5f6c1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt16() + { + int size = Unsafe.SizeOf<Vector256<Int16>>() / sizeof(Int16); + Int16[] values = new Int16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt16(); + } + + Vector256<Int16> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256Int16ToString: Vector256<Int16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int32.cs new file mode 100644 index 0000000000..44023d29a0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt32() + { + int size = Unsafe.SizeOf<Vector256<Int32>>() / sizeof(Int32); + Int32[] values = new Int32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt32(); + } + + Vector256<Int32> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256Int32ToString: Vector256<Int32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int64.cs new file mode 100644 index 0000000000..228da71364 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Int64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt64() + { + int size = Unsafe.SizeOf<Vector256<Int64>>() / sizeof(Int64); + Int64[] values = new Int64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt64(); + } + + Vector256<Int64> vector = Vector256.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256Int64ToString: Vector256<Int64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.SByte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.SByte.cs new file mode 100644 index 0000000000..5a1cdc25e3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.SByte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSByte() + { + int size = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); + SByte[] values = new SByte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSByte(); + } + + Vector256<SByte> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15], values[16], values[17], values[18], values[19], values[20], values[21], values[22], values[23], values[24], values[25], values[26], values[27], values[28], values[29], values[30], values[31]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256SByteToString: Vector256<SByte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Single.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Single.cs new file mode 100644 index 0000000000..cff279dfd1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.Single.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSingle() + { + int size = Unsafe.SizeOf<Vector256<Single>>() / sizeof(Single); + Single[] values = new Single[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSingle(); + } + + Vector256<Single> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256SingleToString: Vector256<Single>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt16.cs new file mode 100644 index 0000000000..629a26dac1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt16() + { + int size = Unsafe.SizeOf<Vector256<UInt16>>() / sizeof(UInt16); + UInt16[] values = new UInt16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt16(); + } + + Vector256<UInt16> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], values[12], values[13], values[14], values[15]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256UInt16ToString: Vector256<UInt16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt32.cs new file mode 100644 index 0000000000..5de793c28a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt32() + { + int size = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); + UInt32[] values = new UInt32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt32(); + } + + Vector256<UInt32> vector = Vector256.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256UInt32ToString: Vector256<UInt32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt64.cs new file mode 100644 index 0000000000..cb753105df --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/ToString.UInt64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt64() + { + int size = Unsafe.SizeOf<Vector256<UInt64>>() / sizeof(UInt64); + UInt64[] values = new UInt64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt64(); + } + + Vector256<UInt64> vector = Vector256.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector256UInt64ToString: Vector256<UInt64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_r.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_r.csproj index b559e4a367..1c2464cea1 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_r.csproj @@ -94,6 +94,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="Zero.Byte.cs" /> <Compile Include="Zero.Double.cs" /> <Compile Include="Zero.Int16.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_ro.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_ro.csproj index da7f86b54f..b0494d1964 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector256_1/Vector256_1_ro.csproj @@ -94,6 +94,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="Zero.Byte.cs" /> <Compile Include="Zero.Double.cs" /> <Compile Include="Zero.Int16.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Program.Vector64_1.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Program.Vector64_1.cs index fc58fc8308..3d51ad45a7 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Program.Vector64_1.cs +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Program.Vector64_1.cs @@ -69,6 +69,16 @@ namespace JIT.HardwareIntrinsics.General ["ToVector128.UInt16"] = ToVector128UInt16, ["ToVector128.UInt32"] = ToVector128UInt32, ["ToVector128.UInt64"] = ToVector128UInt64, + ["ToString.Byte"] = ToStringByte, + ["ToString.SByte"] = ToStringSByte, + ["ToString.Int16"] = ToStringInt16, + ["ToString.UInt16"] = ToStringUInt16, + ["ToString.Int32"] = ToStringInt32, + ["ToString.UInt32"] = ToStringUInt32, + ["ToString.Single"] = ToStringSingle, + ["ToString.Double"] = ToStringDouble, + ["ToString.Int64"] = ToStringInt64, + ["ToString.UInt64"] = ToStringUInt64, }; } } diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Byte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Byte.cs new file mode 100644 index 0000000000..c5c049ed54 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Byte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringByte() + { + int size = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); + Byte[] values = new Byte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetByte(); + } + + Vector64<Byte> vector = Vector64.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64ByteToString: Vector64<Byte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Double.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Double.cs new file mode 100644 index 0000000000..24cc68b32b --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Double.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringDouble() + { + int size = Unsafe.SizeOf<Vector64<Double>>() / sizeof(Double); + Double[] values = new Double[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetDouble(); + } + + Vector64<Double> vector = Vector64.Create(values[0]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64DoubleToString: Vector64<Double>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int16.cs new file mode 100644 index 0000000000..5d61e899ca --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt16() + { + int size = Unsafe.SizeOf<Vector64<Int16>>() / sizeof(Int16); + Int16[] values = new Int16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt16(); + } + + Vector64<Int16> vector = Vector64.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64Int16ToString: Vector64<Int16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int32.cs new file mode 100644 index 0000000000..4228ec15b6 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt32() + { + int size = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); + Int32[] values = new Int32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt32(); + } + + Vector64<Int32> vector = Vector64.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64Int32ToString: Vector64<Int32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int64.cs new file mode 100644 index 0000000000..382d9afdb0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Int64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringInt64() + { + int size = Unsafe.SizeOf<Vector64<Int64>>() / sizeof(Int64); + Int64[] values = new Int64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetInt64(); + } + + Vector64<Int64> vector = Vector64.Create(values[0]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64Int64ToString: Vector64<Int64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.SByte.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.SByte.cs new file mode 100644 index 0000000000..066fe079e2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.SByte.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSByte() + { + int size = Unsafe.SizeOf<Vector64<SByte>>() / sizeof(SByte); + SByte[] values = new SByte[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSByte(); + } + + Vector64<SByte> vector = Vector64.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64SByteToString: Vector64<SByte>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Single.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Single.cs new file mode 100644 index 0000000000..e7a907ad3d --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.Single.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringSingle() + { + int size = Unsafe.SizeOf<Vector64<Single>>() / sizeof(Single); + Single[] values = new Single[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetSingle(); + } + + Vector64<Single> vector = Vector64.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64SingleToString: Vector64<Single>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt16.cs new file mode 100644 index 0000000000..6c4b200c6d --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt16.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt16() + { + int size = Unsafe.SizeOf<Vector64<UInt16>>() / sizeof(UInt16); + UInt16[] values = new UInt16[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt16(); + } + + Vector64<UInt16> vector = Vector64.Create(values[0], values[1], values[2], values[3]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64UInt16ToString: Vector64<UInt16>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt32.cs new file mode 100644 index 0000000000..5d88d769b0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt32.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt32() + { + int size = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32); + UInt32[] values = new UInt32[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt32(); + } + + Vector64<UInt32> vector = Vector64.Create(values[0], values[1]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64UInt32ToString: Vector64<UInt32>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt64.cs new file mode 100644 index 0000000000..a010010d9a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/ToString.UInt64.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; + +namespace JIT.HardwareIntrinsics.General +{ + public static partial class Program + { + private unsafe static void ToStringUInt64() + { + int size = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); + UInt64[] values = new UInt64[size]; + + for (int i = 0; i < size; i++) + { + values[i] = TestLibrary.Generator.GetUInt64(); + } + + Vector64<UInt64> vector = Vector64.Create(values[0]); + string actual = vector.ToString(); + + string expected = '<' + string.Join(", ", values.Select(x => x.ToString("G", System.Globalization.CultureInfo.InvariantCulture))) + '>'; + + bool succeeded = string.Equals(expected, actual, StringComparison.Ordinal); + + if (!succeeded) + { + TestLibrary.TestFramework.LogInformation($"Vector64UInt64ToString: Vector64<UInt64>.ToString() returned an unexpected result."); + TestLibrary.TestFramework.LogInformation($"Expected: {expected}"); + TestLibrary.TestFramework.LogInformation($"Actual: {actual}"); + TestLibrary.TestFramework.LogInformation(string.Empty); + + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_r.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_r.csproj index ead2a80947..5e57e23159 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_r.csproj @@ -64,6 +64,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="ToVector128.Byte.cs" /> <Compile Include="ToVector128.Double.cs" /> <Compile Include="ToVector128.Int16.cs" /> diff --git a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_ro.csproj b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_ro.csproj index 2c1555ac3c..5ee926f492 100644 --- a/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/General/Vector64_1/Vector64_1_ro.csproj @@ -64,6 +64,16 @@ <Compile Include="ToScalar.UInt16.cs" /> <Compile Include="ToScalar.UInt32.cs" /> <Compile Include="ToScalar.UInt64.cs" /> + <Compile Include="ToString.Byte.cs" /> + <Compile Include="ToString.Double.cs" /> + <Compile Include="ToString.Int16.cs" /> + <Compile Include="ToString.Int32.cs" /> + <Compile Include="ToString.Int64.cs" /> + <Compile Include="ToString.SByte.cs" /> + <Compile Include="ToString.Single.cs" /> + <Compile Include="ToString.UInt16.cs" /> + <Compile Include="ToString.UInt32.cs" /> + <Compile Include="ToString.UInt64.cs" /> <Compile Include="ToVector128.Byte.cs" /> <Compile Include="ToVector128.Double.cs" /> <Compile Include="ToVector128.Int16.cs" /> |