-
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.
Display enum values as enum names instead of
<className>@<hashCode>
(…
- Loading branch information
Showing
5 changed files
with
87 additions
and
10 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
37 changes: 37 additions & 0 deletions
37
src/jvm/test/org/jetbrains/kotlinx/lincheck_test/representation/EnumRepresentationTest.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,37 @@ | ||
/* | ||
* 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.* | ||
import org.jetbrains.kotlinx.lincheck.annotations.Operation | ||
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* | ||
import org.jetbrains.kotlinx.lincheck_test.util.* | ||
import org.junit.* | ||
|
||
class EnumRepresentationTest { | ||
private var x: MyEnum = MyEnum.VALUE_1 | ||
private var counter = 0 | ||
|
||
@Operation | ||
fun operation(): Int { | ||
x = MyEnum.VALUE_2 | ||
return counter++ | ||
} | ||
|
||
@Test | ||
fun test() = ModelCheckingOptions() | ||
.checkImpl(this::class.java) | ||
.checkLincheckOutput("enum_representation.txt") | ||
} | ||
|
||
private enum class MyEnum { | ||
VALUE_1, VALUE_2 | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/jvm/test/resources/expected_logs/enum_representation.txt
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,36 @@ | ||
= Invalid execution results = | ||
| ------------------------------- | | ||
| Thread 1 | Thread 2 | | ||
| ------------------------------- | | ||
| operation(): 0 | operation(): 0 | | ||
| ------------------------------- | | ||
|
||
The following interleaving leads to the error: | ||
| ----------------------------------------------------------------------------------------------------- | | ||
| Thread 1 | Thread 2 | | ||
| ----------------------------------------------------------------------------------------------------- | | ||
| | operation(): 0 | | ||
| | x.WRITE(VALUE_2) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:25) | | ||
| | counter.READ: 0 at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | ||
| | switch | | ||
| operation(): 0 | | | ||
| | counter.WRITE(1) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | ||
| | result: 0 | | ||
| ----------------------------------------------------------------------------------------------------- | | ||
|
||
Detailed trace: | ||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Thread 1 | Thread 2 | | ||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | operation(): 0 | | ||
| | x.WRITE(VALUE_2) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:25) | | ||
| | counter.READ: 0 at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | ||
| | switch | | ||
| operation(): 0 | | | ||
| x.WRITE(VALUE_2) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:25) | | | ||
| counter.READ: 0 at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | | ||
| counter.WRITE(1) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | | ||
| result: 0 | | | ||
| | counter.WRITE(1) at EnumRepresentationTest.operation(EnumRepresentationTest.kt:26) | | ||
| | result: 0 | | ||
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Oops, something went wrong.