-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bug in the invalid access to local methods of other actors is fixed.
- Loading branch information
Ehsan Khamespanah
committed
Feb 8, 2024
1 parent
69fa8e9
commit be751d4
Showing
10 changed files
with
166 additions
and
17 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
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
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
76 changes: 76 additions & 0 deletions
76
src/test/java/org/rebecalang/compiler/modelcompiler/AccessControlTest.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,76 @@ | ||
package org.rebecalang.compiler.modelcompiler; | ||
|
||
import java.io.File; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.rebecalang.compiler.CompilerConfig; | ||
import org.rebecalang.compiler.utils.CompilerExtension; | ||
import org.rebecalang.compiler.utils.CoreVersion; | ||
import org.rebecalang.compiler.utils.ExceptionContainer; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; | ||
|
||
@ContextConfiguration(classes = CompilerConfig.class) | ||
@SpringJUnitConfig | ||
public class AccessControlTest { | ||
|
||
public static final String MODEL_FILES_BASE = "src/test/resources/org/rebecalang/compiler/modelcompiler/"; | ||
|
||
@Autowired | ||
public RebecaModelCompiler compiler; | ||
@Autowired | ||
public ExceptionContainer exceptionContainer; | ||
|
||
@Test | ||
public void GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_AccessToConstructorTHEN_TwoErrors() { | ||
File model = new File(MODEL_FILES_BASE + "accesscontrol/InvalidAccessToConstructor.rebeca"); | ||
Set<CompilerExtension> extension = new HashSet<CompilerExtension>(); | ||
compiler.compileRebecaFile(model, extension, CoreVersion.CORE_2_3); | ||
|
||
ExceptionContainer expectedExceptionContainer = new ExceptionContainer(); | ||
expectedExceptionContainer.setCorrespondingResource(model); | ||
expectedExceptionContainer.addException(new SymbolTableException("The method A() is not visible for the type A", 6, 7)); | ||
expectedExceptionContainer.addException(new SymbolTableException("The method f() is not visible for the type A", 15, 4)); | ||
|
||
Assertions.assertEquals(expectedExceptionContainer, exceptionContainer); | ||
} | ||
|
||
@Test | ||
public void GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_AccessToLocalMethodOfOtherActorTHEN_OneError() { | ||
File model = new File(MODEL_FILES_BASE + "accesscontrol/InvalidAccessToSynchMethod.rebeca"); | ||
Set<CompilerExtension> extension = new HashSet<CompilerExtension>(); | ||
compiler.compileRebecaFile(model, extension, CoreVersion.CORE_2_3); | ||
|
||
ExceptionContainer expectedExceptionContainer = new ExceptionContainer(); | ||
expectedExceptionContainer.setCorrespondingResource(model); | ||
expectedExceptionContainer.addException(new SymbolTableException("The method f() is not visible for the type A", 12, 4)); | ||
|
||
Assertions.assertEquals(expectedExceptionContainer, exceptionContainer); | ||
} | ||
|
||
@Test | ||
public void GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_ValidAccessToMsgsrvsTHEN_NoError() { | ||
File model = new File(MODEL_FILES_BASE + "accesscontrol/ValidAccessToMsgsrvs.rebeca"); | ||
Set<CompilerExtension> extension = new HashSet<CompilerExtension>(); | ||
compiler.compileRebecaFile(model, extension, CoreVersion.CORE_2_3); | ||
|
||
ExceptionContainer expectedExceptionContainer = new ExceptionContainer(); | ||
expectedExceptionContainer.setCorrespondingResource(model); | ||
|
||
Assertions.assertEquals(expectedExceptionContainer, exceptionContainer); | ||
} | ||
|
||
|
||
|
||
|
||
@Test | ||
public void GIVEN_ManyTests_WHEN_AllAreCorrect_THEN_NoError() { | ||
GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_AccessToLocalMethodOfOtherActorTHEN_OneError(); | ||
GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_AccessToConstructorTHEN_TwoErrors(); | ||
GIVEN_RebecaModelWithTwoReactiveclasses_WHEN_ValidAccessToMsgsrvsTHEN_NoError(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ces/org/rebecalang/compiler/modelcompiler/accesscontrol/InvalidAccessToConstructor.rebeca
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,21 @@ | ||
reactiveclass A(1) { | ||
A() { | ||
|
||
} | ||
void f() { | ||
self.A(); | ||
} | ||
} | ||
|
||
reactiveclass B(1) { | ||
knownrebecs { | ||
A a; | ||
} | ||
msgsrv g() { | ||
a.A(); | ||
} | ||
} | ||
|
||
main { | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...ces/org/rebecalang/compiler/modelcompiler/accesscontrol/InvalidAccessToSynchMethod.rebeca
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,18 @@ | ||
reactiveclass A(1) { | ||
void f() { | ||
|
||
} | ||
} | ||
|
||
reactiveclass B(1) { | ||
knownrebecs { | ||
A a; | ||
} | ||
msgsrv g() { | ||
a.f(); | ||
} | ||
} | ||
|
||
main { | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...resources/org/rebecalang/compiler/modelcompiler/accesscontrol/ValidAccessToMsgsrvs.rebeca
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,25 @@ | ||
reactiveclass A(1) { | ||
msgsrv x() { | ||
|
||
} | ||
} | ||
|
||
reactiveclass B(1) { | ||
knownrebecs { | ||
A a; | ||
} | ||
msgsrv y() { | ||
self.y(); | ||
y(); | ||
z(); | ||
a.x(); | ||
} | ||
msgsrv z() { | ||
|
||
} | ||
} | ||
|
||
main { | ||
A a():(); | ||
B b(a):(); | ||
} |