Skip to content
Permalink
Browse files
[JENKINS-35294] Test verifying enums with varargs work
  • Loading branch information
abayer committed Sep 14, 2017
1 parent bee837d commit 23cc8e4491a1323299481f1e3298cc9e73ba3678
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java
@@ -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.