-
Notifications
You must be signed in to change notification settings - Fork 277
Constant propagation of CProverString.setLength() and CProverString.setCharAt() #5134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import org.cprover.CProverString; | ||
|
||
public class Test | ||
{ | ||
public void testSuccess1() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setCharAt(sb, 0, 'd'); | ||
assert sb.toString().equals("dbc"); | ||
} | ||
|
||
public void testSuccess2() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setCharAt(sb, 2, 'd'); | ||
assert sb.toString().equals("abd"); | ||
} | ||
|
||
public void testNoPropagation1() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setCharAt(sb, -1, 'd'); | ||
assert sb.toString().equals("dbc"); | ||
} | ||
|
||
public void testNoPropagation2() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setCharAt(sb, 3, 'd'); | ||
assert sb.toString().equals("dbc"); | ||
} | ||
|
||
public void testNoPropagation3(StringBuffer sb) | ||
{ | ||
CProverString.setCharAt(sb, 1, 'd'); | ||
assert sb.toString().equals("dbc"); | ||
} | ||
|
||
public void testNoPropagation4(int index) | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setCharAt(sb, index, 'd'); | ||
assert sb.toString().equals("dbc"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation1 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation1:()V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation2 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation2:()V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation3 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation3:(Ljava/lang/StringBuffer;)V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation4 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation4:(I)V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import org.cprover.CProverString; | ||
|
||
public class Test | ||
{ | ||
public void testSuccess1() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test setting to same length (i.e. 3 in this case) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
assert sb.toString().equals(""); | ||
} | ||
|
||
public void testSuccess2() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, 2); | ||
assert sb.toString().equals("ab"); | ||
} | ||
|
||
public void testSuccess3() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test extension by more than one char There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
CProverString.setLength(sb, 3); | ||
assert sb.toString().equals("abc"); | ||
} | ||
|
||
public void testSuccess4() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, 4); | ||
assert sb.toString().equals("abc\u0000"); | ||
} | ||
|
||
public void testSuccess5() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, 5); | ||
assert sb.toString().equals("abc\u0000\u0000"); | ||
} | ||
|
||
public void testSuccess6(StringBuffer sb) | ||
{ | ||
CProverString.setLength(sb, 0); | ||
assert sb.toString().equals(""); | ||
} | ||
|
||
public void testNoPropagation1() | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, -1); | ||
assert sb.toString().equals("abc"); | ||
} | ||
|
||
public void testNoPropagation2(StringBuffer sb) | ||
{ | ||
CProverString.setLength(sb, 3); | ||
assert sb.toString().equals("abc"); | ||
} | ||
|
||
public void testNoPropagation3(int newLength) | ||
{ | ||
StringBuffer sb = new StringBuffer("abc"); | ||
CProverString.setLength(sb, newLength); | ||
assert sb.toString().equals("abc"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation1 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation1:()V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation2 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation2:(Ljava/lang/StringBuffer;)V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE symex-driven-lazy-loading-expected-failure | ||
Test.class | ||
--function Test.testNoPropagation3 --show-vcc --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --property 'java::Test.testNoPropagation3:(I)V.assertion.1' | ||
^Generated [0-9]+ VCC\(s\), 1 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess3 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess4 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess5 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
Test.class | ||
--function Test.testSuccess5 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` | ||
^Generated [0-9]+ VCC\(s\), 0 remaining after simplification$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No negative tests? Setting out of range for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not included test cases for the error cases here as those will be handled by the models in the future. I'll add tests for those cases once we have models that use the CProverString primitives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure but we should check that they aren't accidentally const propagated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, added more tests.