G
G
Georgix2019-02-16 20:02:00
Kotlin
Georgix, 2019-02-16 20:02:00

Kotlin - expected: java.util.Collections$SingletonList but was: java.util.ArrayList. Why?

I apologize in advance for the stupid question. I googled, didn't find anything specific on the Singleton topic.
org.opentest4j.AssertionFailedError: expected: [email protected]<[line]> but was: [email protected]<[line]>
The compilation result is correct, it gives me the desired list, the tests match the result . The only thing is that it complains about waiting for a Singleton, while fun text(text: String): Any. Why? Where can I read what exactly is the Singleton type and the most common questions about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-02-17
@Georgix

In short, apparently, you have a test where you do something like assertEquals(<что-то>, text(<что-то-ещё>));
Lists you get in different ways. mutableListOf returns a java.util.ArrayList, and a SingletonList is obtained from a single element by calling Collections.singletonList(something). equals is apparently not overridden there (I don’t remember now), which is why it turns out such garbage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question