Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip §2.13 for value types #34

Merged
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
Original file line number Diff line number Diff line change
@@ -5,21 +5,21 @@
namespace Reactive.Streams.Example.Unicast.Tests
{
[TestFixture]
public class SyncSubscriberWhiteboxTest : SubscriberWhiteboxVerification<int?>
public class SyncSubscriberWhiteboxTest : SubscriberWhiteboxVerification<int>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd copy this test and keep both.

{
public SyncSubscriberWhiteboxTest() : base(new TestEnvironment())
{
}

public override int? CreateElement(int element) => element;
public override int CreateElement(int element) => element;

public override ISubscriber<int?> CreateSubscriber(WhiteboxSubscriberProbe<int?> probe) => new Subscriber(probe);
public override ISubscriber<int> CreateSubscriber(WhiteboxSubscriberProbe<int> probe) => new Subscriber(probe);

private sealed class Subscriber : SyncSubscriber<int?>
private sealed class Subscriber : SyncSubscriber<int>
{
private readonly WhiteboxSubscriberProbe<int?> _probe;
private readonly WhiteboxSubscriberProbe<int> _probe;

public Subscriber(WhiteboxSubscriberProbe<int?> probe)
public Subscriber(WhiteboxSubscriberProbe<int> probe)
{
_probe = probe;
}
@@ -45,13 +45,13 @@ public SubscriberPuppet(ISubscription subscription)
public void SignalCancel() => _subscription.Cancel();
}

public override void OnNext(int? element)
public override void OnNext(int element)
{
base.OnNext(element);
_probe.RegisterOnNext(element);
}

protected override bool WhenNext(int? element) => true;
protected override bool WhenNext(int element) => true;

public override void OnError(Exception cause)
{
Original file line number Diff line number Diff line change
@@ -115,6 +115,12 @@ public void Required_spec213_blackbox_mustThrowNullPointerExceptionWhenParameter
() => CustomSubscriberVerification(new LamdaSubscriber<int?>()).Required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull(),
"OnNext(null) did not throw ArgumentNullException");

[Test]
public void Required_spec213_blackbox_mustThrowNullPointerExceptionWhenParametersAreNull_mustIgnoreSpecForValueType_onNext()
=> RequireTestSkip(
() => SimpleSubscriberVerification().Required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull(),
"Can't verify behavior for value types");

[Test]
public void Required_spec213_blackbox_mustThrowNullPointerExceptionWhenParametersAreNull_mustFailOnIgnoredNull_onError()
=> RequireTestFailure(
Original file line number Diff line number Diff line change
@@ -310,15 +310,17 @@ public void Required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionW
public void Required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull()
=> BlackboxSubscriberWithoutSetupTest(stage =>
{
var element = default(T);
if(element != null)
throw new IgnoreException("Can't verify behavior for value types");

var subscriber = CreateSubscriber();
var gotNpe = false;
subscriber.OnSubscribe(new Spec213DummySubscription());

try
{
// we can't use null here because we can't enforce a constsraint which supports Nullable<T>
// default(T) will return null for all reference types as well as Nullable<T>
subscriber.OnNext(default(T));
subscriber.OnNext(element);
}
catch (ArgumentNullException)
{
Original file line number Diff line number Diff line change
@@ -329,13 +329,15 @@ public void Required_spec213_onSubscribe_mustThrowNullPointerExceptionWhenParame
public void Required_spec213_onNext_mustThrowNullPointerExceptionWhenParametersAreNull()
=> SubscriberTest(stage =>
{
var element = default(T);
if (element != null)
throw new IgnoreException("Can't verify behavior for value types");

var subscriber = stage.Sub;
var gotNpe = false;
try
{
// we can't use null here because we can't enforce a constsraint which supports Nullable<T>
// default(T) will return null for all reference types as well as Nullable<T>
subscriber.OnNext(default(T));
subscriber.OnNext(element);
}
catch (ArgumentNullException)
{