Skip to content

Commit

Permalink
Rename parseable → parsable
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Nov 29, 2023
1 parent 6b75c1c commit 7ad9eb3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions FrameworkFeatureConstants.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<DefineConstants>$(DefineConstants);STACK_TRACE_HIDDEN_SUPPORTED;DATE_ONLY_SUPPORTED;TIME_ONLY_SUPPORTED;PRIORITY_QUEUE;TRY_GET_NON_ENUMERATED_COUNT;HTTP_HEADERS_NON_VALIDATED;ELEMENT_AT_INDEX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
<DefineConstants>$(DefineConstants);GENERIC_MATH;GENERIC_PARSEABLE</DefineConstants>
<DefineConstants>$(DefineConstants);GENERIC_MATH;GENERIC_PARSABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<DefineConstants>$(DefineConstants);RANDOM_SHUFFLE;UTF8_SPAN_PARSEABLE</DefineConstants>
<DefineConstants>$(DefineConstants);RANDOM_SHUFFLE;UTF8_SPAN_PARSABLE</DefineConstants>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#if GENERIC_PARSEABLE
#if GENERIC_PARSABLE
using System.Globalization;

namespace Funcky.Test.Extensions.ParseExtensions;

public sealed partial class ParseExtensionsTest
{
[Theory]
[MemberData(nameof(ParseableDoubleNumbers))]
[MemberData(nameof(ParsableDoubleNumbers))]
public void ParseGenericStringReturnsTheExpectedDouble(Option<double> expected, string input)
{
Assert.Equal(expected, input.ParseNumberOrNone<double>(NumberStyles.Number, null));
Assert.Equal(expected, input.ParseOrNone<double>(null));
}

[Theory]
[MemberData(nameof(ParseableDoubleNumbers))]
[MemberData(nameof(ParsableDoubleNumbers))]
public void ParseGenericSpanReturnsTheExpectedDouble(Option<double> expected, string input)
{
Assert.Equal(expected, input.AsSpan().ParseNumberOrNone<double>(NumberStyles.Number, null));
Assert.Equal(expected, input.AsSpan().ParseOrNone<double>(null));
}

public static TheoryData<Option<double>, string> ParseableDoubleNumbers()
public static TheoryData<Option<double>, string> ParsableDoubleNumbers()
=> new()
{
{ Option.Some(1.0), "1.0" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ namespace Funcky.Extensions;

public static partial class ParseExtensions
{
#if GENERIC_PARSEABLE
public static Option<TParseable> ParseOrNone<TParseable>(this ReadOnlySpan<char> value, IFormatProvider? provider)
where TParseable : ISpanParsable<TParseable>
=> TParseable.TryParse(value, provider, out var result)
#if GENERIC_PARSABLE
public static Option<TParsable> ParseOrNone<TParsable>(this ReadOnlySpan<char> value, IFormatProvider? provider)
where TParsable : ISpanParsable<TParsable>
=> TParsable.TryParse(value, provider, out var result)
? result
: Option<TParseable>.None;
: Option<TParsable>.None;

public static Option<TParseable> ParseOrNone<TParseable>(this string? value, IFormatProvider? provider)
where TParseable : IParsable<TParseable>
=> TParseable.TryParse(value, provider, out var result)
public static Option<TParsable> ParseOrNone<TParsable>(this string? value, IFormatProvider? provider)
where TParsable : IParsable<TParsable>
=> TParsable.TryParse(value, provider, out var result)
? result
: Option<TParseable>.None;
: Option<TParsable>.None;
#endif

#if UTF8_SPAN_PARSEABLE
public static Option<TParseable> ParseOrNone<TParseable>(this ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
where TParseable : IUtf8SpanParsable<TParseable>
=> TParseable.TryParse(utf8Text, provider, out var result)
#if UTF8_SPAN_PARSABLE
public static Option<TParsable> ParseOrNone<TParsable>(this ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
where TParsable : IUtf8SpanParsable<TParsable>
=> TParsable.TryParse(utf8Text, provider, out var result)
? result
: Option<TParseable>.None;
: Option<TParsable>.None;
#endif
}
6 changes: 3 additions & 3 deletions Funcky/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ static Funcky.Extensions.ParseExtensions.ParseInt64OrNone(this System.ReadOnlySp
static Funcky.Extensions.ParseExtensions.ParseInt64OrNone(this System.ReadOnlySpan<byte> candidate) -> Funcky.Monads.Option<long>
static Funcky.Extensions.ParseExtensions.ParseNumberOrNone<TNumber>(this string! value, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option<TNumber>
static Funcky.Extensions.ParseExtensions.ParseNumberOrNone<TNumber>(this System.ReadOnlySpan<char> value, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option<TNumber>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParseable>(this string? value, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParseable>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParseable>(this System.ReadOnlySpan<char> value, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParseable>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParseable>(this System.ReadOnlySpan<byte> utf8Text, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParseable>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParsable>(this string? value, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParsable>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParsable>(this System.ReadOnlySpan<char> value, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParsable>
static Funcky.Extensions.ParseExtensions.ParseOrNone<TParsable>(this System.ReadOnlySpan<byte> utf8Text, System.IFormatProvider? provider) -> Funcky.Monads.Option<TParsable>
static Funcky.Extensions.ParseExtensions.ParseSByteOrNone(this System.ReadOnlySpan<byte> candidate, System.Globalization.NumberStyles style, System.IFormatProvider? provider) -> Funcky.Monads.Option<sbyte>
static Funcky.Extensions.ParseExtensions.ParseSByteOrNone(this System.ReadOnlySpan<byte> candidate, System.IFormatProvider? provider) -> Funcky.Monads.Option<sbyte>
static Funcky.Extensions.ParseExtensions.ParseSByteOrNone(this System.ReadOnlySpan<byte> candidate) -> Funcky.Monads.Option<sbyte>
Expand Down

0 comments on commit 7ad9eb3

Please sign in to comment.