diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-03-09 18:11:17 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-03-09 18:11:17 +0000 |
| commit | 20dc1e124d606cf4298d5112b6d3c4f6c74e9b68 (patch) | |
| tree | 47914e8b0356b2f40e3723eae650d3bb6f100dd4 /src/test/java/org/zwobble/couscous/tests/backends/python | |
| parent | 8ac6cb16b727b5e3d28ab89fee1d169a4f74d9a1 (diff) | |
Introduce Type interface
Diffstat (limited to 'src/test/java/org/zwobble/couscous/tests/backends/python')
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/backends/python/PythonMethodRunner.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/backends/python/PythonMethodRunner.java b/src/test/java/org/zwobble/couscous/tests/backends/python/PythonMethodRunner.java index 2b0d2ce..ce91549 100644 --- a/src/test/java/org/zwobble/couscous/tests/backends/python/PythonMethodRunner.java +++ b/src/test/java/org/zwobble/couscous/tests/backends/python/PythonMethodRunner.java @@ -3,8 +3,9 @@ package org.zwobble.couscous.tests.backends.python; import com.google.common.base.Joiner; import org.hamcrest.Matchers; import org.zwobble.couscous.ast.MethodSignature; -import org.zwobble.couscous.ast.TypeName; +import org.zwobble.couscous.ast.types.ScalarType; import org.zwobble.couscous.ast.TypeNode; +import org.zwobble.couscous.ast.types.Type; import org.zwobble.couscous.backends.Names; import org.zwobble.couscous.backends.python.PythonBackend; import org.zwobble.couscous.backends.python.PythonCodeGenerator; @@ -28,7 +29,7 @@ import static org.zwobble.couscous.values.PrimitiveValues.value; public class PythonMethodRunner implements MethodRunner { @Override - public PrimitiveValue runMethod(List<TypeNode> classNodes, TypeName className, String methodName, List<PrimitiveValue> arguments, TypeName returnType) { + public PrimitiveValue runMethod(List<TypeNode> classNodes, ScalarType className, String methodName, List<PrimitiveValue> arguments, Type returnType) { try { Path directoryPath = Files.createTempDirectory(null); PythonBackend compiler = new PythonBackend(directoryPath, "couscous"); @@ -45,10 +46,10 @@ public class PythonMethodRunner implements MethodRunner { public static PrimitiveValue runFunction( Path directoryPath, - TypeName className, + ScalarType className, String methodName, List<PrimitiveValue> arguments, - TypeName returnType) + Type returnType) throws IOException, InterruptedException { String argumentsString = Joiner.on(", ").join(arguments.stream().map(PythonCodeGenerator::generateCode).map(PythonSerializer::serialize).iterator()); @@ -82,7 +83,7 @@ public class PythonMethodRunner implements MethodRunner { case "<class 'type'>": String typeName = value.substring(value.indexOf("'") + 1, value.lastIndexOf("'")); assertThat(typeName, Matchers.startsWith(PACKAGE_PREFIX)); - return value(TypeName.of(typeName.substring(PACKAGE_PREFIX.length(), typeName.lastIndexOf(".")))); + return value(ScalarType.of(typeName.substring(PACKAGE_PREFIX.length(), typeName.lastIndexOf(".")))); default: throw new RuntimeException("Unhandled type: " + type); } |
