From 2028ec3ce89406eed16a90c5fde781a9ea1e3df9 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 19 Feb 2018 18:38:21 +0300 Subject: [PATCH] Minor improvements in all/any/none samples Extract variables to make assertion expression shorter. --- .../test/samples/collections/collections.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/samples/test/samples/collections/collections.kt b/libraries/stdlib/samples/test/samples/collections/collections.kt index cfffedb06b7..c7654bbbb28 100644 --- a/libraries/stdlib/samples/test/samples/collections/collections.kt +++ b/libraries/stdlib/samples/test/samples/collections/collections.kt @@ -371,14 +371,17 @@ class Collections { val evens = zeroToTen.map { it * 2 } assertTrue(evens.all { isEven(it) }) - assertTrue(emptyList().all { false }) + val emptyList = emptyList() + assertTrue(emptyList.all { false }) } @Sample fun none() { - assertTrue(emptyList().none()) + val emptyList = emptyList() + assertTrue(emptyList.none()) - assertFalse(listOf("one", "two", "three").none()) + val nonEmptyList = listOf("one", "two", "three") + assertFalse(nonEmptyList.none()) } @Sample @@ -391,14 +394,17 @@ class Collections { val odds = zeroToTen.map { it * 2 + 1 } assertTrue(odds.none { isEven(it) }) - assertTrue(emptyList().none { true }) + val emptyList = emptyList() + assertTrue(emptyList.none { true }) } @Sample fun any() { - assertFalse(emptyList().any()) + val emptyList = emptyList() + assertFalse(emptyList.any()) - assertTrue(listOf(1, 2, 3).any()) + val nonEmptyList = listOf(1, 2, 3) + assertTrue(nonEmptyList.any()) } @Sample @@ -411,7 +417,8 @@ class Collections { val odds = zeroToTen.map { it * 2 + 1 } assertFalse(odds.any { isEven(it) }) - assertFalse(emptyList().any { true }) + val emptyList = emptyList() + assertFalse(emptyList.any { true }) } }