aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-31 18:39:27 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-31 18:39:27 +0100
commit157aa4fbc6447900c33f668ccaf6de46632e6b5c (patch)
tree8cbabe96589af343a3e0390c3a11f37d4b7e05c1 /src/test/java/org/zwobble
parentb70f8de0df87a24982aa309427fe257efe4d55ed (diff)
Extract MAIN_IDENTIFIER in tests
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/couscous/tests/frontends/java/JavaReaderTests.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/frontends/java/JavaReaderTests.java b/src/test/java/org/zwobble/couscous/tests/frontends/java/JavaReaderTests.java
index 4308be7..c7ad81d 100644
--- a/src/test/java/org/zwobble/couscous/tests/frontends/java/JavaReaderTests.java
+++ b/src/test/java/org/zwobble/couscous/tests/frontends/java/JavaReaderTests.java
@@ -41,6 +41,8 @@ import static org.zwobble.couscous.util.ExtraLists.list;
import static org.zwobble.couscous.util.ExtraSets.set;
public class JavaReaderTests {
+ private static final Identifier MAIN_IDENTIFIER = Identifier.TOP.type("com.example.Example").method("main");
+
@Test
public void canReadReturnWithoutValue() {
StatementNode statement = readStatement("void", "return;");
@@ -184,12 +186,12 @@ public class JavaReaderTests {
.addVariable("iterable", "java.lang.Iterable<String>")
.readStatement("for (String x : iterable) { return x; } return \"\";");
- VariableDeclaration expectedTarget = var(Identifier.TOP.type("com.example.Example").method("main").variable("x"), "x", Types.STRING);
+ VariableDeclaration expectedTarget = var(MAIN_IDENTIFIER.variable("x"), "x", Types.STRING);
assertEquals(
list(
new ForEachNode(
expectedTarget,
- reference(var(Identifier.TOP.type("com.example.Example").method("main").variable("iterable"), "iterable", JavaTypes.iterable(Types.STRING))),
+ reference(var(MAIN_IDENTIFIER.variable("iterable"), "iterable", JavaTypes.iterable(Types.STRING))),
list(returns(reference(expectedTarget)))
),
returns(literal(""))
@@ -235,7 +237,7 @@ public class JavaReaderTests {
@Test
public void canReadTryWithResourceWithoutOtherClauses() {
ScalarType type = ScalarType.of("java.io.ByteArrayOutputStream");
- Identifier identifier = Identifier.TOP.type("com.example.Example").method("main").variable("closeable");
+ Identifier identifier = MAIN_IDENTIFIER.variable("closeable");
LocalVariableDeclarationNode expectedResource = localVariableDeclaration(identifier, "closeable", type, constructorCall(type, list()));
assertThat(
readStatements("int", "try(java.io.ByteArrayOutputStream closeable = new java.io.ByteArrayOutputStream()) { return 1; }"),