error tests expansion
.NET Test / .NET tests (push) Failing after 2m5s

This commit is contained in:
2026-07-12 18:06:53 +04:00
parent 2dbfd781ec
commit e8ae93799e
23 changed files with 1190 additions and 156 deletions
+4 -4
View File
@@ -64,7 +64,7 @@ public readonly partial struct Result : IEquatable<Result>
public static implicit operator Result(Error error) => new(error ?? throw new ArgumentNullException(nameof(error)));
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Result(Exception exception) => new(
new ExceptionalError(exception ?? throw new ArgumentNullException(nameof(exception))));
Error.New(exception ?? throw new ArgumentNullException(nameof(exception))));
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Result<SuccessUnit>(Result result) => result.State switch
{
@@ -75,8 +75,8 @@ public readonly partial struct Result : IEquatable<Result>
[Pure, MethodImpl(MethodImplOptions.AggressiveInlining)]
public static explicit operator Result(SuccessUnit _) => new(null);
[Pure] public bool IsSuccess => Error is null;
[Pure] public bool IsFailure => Error is not null;
[Pure] public bool IsSuccess => State == ResultState.Success;
[Pure] public bool IsFailure => State == ResultState.Error;
[Pure] public bool TryGetValue([MaybeNullWhen(false)]out SuccessUnit? u, [MaybeNullWhen(true), NotNullWhen(false)]out Error? error)
{
@@ -236,7 +236,7 @@ public readonly struct Result<T> : IEquatable<Result<T>>
if (typeof(R).IsAssignableFrom(typeof(T)) && Value is null)
return default(R)!;
return (R)(object)Value!;
return (R)(object)Value!; // throws InvalidCastException by design. should not use cast on incompatible types
}
default: throw new ResultNotInitializedException();