Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DLochmelis33 committed Sep 4, 2024
1 parent 80d9450 commit af2284a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.jetbrains.litmuskt.tests

import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome
import org.jetbrains.litmuskt.LitmusTestContainer
import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome
import org.jetbrains.litmuskt.autooutcomes.accept
import org.jetbrains.litmuskt.autooutcomes.forbid
import org.jetbrains.litmuskt.autooutcomes.interesting
Expand Down Expand Up @@ -66,19 +66,22 @@ object UnsafePublication {
}
}

val PlainArrayBoxed = litmusTest({
val PlainArray = litmusTest({
object : LitmusIOutcome() {
var arr: Array<Int>? = null
}
}) {
thread {
arr = Array(10) { 1 }
arr = Array(1) { 1 }
}
thread {
r1 = arr?.get(0) ?: -1
}
spec {
accept(1)
// 0 is the default value for `Int`. However, since Int-s in `Array<Int>` are boxed, we don't get to see a 0.
// On JVM, a NullPointerException here is technically valid. Currently, there is no support for exceptions as accepted outcomes.
// On Native, there is no NullPointerException, so we can see a segmentation fault.
interesting(0)
accept(-1)
}
Expand All @@ -89,10 +92,6 @@ object UnsafePublication {
var arr: IntArray? = null
}
}) {
reset {
arr = null
outcomeReset()
}
thread {
arr = IntArray(1) { 1 }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.jetbrains.litmuskt

import org.jetbrains.litmuskt.autooutcomes.*
import org.jetbrains.litmuskt.*
import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome
import org.jetbrains.litmuskt.autooutcomes.accept
import org.jetbrains.litmuskt.autooutcomes.forbid
import java.util.concurrent.atomic.AtomicIntegerArray

@LitmusTestContainer
Expand All @@ -11,10 +12,6 @@ object UnsafePublicationJvm {
var arr: AtomicIntegerArray? = null
}
}) {
reset {
arr = null
outcomeReset()
}
thread {
arr = AtomicIntegerArray(intArrayOf(1))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package org.jetbrains.litmuskt.tests

import org.jetbrains.litmuskt.autooutcomes.*
import org.jetbrains.litmuskt.*
import org.jetbrains.litmuskt.LitmusTestContainer
import org.jetbrains.litmuskt.autooutcomes.LitmusIOutcome
import org.jetbrains.litmuskt.autooutcomes.accept
import org.jetbrains.litmuskt.autooutcomes.interesting
import org.jetbrains.litmuskt.litmusTest
import kotlin.concurrent.AtomicIntArray

@LitmusTestContainer
object UnsafePublicationNative {

@OptIn(kotlin.ExperimentalStdlibApi::class)
@OptIn(ExperimentalStdlibApi::class)
val PlainAtomicIntArray = litmusTest({
object : LitmusIOutcome() {
var arr: AtomicIntArray? = null
}
}) {
reset {
arr = null
outcomeReset()
}
thread {
arr = AtomicIntArray(10) { 1 }
arr = AtomicIntArray(1) { 1 }
}
thread {
r1 = arr?.get(0) ?: -1
Expand Down

0 comments on commit af2284a

Please sign in to comment.