-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for private ctor call when private check is disabled
- Loading branch information
Showing
2 changed files
with
56 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
40 changes: 40 additions & 0 deletions
40
...tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java
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,40 @@ | ||
package org.enso.interpreter.test.privateaccess; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import java.io.IOException; | ||
import org.enso.interpreter.test.TestBase; | ||
import org.enso.polyglot.RuntimeOptions; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class PrivateCheckDisabledTest extends TestBase { | ||
@Rule public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void privateCtorCanBeAccessedWhenPrivateCheckIsDisabled() throws IOException { | ||
var libSrc = """ | ||
type T | ||
private Cons data | ||
"""; | ||
createProject("Lib", libSrc, tempFolder); | ||
var mainSrc = | ||
""" | ||
from local.Lib import T | ||
main = | ||
obj = T.Cons 42 | ||
obj.data | ||
"""; | ||
var mainDir = createProject("Main", mainSrc, tempFolder); | ||
var ctxBuilder = defaultContextBuilder().option(RuntimeOptions.DISABLE_PRIVATE_CHECK, "true"); | ||
testProjectRun( | ||
ctxBuilder, | ||
mainDir, | ||
res -> { | ||
assertThat(res.isNumber(), is(true)); | ||
assertThat(res.asInt(), is(42)); | ||
}); | ||
} | ||
} |