Search in sources :

Example 1 with APersistentSet

use of clojure.lang.APersistentSet in project enumerable by hraberg.

the class ClojureTest method creatingPersistentCollections.

@Test
public void creatingPersistentCollections() throws Exception {
    APersistentVector vector = (APersistentVector) vec(list("hello", "world"));
    assertEquals("hello", vector.invoke(0));
    assertEquals("world", vector.invoke(1));
    assertEquals("[\"hello\" \"world\"]", vector.toString());
    APersistentSet set = (APersistentSet) set(list("hello", "world"));
    assertEquals("hello", set.invoke("hello"));
    assertEquals("world", set.invoke("world"));
    assertEquals("#{\"hello\" \"world\"}", set.toString());
    APersistentMap map = (APersistentMap) zipmap(list("hello", "world"), list(1, 2));
    assertEquals(1, map.invoke("hello"));
    assertEquals(2, map.invoke("world"));
    assertEquals("{\"world\" 2, \"hello\" 1}", map.toString());
}
Also used : APersistentVector(clojure.lang.APersistentVector) APersistentMap(clojure.lang.APersistentMap) APersistentSet(clojure.lang.APersistentSet) GroovyTest(org.enumerable.lambda.support.groovy.GroovyTest) ScalaTest(org.enumerable.lambda.support.scala.ScalaTest) JRubyTest(org.enumerable.lambda.support.jruby.JRubyTest) Test(org.junit.Test) JavaScriptTest(org.enumerable.lambda.support.javascript.JavaScriptTest)

Aggregations

APersistentMap (clojure.lang.APersistentMap)1 APersistentSet (clojure.lang.APersistentSet)1 APersistentVector (clojure.lang.APersistentVector)1 GroovyTest (org.enumerable.lambda.support.groovy.GroovyTest)1 JavaScriptTest (org.enumerable.lambda.support.javascript.JavaScriptTest)1 JRubyTest (org.enumerable.lambda.support.jruby.JRubyTest)1 ScalaTest (org.enumerable.lambda.support.scala.ScalaTest)1 Test (org.junit.Test)1