Skip to content
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

DRY isScala3 #80

Merged
merged 1 commit into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package org.typelevel.scalaccompat.annotation

object CustomStaticHelper {
object ScalacVersionHelper {
final val isScala3 = false
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

package org.typelevel.scalaccompat.annotation

object CustomStaticHelper {
object ScalacVersionHelper {
final val isScala3 = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CustomStaticSuite extends FunSuite {
test("static3 respected on Scala 3 only") {
val fields = classOf[CustomStaticDemo].getFields().map(_.getName).toList

if (CustomStaticHelper.isScala3) {
if (ScalacVersionHelper.isScala3) {
assertEquals(fields, List("foo"))
} else { // Scala 2
assertEquals(fields, Nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CustomTargetNameSuite extends FunSuite {
test("targetName3 respected on Scala 3 only") {
val methods = getClass().getMethods().map(_.getName)

if (CustomTargetNameHelper.isScala3) {
if (ScalacVersionHelper.isScala3) {
assert(clue(methods).contains("bar"))
assert(!clue(methods).contains("foo"))
} else { // Scala 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CustomThreadUnsafeSuite extends FunSuite {

test("threadUnsafe3 respected on Scala 3 only") {
Future.sequence(List(Future(foo), Future(foo))).map { _ =>
if (CustomThreadUnsafeHelper.isScala3) {
if (ScalacVersionHelper.isScala3) {
assertEquals(counter.get(), 2)
} else { // Scala 2
assertEquals(counter.get(), 1)
Expand Down