Skip to content

Commit

Permalink
Multiple input test files (#258)
Browse files Browse the repository at this point in the history
* Initial infrastructure to deal with multiple input test files.

* Simply copy testSameFileSameName() tests.

Put them in different files.

* Make variable final.

* Add test case with class with same name.

* More tests.

* Test varying hybridizations.

* Reuse ctor.

* Test varying tensor parameterization.

* Change the way we find FUTs.

* Fix spelling.

* Test normal functions with same attributes.

* Test normal functions with different attributes.

* Add containing module name to FUT.

* More tests with varying attributes.

* Ensure the FUT is non-null.

Not sure if this will appease the CI or not.
  • Loading branch information
khatchad authored Sep 7, 2023
1 parent 53f7b55 commit b61023a
Show file tree
Hide file tree
Showing 33 changed files with 501 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ public argumentsType getParameters() {
return getFunctionDefinition().getFunctionDef().args;
}

public int getNumberOfParameters() {
return getFunctionDefinition().getFunctionDef().args.args.length;
}

public RefactoringStatus getStatus() {
return this.status;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test:

def b(self):
pass


if __name__ == '__main__':
Test().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test2:

def b(self):
pass


if __name__ == '__main__':
Test2().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tensorflow as tf


@tf.function
def b(a):
pass


if __name__ == '__main__':
b(tf.ones([1, 2]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tensorflow as tf


@tf.function
def b(a):
pass


if __name__ == '__main__':
b(5)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def b():
pass


if __name__ == '__main__':
b()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def b():
pass


if __name__ == '__main__':
b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test:

def b(self):
pass


if __name__ == '__main__':
Test().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test:

def b(self):
pass


if __name__ == '__main__':
Test().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test:

@tf.function
def b(self):
pass


if __name__ == '__main__':
Test().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test2:

@tf.function
def b(self):
pass


if __name__ == '__main__':
Test2().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test:

@tf.function
def b(self, a):
pass


if __name__ == '__main__':
Test().b(tf.ones([1, 2]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test2:

@tf.function
def b(self, a):
pass


if __name__ == '__main__':
Test2().b(tf.ones([1, 2]))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test:

@tf.function
def b(self):
pass


if __name__ == '__main__':
Test().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Test2:

def b(self):
pass


if __name__ == '__main__':
Test2().b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test:

@tf.function
def b(self, a):
pass


if __name__ == '__main__':
Test().b(tf.ones([1, 2]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf


class Test2:

@tf.function
def b(self, a):
pass


if __name__ == '__main__':
Test2().b(5)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tensorflow as tf


@tf.function
def b(a):
pass


if __name__ == '__main__':
b(5)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tensorflow as tf


@tf.function
def b():
pass


if __name__ == '__main__':
b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tensorflow as tf


@tf.function
def b(a):
pass


if __name__ == '__main__':
b(5)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def b():
pass


if __name__ == '__main__':
b()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public class FunctionUnderTest {
private String name;

/**
* The names of the parameteres of this function under test.
* The name of the containing module.
*/
private String moduleName;

/**
* The names of the parameters of this function under test.
*/
private List<String> parameters = new ArrayList<>();

Expand All @@ -37,6 +42,11 @@ public class FunctionUnderTest {
*/
private boolean hybrid;

/**
* True iff this {@link FunctionUnderTest} likely has a tensor parameter.
*/
private boolean likelyHasTensorParameter;

public FunctionUnderTest(String name) {
this.name = name;
}
Expand All @@ -47,10 +57,26 @@ public FunctionUnderTest(String name, boolean hybrid) {
}

public FunctionUnderTest(String name, String... parameters) {
this.name = name;
this(name);
this.addParameters(parameters);
}

public FunctionUnderTest(String name, boolean hybrid, String... parameters) {
this(name, hybrid);
this.addParameters(parameters);
}

public FunctionUnderTest(String name, boolean hybrid, boolean likelyHasTensorParameter, String... parameters) {
this(name, hybrid, parameters);
this.likelyHasTensorParameter = likelyHasTensorParameter;
}

public FunctionUnderTest(String name, String moduleName, boolean hybrid, boolean likelyHasTensorParameter, String... parameters) {
this(name, hybrid, parameters);
this.moduleName = moduleName;
this.likelyHasTensorParameter = likelyHasTensorParameter;
}

public boolean addParameters(String... parameters) {
return this.parameters.addAll(Arrays.asList(parameters));
}
Expand All @@ -59,6 +85,10 @@ public String getName() {
return name;
}

public String getModuleName() {
return this.moduleName;
}

public List<String> getParameters() {
return Collections.unmodifiableList(parameters);
}
Expand All @@ -67,9 +97,13 @@ public boolean isHybrid() {
return hybrid;
}

public boolean getLikelyHasTensorParameter() {
return likelyHasTensorParameter;
}

@Override
public int hashCode() {
return Objects.hash(name, parameters, hybrid);
return Objects.hash(name, moduleName, parameters, hybrid, likelyHasTensorParameter);
}

@Override
Expand All @@ -81,7 +115,9 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
FunctionUnderTest other = (FunctionUnderTest) obj;
return Objects.equals(name, other.name) && Objects.equals(parameters, other.parameters) && Objects.equals(hybrid, other.hybrid);
return Objects.equals(name, other.name) && Objects.equals(moduleName, other.moduleName)
&& Objects.equals(parameters, other.parameters) && Objects.equals(hybrid, other.hybrid)
&& Objects.equals(likelyHasTensorParameter, other.likelyHasTensorParameter);
}

/**
Expand Down
Loading

0 comments on commit b61023a

Please sign in to comment.