Skip to content

Commit 5f30ce3

Browse files
committed
Mark ValueTask unit tests with ActiveIssue attribute and make assertions as if the feature is implemented.
1 parent e00e249 commit 5f30ce3

File tree

2 files changed

+72
-23
lines changed

2 files changed

+72
-23
lines changed

src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/HelperMarshal.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,32 @@ public static async ValueTask AsynchronousValueTask()
679679
await Task.Yield();
680680
}
681681

682+
public static ValueTask SynchronousValueTask()
683+
{
684+
return ValueTask.CompletedTask;
685+
}
686+
687+
public static ValueTask<int> SynchronousValueTaskInt(int i)
688+
{
689+
return ValueTask.FromResult(i);
690+
}
691+
682692
public static async ValueTask<int> AsynchronousValueTaskInt(int i)
683693
{
684694
await Task.Yield();
685695
return i;
686696
}
697+
698+
public static ValueTask FailedSynchronousValueTask()
699+
{
700+
return ValueTask.FromException(new Exception());
701+
}
702+
703+
public static async ValueTask FailedAsynchronousValueTask()
704+
{
705+
await Task.Yield();
706+
throw new Exception();
707+
}
687708
}
688709

689710
public enum TestEnum : uint {

src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/MarshalTests.cs

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,16 @@ private static async Task<bool> MarshalTask(string helperMethodName, string help
923923
return resolved;
924924
}
925925

926+
private static async Task MarshalTaskReturningInt(string helperMethodName)
927+
{
928+
HelperMarshal._intValue = 0;
929+
930+
bool success = await MarshalTask(helperMethodName, "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");
931+
932+
Assert.True(success, $"{helperMethodName} didn't succeeded.");
933+
Assert.Equal(7, HelperMarshal._intValue);
934+
}
935+
926936
[Fact]
927937
public static async Task MarshalSynchronousTask()
928938
{
@@ -938,57 +948,75 @@ public static async Task MarshalAsynchronousTask()
938948
}
939949

940950
[Fact]
941-
public static async Task MarshalSynchronousTaskInt()
951+
public static Task MarshalSynchronousTaskInt()
942952
{
943-
HelperMarshal._intValue = 0;
944-
945-
bool success = await MarshalTask("SynchronousTaskInt", "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");
946-
947-
Assert.True(success, "SynchronousTask didn't succeeded.");
948-
Assert.Equal(7, HelperMarshal._intValue);
953+
return MarshalTaskReturningInt("SynchronousTaskInt");
949954
}
950955

951956
[Fact]
952-
public static async Task MarshalAsynchronousTaskInt()
957+
public static Task MarshalAsynchronousTaskInt()
953958
{
954-
HelperMarshal._intValue = 0;
955-
956-
bool success = await MarshalTask("AsynchronousTaskInt", "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");
957-
958-
Assert.True(success, "AsynchronousTask didn't succeeded.");
959-
Assert.Equal(7, HelperMarshal._intValue);
959+
return MarshalTaskReturningInt("AsynchronousTaskInt");
960960
}
961961

962962
[Fact]
963963
public static async Task MarshalFailedSynchronousTask()
964964
{
965965
bool success = await MarshalTask("FailedSynchronousTask");
966-
967966
Assert.False(success, "FailedSynchronousTask didn't failed.");
968967
}
969968

970969
[Fact]
971970
public static async Task MarshalFailedAsynchronousTask()
972971
{
973972
bool success = await MarshalTask("FailedAsynchronousTask");
974-
975973
Assert.False(success, "FailedAsynchronousTask didn't failed.");
976974
}
977975

978976
[Fact]
979-
[Trait("Category","Marek")]
977+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
978+
public static async Task MarshalSynchronousValueTaskDoesNotWorkYet()
979+
{
980+
bool success = await MarshalTask("SynchronousValueTask");
981+
Assert.True(success, "SynchronousValueTask didn't succeeded.");
982+
}
983+
984+
[Fact]
985+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
980986
public static async Task MarshalAsynchronousValueTaskDoesNotWorkYet()
981987
{
982-
var exception = await Assert.ThrowsAsync<JSException>(() => MarshalTask("AsynchronousValueTask"));
983-
Assert.StartsWith("Error: no idea on how to unbox value types", exception.Message);
988+
bool success = await MarshalTask("AsynchronousValueTask");
989+
Assert.True(success, "AsynchronousValueTask didn't succeeded.");
990+
}
991+
992+
[Fact]
993+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
994+
public static Task MarshalSynchronousValueTaskIntDoesNotWorkYet()
995+
{
996+
return MarshalTaskReturningInt("SynchronousValueTaskInt");
997+
}
998+
999+
[Fact]
1000+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
1001+
public static Task MarshalAsynchronousValueTaskIntDoesNotWorkYet()
1002+
{
1003+
return MarshalTaskReturningInt("AsynchronousValueTaskInt");
1004+
}
1005+
1006+
[Fact]
1007+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
1008+
public static async Task MarshalFailedSynchronousValueTaskDoesNotWorkYet()
1009+
{
1010+
bool success = await MarshalTask("FailedSynchronousValueTask");
1011+
Assert.False(success, "FailedSynchronousValueTask didn't failed.");
9841012
}
9851013

9861014
[Fact]
987-
[Trait("Category","Marek")]
988-
public static async Task MarshalAsynchronousValueTaskIntDoesNotWorkYet()
1015+
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
1016+
public static async Task MarshalFailedAsynchronousValueTaskDoesNotWorkYet()
9891017
{
990-
var exception = await Assert.ThrowsAsync<JSException>(() => MarshalTask("AsynchronousValueTaskInt", "7"));
991-
Assert.StartsWith("Error: no idea on how to unbox value types", exception.Message);
1018+
bool success = await MarshalTask("FailedAsynchronousValueTask");
1019+
Assert.False(success, "FailedAsynchronousValueTask didn't failed.");
9921020
}
9931021
}
9941022
}

0 commit comments

Comments
 (0)