From d9da868e2c2554fc731991259e7cc5602337f31c Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 30 Sep 2020 22:34:59 +0200 Subject: [PATCH] Regenerated AtomicTest --- .../Building Maps/Examples/task.md | 2 +- .../Hello, World/Examples/task.md | 3 +- util/src/AtomicTest.kt | 34 +++++++++---------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Functional Programming/Building Maps/Examples/task.md b/Functional Programming/Building Maps/Examples/task.md index 66ca4549..fc8f423f 100644 --- a/Functional Programming/Building Maps/Examples/task.md +++ b/Functional Programming/Building Maps/Examples/task.md @@ -1,4 +1,4 @@ ## Building Maps Examples accompanying the atom. -[Read "Building Maps" atom online.](https://stepik.org/lesson/350541/step/1) +[Read "Building Maps" atom online.](https://stepik.org/lesson/107894/step/1) diff --git a/Programming Basics/Hello, World/Examples/task.md b/Programming Basics/Hello, World/Examples/task.md index 08b2f84a..92efc9b0 100644 --- a/Programming Basics/Hello, World/Examples/task.md +++ b/Programming Basics/Hello, World/Examples/task.md @@ -1,3 +1,4 @@ ## Hello, World -Examples accompanying the atom. \ No newline at end of file +Examples accompanying the atom. +[Read "Hello, World" atom online.](https://stepik.org/lesson/103796/step/1) diff --git a/util/src/AtomicTest.kt b/util/src/AtomicTest.kt index d777c44c..71304bb2 100644 --- a/util/src/AtomicTest.kt +++ b/util/src/AtomicTest.kt @@ -15,7 +15,7 @@ private fun runTest( if (!test()) { print(ERROR_TAG) println("$actual " + - (if(checkEquals) "!=" else "==") + + (if (checkEquals) "!=" else "==") + " $expected") } } @@ -24,7 +24,7 @@ private fun runTest( * Compares the string representation * of the object with the string `value`. */ -infix fun T.eq(value: String) { +infix fun T.eq(value: String) { runTest(this, value) { this.toString() == value.trimIndent() } @@ -59,9 +59,9 @@ infix fun Double.eq(value: Double) { abs(this - value) < 0.0000001 } } + /** - * Auxiliary class that contains the information - * about the captured exception type and its message. + * Holds captured exception information: */ class CapturedException( private val exceptionClass: KClass<*>?, @@ -69,37 +69,37 @@ class CapturedException( ) { private val fullMessage: String get() { - val className = this.exceptionClass?.simpleName ?: "" - return className + this.actualMessage + val className = + exceptionClass?.simpleName ?: "" + return className + actualMessage } infix fun eq(message: String) { fullMessage eq message } - infix fun contains(messageParts: List) { - if (messageParts.any { it !in fullMessage }) { + infix fun contains(parts: List) { + if (parts.any { it !in fullMessage }) { print(ERROR_TAG) println("Actual message: $fullMessage") - println("Expected parts: $messageParts") + println("Expected parts: $parts") } } override fun toString() = fullMessage } /** - * Captures an exception and produces information - * about its type and message. - * Usage: - * + * Captures an exception and produces + * information about it. Usage: * ``` * capture { * // Code that fails * } eq "FailureException: message" * ``` */ -fun capture(f: () -> Unit): CapturedException = +fun capture(f:() -> Unit): CapturedException = try { f() - CapturedException(null, "$ERROR_TAG Expected an exception") + CapturedException(null, + "$ERROR_TAG Expected an exception") } catch (e: Throwable) { CapturedException(e::class, (e.message?.let { ": $it" } ?: "")) @@ -111,7 +111,7 @@ object trace { trc += obj.toString() } /** - * Compares Trace contents to a multiline + * Compares trc contents to a multiline * `String` by ignoring line separators. */ infix fun eq(multiline: String) { @@ -123,4 +123,4 @@ object trace { } trc.clear() } -} +} \ No newline at end of file