Added support for nested lists, and longs in lists.
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
package redis.clients.jedis.tests.commands;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hamcrest.core.CombinableMatcher;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
import static org.hamcrest.CoreMatchers.both;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
|
||||
public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
@@ -57,6 +62,15 @@ public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(new Long(2), response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evalNestedLists() {
|
||||
String script = "return { {KEYS[1]} , {2} }";
|
||||
List<?> results = (List<?>) jedis.eval(script, 1, "key1");
|
||||
|
||||
assertThat((List<String>) results.get(0), listWithItem("key1"));
|
||||
assertThat((List<Long>) results.get(1), listWithItem(2L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evalNoArgs() {
|
||||
String script = "return KEYS[1]";
|
||||
@@ -156,7 +170,10 @@ public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(results.get(1), "key2");
|
||||
assertEquals(results.get(2), "1");
|
||||
assertEquals(results.get(3), "2");
|
||||
|
||||
}
|
||||
|
||||
private <T> CombinableMatcher<List<T>> listWithItem(T expected) {
|
||||
return both(CoreMatchers.<List<T>>instanceOf(List.class)).and(hasItem(equalTo(expected)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user