Sequences (arrays etc) don't conform to the Equatable protocol and
therefore couldn't be used in an assert call. For example take a
ViewModel that produces lists of objects to hook up to a TableView. The
only option was to check .is(Not)Empty and not assert the contents of
the sequences to make sure the ViewModel behaves correctly.
This feature add support for Sequences to contain elements that are Equatable. The code is almost similar to the existing code but because of different generic constraint I didn't see a way to reuse/generify more. Improvements/comments on this are welcome.
Also a limitation exists on comparing the result to an empty array; Swift doesn't know the type of the elements of the array so the code doesn't compile. You need to explicitly specify type of the elements of the empty array; see test-case.
Sequence
s (arrays etc) don't conform to theEquatable
protocol and therefore couldn't be used in an assert call. For example take a ViewModel that produces lists of objects to hook up to a TableView. The only option was to check .is(Not)Empty and not assert the contents of the sequences to make sure the ViewModel behaves correctly.This feature add support for
Sequence
s to contain elements that areEquatable
. The code is almost similar to the existing code but because of different generic constraint I didn't see a way to reuse/generify more. Improvements/comments on this are welcome.Also a limitation exists on comparing the result to an empty array; Swift doesn't know the type of the elements of the array so the code doesn't compile. You need to explicitly specify type of the elements of the empty array; see test-case.