[purity] Rename tests

Summary:
Consistent renaming of tests: replace
- `bad` -> `impure`
- `ok` -> `pure`

Reviewed By: mbouaziz

Differential Revision: D15536214

fbshipit-source-id: eab8b1cc3
master
Ezgi Çiçek 6 years ago committed by Facebook Github Bot
parent a01a4a3658
commit c14b917e7f

@ -12,7 +12,7 @@ class GlobalTest {
int x = 0; int x = 0;
// modifies global var 's' hence impure // modifies global var 's' hence impure
void set_bad() { void set_impure() {
s = 10; s = 10;
} }
} }
@ -22,20 +22,20 @@ class GlobalTest {
} }
// calls foo which modifies global var // calls foo which modifies global var
void call_set_bad() { void call_set_impure() {
Foo f = new Foo(); Foo f = new Foo();
f.set_bad(); f.set_impure();
} }
// foo is global which is modified by incr. // foo is global which is modified by incr.
void global_mod_via_argument_passing_bad(int size, Foo f) { void global_mod_via_argument_passing_impure(int size, Foo f) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
incr(foo, i); incr(foo, i);
} }
} }
// aliased_foo is aliasing a global and then is modified by incr. // aliased_foo is aliasing a global and then is modified by incr.
void global_mod_via_argument_passing_bad_aliased(int size, Foo f) { void global_mod_via_argument_passing_impure_aliased(int size, Foo f) {
Foo aliased_foo = foo; // Inferbo can't recognize aliasing here Foo aliased_foo = foo; // Inferbo can't recognize aliasing here
// and assumes aliased_foo is in [-oo,+oo] not in foo // and assumes aliased_foo is in [-oo,+oo] not in foo
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {

@ -15,64 +15,64 @@ class Test {
global_arr = new Integer[size]; global_arr = new Integer[size];
} }
void set_bad(int x, int y) { void set_impure(int x, int y) {
a = x + y; a = x + y;
} }
void global_array_set_bad(int x, int y) { void global_array_set_impure(int x, int y) {
global_arr[0] = x + y; global_arr[0] = x + y;
} }
int local_write_ok(int x, int y) { int local_write_pure(int x, int y) {
int k = x + y; int k = x + y;
k++; k++;
return k; return k;
} }
void call_pure_ok(int size) { void call_pure_pure(int size) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
local_write_ok(i, size); local_write_pure(i, size);
} }
} }
void call_impure_bad(int size) { void call_impure_impure(int size) {
int d = 0; int d = 0;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
set_bad(i, size); set_impure(i, size);
} }
} }
// no change to outside state, the local allocation is ok. // no change to outside state, the local allocation is ok.
int local_alloc_ok(int x, int y) { int local_alloc_pure(int x, int y) {
ArrayList<Integer> list = new ArrayList<Integer>(x + y); ArrayList<Integer> list = new ArrayList<Integer>(x + y);
for (Integer el : list) { for (Integer el : list) {
call_pure_ok(el); call_pure_pure(el);
} }
return list.size(); return list.size();
} }
void parameter_field_write_bad(Test test, boolean b) { void parameter_field_write_impure(Test test, boolean b) {
int c = b ? 0 : 1; int c = b ? 0 : 1;
test.a = c; test.a = c;
} }
int parameter_field_access_ok(Test test) { int parameter_field_access_pure(Test test) {
return test.a; return test.a;
} }
// expected to be impure since y points to x // expected to be impure since y points to x
void local_field_write_bad(Test x) { void local_field_write_impure(Test x) {
Test y = x; Test y = x;
y.a = 0; y.a = 0;
} }
void swap_bad(int[] array, int i, int j) { void swap_impure(int[] array, int i, int j) {
int tmp = array[i]; int tmp = array[i];
array[i] = array[j]; array[i] = array[j];
array[j] = tmp; array[j] = tmp;
} }
void alias_bad(int[] array, int i, int j) { void alias_impure(int[] array, int i, int j) {
int[] a = array; int[] a = array;
a[j] = i; a[j] = i;
} }
@ -80,12 +80,12 @@ class Test {
// Currently, we can't distinguish between returning new Objects or // Currently, we can't distinguish between returning new Objects or
// creating new Objects locally. Ideally, the latter should be fine // creating new Objects locally. Ideally, the latter should be fine
// as long as it doesn't leak to the result. // as long as it doesn't leak to the result.
public ArrayList<Integer> emptyList_bad_FP() { public ArrayList<Integer> emptyList_impure_FP() {
return new ArrayList<Integer>(); return new ArrayList<Integer>();
} }
// All unmodeled calls will be marked as modifying global state // All unmodeled calls will be marked as modifying global state
static long systemNanoTime_bad() { static long systemNanoTime_impure() {
return System.nanoTime(); return System.nanoTime();
} }
} }

@ -5,8 +5,8 @@ codetoanalyze/java/purity/Localities.java, Localities.length_pure(java.util.Arra
codetoanalyze/java/purity/Localities.java, Localities.mkHC_pure(Localities$Counter):Localities$HasCounter, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function Localities$HasCounter Localities.mkHC_pure(Localities$Counter)] codetoanalyze/java/purity/Localities.java, Localities.mkHC_pure(Localities$Counter):Localities$HasCounter, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function Localities$HasCounter Localities.mkHC_pure(Localities$Counter)]
codetoanalyze/java/purity/Localities.java, Localities.setFreshArrayEntry_pure(int,int):int[], 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int[] Localities.setFreshArrayEntry_pure(int,int)] codetoanalyze/java/purity/Localities.java, Localities.setFreshArrayEntry_pure(int,int):int[], 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int[] Localities.setFreshArrayEntry_pure(int,int)]
codetoanalyze/java/purity/PurityModeled.java, PurityModeled.arraycopy_pure(int[]):void, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function void PurityModeled.arraycopy_pure(int[])] codetoanalyze/java/purity/PurityModeled.java, PurityModeled.arraycopy_pure(int[]):void, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function void PurityModeled.arraycopy_pure(int[])]
codetoanalyze/java/purity/Test.java, Test.call_pure_ok(int):void, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function void Test.call_pure_ok(int)] codetoanalyze/java/purity/Test.java, Test.call_pure_pure(int):void, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function void Test.call_pure_pure(int)]
codetoanalyze/java/purity/Test.java, Test.emptyList_bad_FP():java.util.ArrayList, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function ArrayList Test.emptyList_bad_FP()] codetoanalyze/java/purity/Test.java, Test.emptyList_impure_FP():java.util.ArrayList, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function ArrayList Test.emptyList_impure_FP()]
codetoanalyze/java/purity/Test.java, Test.local_alloc_ok(int,int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.local_alloc_ok(int,int)] codetoanalyze/java/purity/Test.java, Test.local_alloc_pure(int,int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.local_alloc_pure(int,int)]
codetoanalyze/java/purity/Test.java, Test.local_write_ok(int,int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.local_write_ok(int,int)] codetoanalyze/java/purity/Test.java, Test.local_write_pure(int,int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.local_write_pure(int,int)]
codetoanalyze/java/purity/Test.java, Test.parameter_field_access_ok(Test):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.parameter_field_access_ok(Test)] codetoanalyze/java/purity/Test.java, Test.parameter_field_access_pure(Test):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int Test.parameter_field_access_pure(Test)]

Loading…
Cancel
Save