-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#337 - output fixed in case of an incorrect arguments count in th cus…
…tom scenario DSL
- Loading branch information
Aleksandr.Potapov
committed
Jul 3, 2024
1 parent
11eefac
commit 25d5560
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../kotlinx/lincheck_test/representation/IncorrectArgumentsCountInCustomScenarioActorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Lincheck | ||
* | ||
* Copyright (C) 2019 - 2024 JetBrains s.r.o. | ||
* | ||
* This Source Code Form is subject to the terms of the | ||
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package org.jetbrains.kotlinx.lincheck_test.representation | ||
|
||
import org.jetbrains.kotlinx.lincheck.annotations.Operation | ||
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingOptions | ||
import org.jetbrains.kotlinx.lincheck_test.util.checkFailsWithException | ||
import org.junit.Assert | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class IncorrectArgumentsCountInCustomScenarioActorTest { | ||
|
||
@Operation | ||
fun operation(value: Int) = Unit | ||
|
||
@Test | ||
fun testTooFew() { | ||
val exception = Assert.assertThrows(IllegalArgumentException::class.java) { | ||
ModelCheckingOptions() | ||
.addCustomScenario { | ||
parallel { thread { actor(::operation) } } | ||
} | ||
} | ||
assertEquals("The count of the supplied parameters for the operation method is incorrect: 1 arguments expected, 0 supplied.", exception.message) | ||
} | ||
|
||
@Test | ||
fun testTooMany() { | ||
val exception = Assert.assertThrows(IllegalArgumentException::class.java) { | ||
ModelCheckingOptions() | ||
.addCustomScenario { | ||
parallel { thread { actor(::operation, 1, 2) } } | ||
} | ||
} | ||
assertEquals("The count of the supplied parameters for the operation method is incorrect: 1 arguments expected, 2 supplied.", exception.message) | ||
} | ||
|
||
} |