aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-06 13:26:37 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-06 13:26:37 +0000
commitaba89055c42fbef162b5c01e7fe4c53a8402e6bc (patch)
tree0235e2973339fa1d4def1e2dde7bebc106747c1c
parent06e8060e71c96f28b45057b7c8ee8078552730da (diff)
Add JavaToCsharpTests with some tests disabled
-rw-r--r--src/main/java/org/zwobble/couscous/backends/csharp/CsharpSerializer.java2
-rw-r--r--src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpMethodRunner.java2
-rw-r--r--src/test/java/org/zwobble/couscous/tests/backends/csharp/JavaToCsharpTests.java83
3 files changed, 85 insertions, 2 deletions
diff --git a/src/main/java/org/zwobble/couscous/backends/csharp/CsharpSerializer.java b/src/main/java/org/zwobble/couscous/backends/csharp/CsharpSerializer.java
index e47b732..a6bcfc9 100644
--- a/src/main/java/org/zwobble/couscous/backends/csharp/CsharpSerializer.java
+++ b/src/main/java/org/zwobble/couscous/backends/csharp/CsharpSerializer.java
@@ -155,7 +155,7 @@ public class CsharpSerializer implements NodeVisitor {
@Override
public void visit(TypeCoercionNode typeCoercion) {
- throw new UnsupportedOperationException();
+ write(typeCoercion.getExpression());
}
@Override
diff --git a/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpMethodRunner.java b/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpMethodRunner.java
index 90f5a2a..651e50b 100644
--- a/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpMethodRunner.java
+++ b/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpMethodRunner.java
@@ -53,7 +53,7 @@ public class CsharpMethodRunner implements MethodRunner {
}
}
- private static PrimitiveValue runFunction(
+ public static PrimitiveValue runFunction(
Path directoryPath,
TypeName className,
String methodName,
diff --git a/src/test/java/org/zwobble/couscous/tests/backends/csharp/JavaToCsharpTests.java b/src/test/java/org/zwobble/couscous/tests/backends/csharp/JavaToCsharpTests.java
new file mode 100644
index 0000000..aeaa6ad
--- /dev/null
+++ b/src/test/java/org/zwobble/couscous/tests/backends/csharp/JavaToCsharpTests.java
@@ -0,0 +1,83 @@
+package org.zwobble.couscous.tests.backends.csharp;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.zwobble.couscous.CouscousCompiler;
+import org.zwobble.couscous.ast.TypeName;
+import org.zwobble.couscous.backends.csharp.CsharpBackend;
+import org.zwobble.couscous.frontends.java.JavaFrontend;
+import org.zwobble.couscous.tests.CompilerTests;
+import org.zwobble.couscous.values.PrimitiveValue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import static org.zwobble.couscous.tests.util.ExtraFiles.deleteRecursively;
+import static org.zwobble.couscous.util.ExtraLists.list;
+
+public class JavaToCsharpTests extends CompilerTests {
+ @Test
+ @Ignore
+ public void integersCanBeAssignedToObjectVariable() {
+ }
+
+ @Test
+ @Ignore
+ public void anonymousClassesWithoutCapture() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void anonymousClassesWithCapture() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void lambdasWithoutCapture() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void lambdasWithCapture() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void lambdasWithThisCapture() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void staticMethodOverloads() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void stringToLowerCase() throws Exception {
+ }
+
+ @Test
+ @Ignore
+ public void stringEquals() throws Exception {
+ }
+
+ protected PrimitiveValue execProgram(
+ Path directory,
+ TypeName type,
+ String methodName,
+ List<PrimitiveValue> arguments) throws IOException, InterruptedException
+ {
+ Path directoryPath = Files.createTempDirectory(null);
+ try {
+ CouscousCompiler compiler = new CouscousCompiler(
+ new JavaFrontend(),
+ new CsharpBackend(directoryPath, "Couscous"));
+ compiler.compileDirectory(list(directory), directory);
+ return CsharpMethodRunner.runFunction(directoryPath, type, methodName, arguments, false);
+ } finally {
+ deleteRecursively(directoryPath.toFile());
+ }
+ }
+}