Skip to content

Commit

Permalink
Cleanup tests (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Weitian Xing <xingweitian@gmail.com>
Co-authored-by: Baorui Zhou <b42zhou@uwaterloo.ca>
Co-authored-by: Jeff Luo <j36luo@uwaterloo.ca>
Co-authored-by: Mier Ta <topnessman@sina.com>
Co-authored-by: Werner Dietl <wdietl@gmail.com>
  • Loading branch information
6 people authored Jan 22, 2022
1 parent 1e566e0 commit e78b5d2
Show file tree
Hide file tree
Showing 41 changed files with 462 additions and 241 deletions.
38 changes: 38 additions & 0 deletions src/test/java/inference/UniverseInferenceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package universe;

import checkers.inference.test.CFInferenceTest;
import org.checkerframework.framework.test.TestUtilities;
import org.checkerframework.javacutil.Pair;
import org.junit.runners.Parameterized.Parameters;
import universe.solver.UniverseSolverEngine;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class UniverseInferenceTest extends CFInferenceTest {

public UniverseInferenceTest(File testFile) {
super(testFile, UniverseInferenceChecker.class, "",
"-Anomsgtext", "-Astubs=src/main/java/universe/jdk.astub", "-d", "testTmp", "-doe");
}

@Override
public Pair<String, List<String>> getSolverNameAndOptions() {
return Pair.of(UniverseSolverEngine.class.getCanonicalName(),
new ArrayList<String>(Arrays.asList("useGraph=false", "collectStatistic=true")));
}

@Override
public boolean useHacks() {
return true;
}

@Parameters
public static List<File> getTestFiles(){
List<File> testfiles = new ArrayList<>();
testfiles.addAll(TestUtilities.findRelativeNestedJavaFiles("tests", "inference"));
return testfiles;
}
}
6 changes: 6 additions & 0 deletions src/test/java/typecheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory contains test drivers for the two type checkers:
- sub-directory `universe_checker` uses the Checker Framework based checker
- sub-directory `universe_inference_checker` uses the Checker Framework Inference based checker.

The test drivers in the two directories execute on the same test files and ensure consistent behavior.
All additions and modifications should be performed to both test drivers.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseCheckerTestsLostNo extends CheckerFrameworkPerDirectoryTest {
public UniverseCheckerTestsLostNo(List <File> testFiles) {
super(testFiles, UniverseChecker.class, "", "-Anomsgtext", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/lostno"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseCheckerTestsLostYes extends CheckerFrameworkPerDirectoryTest {
public UniverseCheckerTestsLostYes(List <File> testFiles) {
super(testFiles, UniverseChecker.class, "", "-Anomsgtext", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/lostyes"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseCheckerTestsStrictPurity extends CheckerFrameworkPerDirectoryTest {
public UniverseCheckerTestsStrictPurity(List <File> testFiles) {
super(testFiles, UniverseChecker.class, "", "-Anomsgtext", "-Alint=checkStrictPurity", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/strictpurity"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseCheckerTestsTopology extends CheckerFrameworkPerDirectoryTest {
public UniverseCheckerTestsTopology(List <File> testFiles) {
super(testFiles, UniverseChecker.class, "", "-Anomsgtext", "-AconservativeUninferredTypeArguments", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/topol"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseInferenceCheckerTestsLostNo extends CheckerFrameworkPerDirectoryTest {
public UniverseInferenceCheckerTestsLostNo(List <File> testFiles) {
super(testFiles, UniverseInferenceChecker.class, "", "-Anomsgtext", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/lostno"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseInferenceCheckerTestsLostYes extends CheckerFrameworkPerDirectoryTest {
public UniverseInferenceCheckerTestsLostYes(List <File> testFiles) {
super(testFiles, UniverseInferenceChecker.class, "", "-Anomsgtext", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/lostyes"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseInferenceCheckerTestsStrictPurity extends CheckerFrameworkPerDirectoryTest {
public UniverseInferenceCheckerTestsStrictPurity(List <File> testFiles) {
super(testFiles, UniverseInferenceChecker.class, "", "-Anomsgtext", "-Alint=checkStrictPurity", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/strictpurity"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package universe;

import java.io.File;
import java.util.List;

import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
import org.junit.runners.Parameterized.Parameters;

public class UniverseInferenceCheckerTestsTopology extends CheckerFrameworkPerDirectoryTest {
public UniverseInferenceCheckerTestsTopology(List <File> testFiles) {
super(testFiles, UniverseInferenceChecker.class, "", "-Anomsgtext", "-AconservativeUninferredTypeArguments", "-d", "testTmp");
}

@Parameters
public static String [] getTestDirs(){
return new String[]{"typecheck/topol"};
}
}
84 changes: 0 additions & 84 deletions src/universe/UniverseTests.java

This file was deleted.

3 changes: 2 additions & 1 deletion tests/inference/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

public class Array {

int @Rep[] pi;
int @Rep[] pi;
// :: fixable-error: (assignment.type.incompatible)
int [] xpi = pi;

}
9 changes: 9 additions & 0 deletions tests/inference/BottomReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import universe.qual.*;

public class BottomReceiver {
void foo(char [] a) {
String s = "Hello";
// :: fixable-error: (assignment.type.incompatible)
a = s.toCharArray();
}
}
16 changes: 9 additions & 7 deletions tests/inference/ConstructorCall.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import universe.qual.*;

class C {
public C(Object o){}
}
public class ConstructorCall {
Object op;
//:: fixable-error: (assignment.type.incompatible)
//:: fixable-error: (argument.type.incompatible)
C c = new @Rep C(op);

class C {
public C(Object o){}
}

void foo(@Peer Object op) {
// :: fixable-error: (argument.type.incompatible)
C c = new @Rep C(op);
}
}
15 changes: 9 additions & 6 deletions tests/inference/FieldAccess.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import universe.qual.*;
class A {
Object o;
}

public class FieldAccess {
A a = new A();
//:: fixable-error: (assignment.type.incompatible)
@Rep Object fo = a.o;

class A {
Object o;
}

void foo(A a) {
// :: fixable-error: (assignment.type.incompatible)
@Rep Object fo = a.o;
}
}
9 changes: 9 additions & 0 deletions tests/inference/InvalidString.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import java.util.Arrays;

public class InvalidString {
void foo() {
throwException("" + Arrays.asList("", ""));
}

void throwException(String s) {}
}
28 changes: 9 additions & 19 deletions tests/inference/Member.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import universe.qual.Self;
import universe.qual.*;
import java.util.List;
class E {
// Type parameter expects @Peer + @Peer Object = @Peer Object
List<Object> le;// If only actual underlying type is the subtype of the declared underlying type, then the qualifier is useless?!
}

public class Member {

E e = new E();
//:: fixable-error: (assignment.type.incompatible)
@Rep List<@Rep Object> l = e.le;

//@Peer List<@Peer Object> l2 = e.le;

/*
@Peer List<@Peer String> ln;
@Peer List<@Any String> ln;
@Peer List<@Rep String> ln2 = ln;*/
/*
@Peer List<@Peer Object> ln;
@Peer List<@Rep Object> ln2 = ln;*/
void foo(E e) {
// :: fixable-error: (assignment.type.incompatible)
@Rep List<@Rep Object> l = e.le;
}

class E {
List<Object> le;
}

}
Loading

0 comments on commit e78b5d2

Please sign in to comment.