Skip to content

Commit

Permalink
- Add Compilation test to macros project
Browse files Browse the repository at this point in the history
- Remove dependence that core has on unstable macros
  • Loading branch information
lloydmeta committed Jan 4, 2017
1 parent dcd9cd3 commit 6dac841
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 23 deletions.
44 changes: 22 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,27 @@ lazy val scala_2_12 = Project(id = "scala_2_12",
enumeratumReactiveMongoBson
).map(Project.projectToRef): _*) // base plus known 2.12 friendly libs

// Aggregates core and macro
lazy val macrosAggregate = aggregateProject("macros", macrosJS, macrosJVM)
lazy val macros = crossProject
.crossType(CrossType.Pure)
.in(file("macros"))
.settings(commonWithPublishSettings: _*)
.settings(
withCompatUnmanagedSources(jsJvmCrossProject = true,
include_210Dir = true,
includeTestSrcs = false): _*)
.settings(
name := "enumeratum-macros",
version := Versions.Macros.head,
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
)
.settings(testSettings: _*)
lazy val macrosJS = macros.js
lazy val macrosJVM = macros.jvm

// Aggregates core
lazy val coreAggregate = aggregateProject("core", coreJS, coreJVM)
lazy val core = crossProject
.crossType(CrossType.Pure)
Expand All @@ -91,7 +111,7 @@ lazy val core = crossProject
)
.settings(testSettings: _*)
.settings(commonWithPublishSettings: _*)
.dependsOn(macros)
// .dependsOn(macros) used for testing macros
lazy val coreJS = core.js
lazy val coreJVM = core.jvm

Expand Down Expand Up @@ -135,26 +155,6 @@ lazy val coreJVMTests = Project(id = "coreJVMTests",
)
.dependsOn(coreJVM)

lazy val macrosAggregate = aggregateProject("macros", macrosJS, macrosJVM)
lazy val macros = crossProject
.crossType(CrossType.Pure)
.in(file("macros"))
.settings(commonWithPublishSettings: _*)
.settings(
withCompatUnmanagedSources(jsJvmCrossProject = true,
include_210Dir = true,
includeTestSrcs = false): _*)
.settings(
name := "enumeratum-macros",
version := Versions.Macros.head,
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
)
.settings(testSettings: _*)
lazy val macrosJS = macros.js
lazy val macrosJVM = macros.jvm

lazy val enumeratumReactiveMongoBson =
Project(id = "enumeratum-reactivemongo-bson",
base = file("enumeratum-reactivemongo-bson"),
Expand Down
51 changes: 51 additions & 0 deletions macros/src/test/scala/enumeratum/Compilation.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package enumeratum
import scala.language.experimental.macros

/**
* Created by Lloyd on 1/4/17.
*
* Copyright 2017
*/
object FindValEnums {
def apply[A] = macro ValueEnumMacros.findIntValueEntriesImpl[A]
}

sealed abstract class A private (val value: Int) {
val text: String
}

object A {

val values = FindValEnums[A]

case object A1 extends A(1) {
val text = identity("something")
}

def identity(str: String) = str

}

class C
object C {
def build: C = new C
}

sealed abstract class B private (val value: Int, val other: C) {
val text: String
}

object B {

val values = FindValEnums[B]

case object B1 extends B(1, new C) {
val text = identity("something")
}
case object B2 extends B(2, C.build) {
val text = identity("something")
}

def identity(str: String) = str

}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ addSbtPlugin("org.wartremover" % "sbt-wartremover" % "1.2.1")

addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.4.1")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

0 comments on commit 6dac841

Please sign in to comment.