Skip to content
Permalink
Browse files
Use varargs.
  • Loading branch information
garydgregory committed Feb 28, 2021
1 parent 1b4e61a commit 3d4cb92cfef99b340ab2d59d9fb2d0059c58dbe1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
@@ -69,7 +69,7 @@ public void testForEachWithArray() throws Exception {
public void testForEachWithCollection() throws Exception {
final JexlScript e = JEXL.createScript("for(var item : list) item");
final JexlContext jc = new MapContext();
jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}));
jc.set("list", Arrays.asList("Hello", "World"));
final Object o = e.execute(jc);
Assert.assertEquals("Result is not last evaluated expression", "World", o);
}
@@ -87,7 +87,7 @@ public void testForEachWithEnumeration() throws Exception {
public void testForEachWithIterator() throws Exception {
final JexlScript e = JEXL.createScript("for(var item : list) item");
final JexlContext jc = new MapContext();
jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}).iterator());
jc.set("list", Arrays.asList("Hello", "World").iterator());
final Object o = e.execute(jc);
Assert.assertEquals("Result is not last evaluated expression", "World", o);
}
@@ -62,15 +62,11 @@ public JXLTTest(final JexlBuilder builder) {
public static List<JexlBuilder> engines() {
final JexlFeatures f = new JexlFeatures();
f.lexical(true).lexicalShade(true);
return Arrays.<JexlBuilder>asList(new JexlBuilder[] {
new JexlBuilder().silent(false)
.lexical(true).lexicalShade(true)
.cache(128).strict(true),
new JexlBuilder().features(f).silent(false)
.cache(128).strict(true),
new JexlBuilder().silent(false)
.cache(128).strict(true),
});
return Arrays.<JexlBuilder>asList(new JexlBuilder().silent(false)
.lexical(true).lexicalShade(true)
.cache(128).strict(true), new JexlBuilder().features(f).silent(false)
.cache(128).strict(true), new JexlBuilder().silent(false)
.cache(128).strict(true));
}

@Before
@@ -90,7 +90,7 @@ public void testScriptFromFile() throws Exception {
@Test
public void testArgScriptFromFile() throws Exception {
final File testScript = new File(TEST_ADD);
final JexlScript s = JEXL.createScript(testScript,new String[]{"x","y"});
final JexlScript s = JEXL.createScript(testScript,"x", "y");
final JexlContext jc = new MapContext();
jc.set("out", System.out);
final Object result = s.execute(jc, 13, 29);
@@ -112,7 +112,7 @@ public void testScriptFromURL() throws Exception {
@Test
public void testArgScriptFromURL() throws Exception {
final URL testUrl = new File(TEST_ADD).toURI().toURL();
final JexlScript s = JEXL.createScript(testUrl,new String[]{"x","y"});
final JexlScript s = JEXL.createScript(testUrl,"x", "y");
final JexlContext jc = new MapContext();
jc.set("out", System.out);
final Object result = s.execute(jc, 13, 29);
@@ -49,8 +49,8 @@ public void testScriptEngineFactory() throws Exception {
Assert.assertEquals(EXTENSIONS, factory.getExtensions());
Assert.assertEquals(MIMES, factory.getMimeTypes());

Assert.assertEquals("42;", factory.getProgram(new String[]{"42"}));
Assert.assertEquals("str.substring(3,4)", factory.getMethodCallSyntax("str", "substring", new String[]{"3", "4"}));
Assert.assertEquals("42;", factory.getProgram("42"));
Assert.assertEquals("str.substring(3,4)", factory.getMethodCallSyntax("str", "substring", "3", "4"));
}

@Test

0 comments on commit 3d4cb92

Please sign in to comment.