Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Mark ValueTask unit tests with ActiveIssue attribute and make asserti…
…ons as if the feature is implemented.
  • Loading branch information
maraf committed Nov 10, 2021
commit 5f30ce333b28586cbfc3e92e1a11c97c32103fad
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,32 @@ public static async ValueTask AsynchronousValueTask()
await Task.Yield();
}

public static ValueTask SynchronousValueTask()
{
return ValueTask.CompletedTask;
}

public static ValueTask<int> SynchronousValueTaskInt(int i)
{
return ValueTask.FromResult(i);
}

public static async ValueTask<int> AsynchronousValueTaskInt(int i)
{
await Task.Yield();
return i;
}

public static ValueTask FailedSynchronousValueTask()
{
return ValueTask.FromException(new Exception());
}

public static async ValueTask FailedAsynchronousValueTask()
{
await Task.Yield();
throw new Exception();
}
}

public enum TestEnum : uint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,16 @@ private static async Task<bool> MarshalTask(string helperMethodName, string help
return resolved;
}

private static async Task MarshalTaskReturningInt(string helperMethodName)
{
HelperMarshal._intValue = 0;

bool success = await MarshalTask(helperMethodName, "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");

Assert.True(success, $"{helperMethodName} didn't succeeded.");
Assert.Equal(7, HelperMarshal._intValue);
}

[Fact]
public static async Task MarshalSynchronousTask()
{
Expand All @@ -938,57 +948,75 @@ public static async Task MarshalAsynchronousTask()
}

[Fact]
public static async Task MarshalSynchronousTaskInt()
public static Task MarshalSynchronousTaskInt()
{
HelperMarshal._intValue = 0;

bool success = await MarshalTask("SynchronousTaskInt", "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");

Assert.True(success, "SynchronousTask didn't succeeded.");
Assert.Equal(7, HelperMarshal._intValue);
return MarshalTaskReturningInt("SynchronousTaskInt");
}

[Fact]
public static async Task MarshalAsynchronousTaskInt()
public static Task MarshalAsynchronousTaskInt()
{
HelperMarshal._intValue = 0;

bool success = await MarshalTask("AsynchronousTaskInt", "7", "App.call_test_method ('InvokeInt', [ result ], 'i');");

Assert.True(success, "AsynchronousTask didn't succeeded.");
Assert.Equal(7, HelperMarshal._intValue);
return MarshalTaskReturningInt("AsynchronousTaskInt");
}

[Fact]
public static async Task MarshalFailedSynchronousTask()
{
bool success = await MarshalTask("FailedSynchronousTask");

Assert.False(success, "FailedSynchronousTask didn't failed.");
}

[Fact]
public static async Task MarshalFailedAsynchronousTask()
{
bool success = await MarshalTask("FailedAsynchronousTask");

Assert.False(success, "FailedAsynchronousTask didn't failed.");
}

[Fact]
[Trait("Category","Marek")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
public static async Task MarshalSynchronousValueTaskDoesNotWorkYet()
{
bool success = await MarshalTask("SynchronousValueTask");
Assert.True(success, "SynchronousValueTask didn't succeeded.");
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
public static async Task MarshalAsynchronousValueTaskDoesNotWorkYet()
{
var exception = await Assert.ThrowsAsync<JSException>(() => MarshalTask("AsynchronousValueTask"));
Assert.StartsWith("Error: no idea on how to unbox value types", exception.Message);
bool success = await MarshalTask("AsynchronousValueTask");
Assert.True(success, "AsynchronousValueTask didn't succeeded.");
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
public static Task MarshalSynchronousValueTaskIntDoesNotWorkYet()
{
return MarshalTaskReturningInt("SynchronousValueTaskInt");
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
public static Task MarshalAsynchronousValueTaskIntDoesNotWorkYet()
{
return MarshalTaskReturningInt("AsynchronousValueTaskInt");
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/61368")]
public static async Task MarshalFailedSynchronousValueTaskDoesNotWorkYet()
{
bool success = await MarshalTask("FailedSynchronousValueTask");
Assert.False(success, "FailedSynchronousValueTask didn't failed.");
}

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