public async Task TaskExtensions_ValueTaskOfTEnsureCompleted_NotCompletedNoSyncContext()
        {
            var             tcs  = new TaskCompletionSource <int>();
            ValueTask <int> task = new ValueTask <int>(tcs.Task);

#if DEBUG
            Assert.Catch <InvalidOperationException>(() => task.EnsureCompleted());
            await Task.CompletedTask;
#else
            Task <int> runningTask = Task.Run(() => task.EnsureCompleted());
            Assert.IsFalse(runningTask.IsCompleted);
            tcs.SetResult(42);
            Assert.AreEqual(42, await runningTask);
#endif
        }
        public void TaskExtensions_ValueTaskOfTEnsureCompleted_NotCompletedInSyncContext()
        {
            using SingleThreadedSynchronizationContext syncContext = new SingleThreadedSynchronizationContext();
            var tcs  = new TaskCompletionSource <int>();
            var task = new ValueTask <int>(tcs.Task);

            syncContext.Post(t => { Assert.Catch <InvalidOperationException>(() => task.EnsureCompleted()); }, null);
        }
        public void TaskExtensions_ValueTaskOfTEnsureCompleted()
        {
            var task = new ValueTask <int>(42);

            Assert.AreEqual(42, task.EnsureCompleted());
        }
        public void TaskExtensions_ValueTaskEnsureCompleted()
        {
            var task = new ValueTask();

            task.EnsureCompleted();
        }