ruby / spec

The Ruby Spec Suite aka ruby/spec
MIT License
588 stars 384 forks source link

Remove senseless spec. #1140

Closed marcandre closed 4 months ago

marcandre commented 4 months ago

A negative size makes no sense at all, -infinity even less so. It is indeed the case that Ruby currently returns -infinity (even if you take the product of two of these senseless enumerables), but that doesn't make it a valid spec. Ruby does this because it is simpler to test for ±infinity than it is to test for +infinity...

Other alternative implementations should not attempt to mimick such behaviour.

One could argue it is a bug (and nil should be returned maybe, but that would be the case for any negative size), or that the current result is acceptable because "garbage in garbage out", but nobody in their right mind would rely on this behavior and clearly returning nil or raising an exception are better results than returning - infinity.

This PR leaves this uninteresting and ill-defined corner case as implementation dependent.

Ref: https://github.com/marcandre/backports/pull/192

andrykonchin commented 4 months ago

Agree!

Wondering if it makes sense to have means to specify explicitly in specs that some case has undefined behaviour or implementation-specific one? In case a CRuby behaviour is considered as not accurate?