-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Relax Kotlin contracts for Executable
parameters
#4481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6669b93
ab26f26
5cac4e3
0646eba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,26 +156,27 @@ internal class KotlinAssertTimeoutAssertionsTests { | |
} | ||
|
||
@Test | ||
fun `assertTimeout with value initialization in lambda`() { | ||
fun `assertTimeout with value assignment in lambda`() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that this test will pass even when no contract is specified. The @Test
fun `assertTimeout with value assignment in lambda`() {
val value: Int
assertTimeout(ofMillis(500)) {
value = 10 // Val can be assigned in the message supplier lambda.
assertEquals(10, value)
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion. Applied in 5cac4e3 |
||
val value: Int | ||
|
||
assertTimeout(ofMillis(500)) { value = 10 } | ||
|
||
assertEquals(10, value) | ||
assertTimeout(ofMillis(500)) { | ||
value = 10 // Val can be assigned in the message supplier lambda. | ||
assertEquals(10, value) | ||
} | ||
} | ||
|
||
@Test | ||
fun `assertTimeout with message and value initialization in lambda`() { | ||
val value: Int | ||
fun `assertTimeout with message and value assignment in lambda`() { | ||
var value = 0 | ||
|
||
assertTimeout(ofMillis(500), "message") { value = 10 } | ||
|
||
assertEquals(10, value) | ||
} | ||
|
||
@Test | ||
fun `assertTimeout with message supplier and value initialization in lambda`() { | ||
val value: Int | ||
fun `assertTimeout with message supplier and value assignment in lambda`() { | ||
var value = 0 | ||
|
||
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") | ||
val valueInMessageSupplier: Int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This executable should be called
EXACTLY_ONCE
, as otherassertDoesNotThrow
methods.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Addressed in
ef78d82
(#4551)