Where are the Scala collections tested?

I am looking for tests that can be used for custom collections. Ideally, these are behavior tests. For example, when introducing a new Map I would like to check if it follows all the necessary Map -rules and methods, such as Map , filter , view , etc.

What is used by Scala to test their own collections?

+4
source share
1 answer

This is a good question that was asked earlier on SO.

In the original repository, there are collection tests under test/files/scalacheck and others under test/files/run/*coll* .

There is no matching test or TCK for custom collections. Integration with collections is usually associated with a specific implementation requirement.

For example, ScalaDoc for immutable.MapLike tells you to implement get , iterator and + and - . Theoretically, if you test template methods, you can rely on everything you get for free from the library.

But the document adds:

It is also recommended that you override the foreach and size methods for efficiency.

So, if you don't care, you will also add performance tests. The standard library does not include automatic performance testing.

+2
source

Source: https://habr.com/ru/post/1500687/


All Articles