From a2c31ce94617caa7e7157921ddbe010c61a135fc Mon Sep 17 00:00:00 2001 From: Ivan “CLOVIS” Canet Date: Sat, 28 Mar 2026 16:22:46 +0000 Subject: [PATCH] feat(suite): Display failed exception assertions on two lines --- suite/src/commonMain/kotlin/assertions/Exceptions.kt | 4 ++-- suite/src/commonTest/kotlin/assertions/ExceptionsTest.kt | 6 +++--- 2 file(s) changed, 5 insertion(s)(+), 5 deletion(s)(-) diff --git a/suite/src/commonMain/kotlin/assertions/Exceptions.kt b/suite/src/commonMain/kotlin/assertions/Exceptions.kt --- a/suite/src/commonMain/kotlin/assertions/Exceptions.kt +++ b/suite/src/commonMain/kotlin/assertions/Exceptions.kt @@ -46,8 +46,8 @@ } catch (e: Throwable) { // Simplifiable in Kotlin 2.2.20: https://youtrack.jetbrains.com/issue/KT-54363 when (e) { is T -> return e - else -> throw AssertionError("Expected to throw ${T::class}, but the operation threw the exception $e (see cause below for details)", e) + else -> throw AssertionError("Expected to throw ${T::class}\nbut the operation threw the exception $e (see cause below for details)", e) } } - throw AssertionError("Expected to throw ${T::class}, but the operation was successful and returned: $result") + throw AssertionError("Expected to throw ${T::class}\nbut the operation was successful and returned: $result") } diff --git a/suite/src/commonTest/kotlin/assertions/ExceptionsTest.kt b/suite/src/commonTest/kotlin/assertions/ExceptionsTest.kt --- a/suite/src/commonTest/kotlin/assertions/ExceptionsTest.kt +++ b/suite/src/commonTest/kotlin/assertions/ExceptionsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, OpenSavvy and contributors. + * Copyright (c) 2025-2026, OpenSavvy and contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ error("This should go through the 'checkThrows' call") } } catch (e: AssertionError) { - check(e.message matches "Expected to throw .*IllegalArgumentException.*, but the operation threw the exception .*IllegalStateException: This should go through the 'checkThrows' call \\(see cause below for details\\)") + check(e.message matches "Expected to throw .*IllegalArgumentException.*\nbut the operation threw the exception .*IllegalStateException: This should go through the 'checkThrows' call \\(see cause below for details\\)") check(e.cause?.message == "This should go through the 'checkThrows' call") } } @@ -44,7 +44,7 @@ val a = 5 } } catch (e: AssertionError) { - check(e.message matches "Expected to throw .*IllegalArgumentException.*, but the operation was successful and returned: .*Unit") + check(e.message matches "Expected to throw .*IllegalArgumentException.*\nbut the operation was successful and returned: .*Unit") } } -- tangled.sh