guilleiguaran/fakeredis — pull request #60 by skwp (2013-05-30 21:51:18+00:00)
Title: Support for ltrim with negative start (max set size)

Adds support for ltrim with negative offset to behave correctly. This is used for example by redis-objects in their List maxlength implementation.

Redis's correct behavior using ltrim with negative offset is like this:
```
redis.rpush "mylist", "firstitem"
redis.lrange "mylist", 0, -1 == ["firstitem"] # returns the first item
redis.ltrim "mylist", -5, -1 # this truncates the list to a max of 5 items from the right side
redis.lrange "mylist", 0, -1 == ["firstitem"] # nothing should happen to the list
```

The pull request includes specs that demonstrate the correct behavior both for lists smaller than the negative start, and larger. If the list is larger, fakeredis correctly trims it. However if the list is smaller, fakeredis incorrectly returns zero items instead of returning the smaller list.