Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-35294] Test verifying enums with varargs work
  • Loading branch information
abayer committed Sep 14, 2017
1 parent bee837d commit 23cc8e4
Showing 1 changed file with 30 additions and 0 deletions.
Expand Up @@ -884,4 +884,34 @@ public void newPattern() throws Exception {
public void tildePattern() throws Exception {
assertEvaluate(new GenericWhitelist(), Pattern.class, "def f = ~/f.*/; return f.class");
}

@Issue("JENKINS-35294")
@Test
public void enumWithVarargs() throws Exception {
String script = "enum Thing {\n"
+ " FIRST(\"The first thing\")\n"
+ " String[] descriptions;\n"
+ " public Thing(String... descriptions) {\n"
+ " this.descriptions = descriptions;\n"
+ " }\n"
+ "}\n"
+ "Thing.values()[0].descriptions[0]\n";
String expected = "The first thing";
assertEvaluate(new GenericWhitelist(), expected, script);
}

@Issue("JENKINS-35294")
@Test
public void enumWithStringAndVarargs() throws Exception {
String script = "enum Thing {\n"
+ " FIRST(\"The first thing\")\n"
+ " String description;\n"
+ " public Thing(String description, int... unused) {\n"
+ " this.description = description;\n"
+ " }\n"
+ "}\n"
+ "Thing.values()[0].description\n";
String expected = "The first thing";
assertEvaluate(new GenericWhitelist(), expected, script);
}
}

0 comments on commit 23cc8e4

Please sign in to comment.