-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
141 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import mill._ | ||
|
||
def pub = T { | ||
priv() | ||
} | ||
|
||
private def priv = T { | ||
"priv" | ||
} | ||
|
||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
|
||
private def baz = T { | ||
"bazOuter" | ||
} | ||
|
||
object qux extends Module { | ||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
private def baz = T { | ||
"bazInner" | ||
} | ||
} | ||
|
||
object cls extends cls | ||
class cls extends Module { | ||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
|
||
private def baz = T { | ||
"bazCls" | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
integration/feature/private-methods/test/src/PrivateMethodsTests.scala
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,46 @@ | ||
package mill.integration | ||
|
||
import utest._ | ||
|
||
object PrivateMethodsTests extends IntegrationTestSuite { | ||
val tests = Tests { | ||
val wsRoot = initWorkspace() | ||
"simple" - { | ||
// Simple public target depending on private target works | ||
val pub = evalStdout("show", "pub") | ||
assert(pub.out == "\"priv\"") | ||
assert(pub.isSuccess) | ||
|
||
// Make sure calling private methods indirectly in a variety of scenarios works | ||
// even when they're "not really private" due to | ||
val fooBar = evalStdout("show", "foo.bar") | ||
assert(fooBar.out == "\"bazOuter\"") | ||
assert(fooBar.isSuccess) | ||
|
||
val quxFooBar = evalStdout("show", "qux.foo.bar") | ||
assert(quxFooBar.out == "\"bazInner\"") | ||
assert(quxFooBar.isSuccess) | ||
|
||
val clsFooBar = evalStdout("show", "cls.foo.bar") | ||
assert(clsFooBar.out == "\"bazCls\"") | ||
assert(clsFooBar.isSuccess) | ||
|
||
// Make sure calling private methods directly fails | ||
val priv = evalStdout("show", "priv") | ||
assert(priv.err.contains("Cannot resolve priv")) | ||
assert(priv.isSuccess == false) | ||
|
||
val baz = evalStdout("show", "baz") | ||
assert(baz.err.contains("Cannot resolve baz")) | ||
assert(baz.isSuccess == false) | ||
|
||
val quxBaz = evalStdout("show", "qux.baz") | ||
assert(quxBaz.err.contains("Cannot resolve qux.baz")) | ||
assert(quxBaz.isSuccess == false) | ||
|
||
val clsBaz = evalStdout("show", "cls.baz") | ||
assert(clsBaz.err.contains("Cannot resolve cls.baz")) | ||
assert(clsBaz.isSuccess == false) | ||
} | ||
} | ||
} |
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
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,44 @@ | ||
import mill._ | ||
|
||
|
||
def pub = T { | ||
priv() | ||
} | ||
|
||
private def priv = T { | ||
"priv" | ||
} | ||
|
||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
|
||
private def baz = T { | ||
"bazOuter" | ||
} | ||
|
||
object qux extends Module { | ||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
private def baz = T { | ||
"bazInner" | ||
} | ||
} | ||
|
||
object cls extends cls | ||
class cls extends Module { | ||
object foo extends Module { | ||
def bar = T { | ||
baz() | ||
} | ||
} | ||
|
||
private def baz = T { | ||
"bazCls" | ||
} | ||
} |