@Ignore @Test public void testReadFromPrintNotation() { evaluateString( "(setq table #s(hash-table test eql rehash-size 1.5 size 65 data (key1 1 2 \"two\") rehash-threshold 0.8))"); LispObject table = evaluateString("table"); LispHashTable expected = new LispHashTable("eql", 65, new LispFloat(0.8), LispSymbol.ourNil, 1.5); expected.put(new LispSymbol("key1"), new LispInteger(1)); expected.put(new LispInteger(2), new LispString("two")); Assert.assertEquals(expected, table); }
@Test public void testHashMapCapacity() { evaluateString("(setq table (make-hash-table :size 1))"); evaluateString("(puthash 'a 1 table)"); LispObject table = evaluateString("table"); LispHashTable expected = new LispHashTable("eql", 1, new LispFloat(0.8), LispSymbol.ourNil, 1.5); expected.put(new LispSymbol("a"), new LispInteger(1)); Assert.assertEquals(expected, table); evaluateString("(puthash 'b 1 table)"); table = evaluateString("table"); expected = new LispHashTable("eql", 2, new LispFloat(0.8), LispSymbol.ourNil, 1.5); expected.put(new LispSymbol("a"), new LispInteger(1)); expected.put(new LispSymbol("b"), new LispInteger(1)); Assert.assertEquals(expected, table); }
@Test public void testMapHash() { evaluateString("(setq table (makehash))"); evaluateString("(puthash 'a 1 table)"); LispObject table = evaluateString("table"); LispHashTable expected = new LispHashTable("eql", 65, new LispFloat(0.8), LispSymbol.ourNil, 1.5); expected.put(new LispSymbol("a"), new LispInteger(1)); Assert.assertEquals(expected, table); evaluateString("(defun f (symbol int) (message \"%s\" symbol) (+ int 1))"); Assert.assertEquals(LispSymbol.ourNil, evaluateString("(maphash 'f table)")); }