Skip to content

Commit bdcbef9

Browse files
committed
add integration test
1 parent 690dacc commit bdcbef9

File tree

12 files changed

+245
-6
lines changed

12 files changed

+245
-6
lines changed

core/define/src/mill/define/Task.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ object Task extends TaskBase {
146146
class CommandFactory private[mill] (val exclusive: Boolean) {
147147
inline def apply[T](inline t: Result[T])(implicit
148148
inline w: W[T],
149-
inline ctx: mill.define.Ctx
149+
inline ctx: mill.define.ModuleCtx
150150
): Command[T] = ${ TaskMacros.commandImpl[T]('t)('w, 'ctx, '{ this.exclusive }) }
151151
}
152152

@@ -546,7 +546,7 @@ private object TaskMacros {
546546
Quotes
547547
)(t: Expr[Result[T]])(
548548
w: Expr[W[T]],
549-
ctx: Expr[mill.define.Ctx],
549+
ctx: Expr[mill.define.ModuleCtx],
550550
exclusive: Expr[Boolean]
551551
): Expr[Command[T]] = {
552552
appImpl[Command, T](
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package app
2+
3+
import lib.*
4+
5+
final case class MyNumber(val value: Int)
6+
7+
object MyNumber {
8+
9+
given gCombinator: Combinator[MyNumber] = new Combinator[MyNumber] {
10+
def combine(a: MyNumber, b: MyNumber): MyNumber = MyNumber(a.value + b.value)
11+
}
12+
13+
given gDefaultValue: DefaultValue[MyNumber] = new DefaultValue[MyNumber] {
14+
def defaultValue: MyNumber = MyNumber(0)
15+
}
16+
17+
def combine(a: MyNumber, b: MyNumber, c: MyNumber): MyNumber = {
18+
val temp = gCombinator.combine(a, b)
19+
gCombinator.combine(temp, c)
20+
}
21+
22+
def defaultValue: MyNumber = gDefaultValue.defaultValue
23+
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package app
2+
3+
import lib.*
4+
5+
final case class MyString(val value: String)
6+
7+
object MyString {
8+
9+
given gCombinator: Combinator[MyString] = new Combinator[MyString] {
10+
def combine(a: MyString, b: MyString): MyString = MyString(a.value + b.value)
11+
}
12+
13+
given gDefaultValue: DefaultValue[MyString] = new DefaultValue[MyString] {
14+
def defaultValue: MyString = MyString("")
15+
}
16+
17+
def combine(a: MyString, b: MyString, c: MyString): MyString = {
18+
val temp = gCombinator.combine(a, b)
19+
gCombinator.combine(temp, c)
20+
}
21+
22+
def defaultValue: MyString = gDefaultValue.defaultValue
23+
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package app
2+
3+
import utest.*
4+
import app.MyNumber
5+
6+
object MyNumberCombinatorTests extends TestSuite {
7+
def tests = Tests {
8+
test("simple") {
9+
val a = MyNumber(1)
10+
val b = MyNumber(2)
11+
val c = MyNumber(3)
12+
val result = MyNumber.combine(a, b, c)
13+
assert(result == MyNumber(6))
14+
}
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package app
2+
3+
import utest.*
4+
import app.MyNumber
5+
6+
object MyNumberDefaultValueTests extends TestSuite {
7+
def tests = Tests {
8+
test("simple") {
9+
val result = MyNumber.defaultValue
10+
assert(result == MyNumber(0))
11+
}
12+
}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package app
2+
3+
import utest.*
4+
import app.MyString
5+
6+
object MyStringCombinatorTests extends TestSuite {
7+
def tests = Tests {
8+
test("simple") {
9+
val a = MyString("a")
10+
val b = MyString("b")
11+
val c = MyString("c")
12+
val result = MyString.combine(a, b, c)
13+
assert(result == MyString("abc"))
14+
}
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package app
2+
3+
import utest.*
4+
import app.MyString
5+
6+
object MyStringDefaultValueTests extends TestSuite {
7+
def tests = Tests {
8+
test("simple") {
9+
val result = MyString.defaultValue
10+
assert(result == MyString(""))
11+
}
12+
}
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package build
2+
3+
import mill._, scalalib._
4+
5+
object lib extends ScalaModule {
6+
def scalaVersion = "3.3.1"
7+
}
8+
9+
object app extends ScalaModule {
10+
def scalaVersion = "3.3.1"
11+
def moduleDeps = Seq(lib)
12+
13+
object test extends ScalaTests {
14+
def ivyDeps = Seq(ivy"com.lihaoyi::utest:0.8.5")
15+
def testFramework = "utest.runner.Framework"
16+
def moduleDeps = Seq(app)
17+
}
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package lib
2+
3+
trait Combinator[T] {
4+
def combine(a: T, b: T): T
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package lib
2+
3+
trait DefaultValue[T] {
4+
def defaultValue: T
5+
}

0 commit comments

Comments
 (0)