Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions latte/src/main/java/typechecking/LatteTypeChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ public void visitCtIf(CtIf ifElement) {
visitCtVariableRead((CtVariableRead<?>)condition);
} else if (condition instanceof CtFieldRead){
visitCtFieldRead((CtFieldRead<?>)condition);
} else if (condition instanceof CtInvocation) {
visitCtInvocation((CtInvocation<?>) condition);
} else {
logError("Cannot evaluate the condition of the if statement: " + condition.toString(), condition);
}
Expand Down
44 changes: 44 additions & 0 deletions latte/src/test/examples/MyNodeIfInvocationPermission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package latte;

import specification.Free;
import specification.Unique;
import specification.Shared;

/*
* This file is part of the Latte test suite.
*/
class MyNode {

@Unique Object value;
@Unique Node next;

/**
* Constructor for the Node class using @Free value and next nodes
* @param value
* @param next
*/
public MyNode (@Free Object value, @Free Node next) {
this.value = value;
this.next = next;
}

public @Unique Object test(@Free Object v1, @Free Object v2, @Free Node n1, boolean c1){
@Shared MyNode n = new MyNode(v1, n1);
Object o1 = new Object();
Node n2 = new Node();

if (this.test(n, o1, n2)) {
this.value = v2;
} else {
this.value = v2;
}
return this.value;
}

public boolean test2(@Shared MyNode node, @Free Object o, @Free Node next){
@Free MyNode mn = new MyNode(o, next);
node = mn;

return node == this;
}
}
35 changes: 35 additions & 0 deletions latte/src/test/examples/MyNodeInvocationIf.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package latte;

import specification.Free;
import specification.Unique;

/*
* This file is part of the Latte test suite.
*/
class MyNode {

@Unique Object value;
@Unique Node next;

/**
* Constructor for the Node class using @Free value and next nodes
* @param value
* @param next
*/
public MyNode (@Free Object value, @Free Node next) {
this.value = value;
this.next = next;
}

public void test(@Free Object v1, boolean c1){
if (boolRead(c1)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now add more tests with methods that use the Objects with permissions like @Unique, and see if their changes are added to the context after the call.

this.value = v1;
} else {
this.value = null;
}
}

private boolean boolRead(boolean b){
return b;
}
}
4 changes: 3 additions & 1 deletion latte/src/test/java/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ private static Stream<Arguments> provideCorrectTestCases() {
Arguments.of("src/test/examples/searching_state_space/TimerTaskCannotReschedule.java"),
Arguments.of("src/test/examples/searching_state_space/ResultSetNoNext.java"),
Arguments.of("src/test/examples/searching_state_space/ResultSetForwardOnly.java"),
Arguments.of("src/test/examples/stack_overflow/MediaRecord.java")
Arguments.of("src/test/examples/stack_overflow/MediaRecord.java"),
Arguments.of("src/test/examples/MyNodeInvocationIf.java"),
Arguments.of("src/test/examples/MyNodeIfInvocationPermission.java")
);
}

Expand Down
Loading