aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpSerializerTests.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpSerializerTests.java b/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpSerializerTests.java
index b16c6b5..781d00a 100644
--- a/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpSerializerTests.java
+++ b/src/test/java/org/zwobble/couscous/tests/backends/csharp/CsharpSerializerTests.java
@@ -57,6 +57,18 @@ public class CsharpSerializerTests {
}
@Test
+ public void typeLiteralUsesAtSymbolToEscapeReservedIdentifiers() {
+ String output = serialize(literal(ScalarType.of("internal")));
+ assertEquals("typeof(@internal)", output);
+ }
+
+ @Test
+ public void typeLiteralDoesntUseAtSymbolForReservedTypeIdentifiers() {
+ String output = serialize(literal(ScalarType.of("string")));
+ assertEquals("typeof(string)", output);
+ }
+
+ @Test
public void variableReferenceWritesIdentifier() {
String output = serialize(reference(var(TestIds.ANY_ID, "x", ScalarType.of("X"))));
assertEquals("x", output);
@@ -305,6 +317,26 @@ public class CsharpSerializerTests {
}
@Test
+ public void namespacePartsInNamespaceDeclarationAreMangledInIfReserved() {
+ ClassNode classNode = ClassNode.builder("com.example.internal.Example")
+ .build();
+
+ String output = serialize(classNode);
+
+ assertEquals("namespace com.example.@internal {\n internal class Example {\n }\n}\n", output);
+ }
+
+ @Test
+ public void namespacePartsInNamespaceReferenceAreMangledInIfReserved() {
+ String output = serialize(localVariableDeclaration(
+ TestIds.ANY_ID,
+ "x",
+ ScalarType.of("com.example.internal.Example"),
+ literal("[value]")));
+ assertEquals("com.example.@internal.Example x = \"[value]\";\n", output);
+ }
+
+ @Test
public void classWithTypeParameters() {
ClassNode classNode = ClassNode.builder("com.example.Example")
.addTypeParameter("T")