sebastianbenz / Jnario

Executable specifications for Java
136 stars 38 forks source link

Iterable<T> and List<T> should be compared properly #148

Closed borisbrodski closed 9 years ago

borisbrodski commented 9 years ago

Following spec throws an AssertionError

fact "can compare iterable with list of same type" {
  #[].filter[true] => #[]
}

The exception:

java.lang.AssertionError: 
Expected #[].filter[true] => #[] but
     #[].filter[true] is <[]>
     #[] is <[]>

    at org.jnario.lib.Assert.fail(Assert.java:48)
    at org.jnario.lib.Assert.assertTrue(Assert.java:20)

Here #[] is of type List<Object> but #[].filter[true] of type Iterable<Object>

sebastianbenz commented 9 years ago

I think this is the correct behavior as it is based on Java's equal semantics. You could easily fix this by writing:

#[].filter[true].toList => #[]

or

#[].filter[true].toList => empty

Besides changing this behavior would be a breaking API change which I would like to avoid.

borisbrodski commented 9 years ago

Ok, I see.