-
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.
Ensure disable private check cmd line option disables runtime private…
… access checks (#10034) Ensure that `--disable-private-check` cmd line option disables the runtime private access checks as well.
- Loading branch information
Showing
4 changed files
with
84 additions
and
36 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
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)); | ||
}); | ||
} | ||
} |
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