jline/jline2 — pull request #66 by artloder (2012-12-13 05:12:19+00:00)
Title: Issue-65: fix to ConsoleReader.expandEvents for numeric expansion.

I'm also adding a ConsolerReaderTest.testNumericExpansions test method that validates the edge cases missed in the current implementation. To see the tests that are failing given the current implementation, see below:

```javascript
@Test
public void testNumericExpansions() throws Exception {
ConsoleReader reader = new ConsoleReader();
MemoryHistory history = new MemoryHistory();
history.setMaxSize(3);

// Seed history with three entries:
// 1 history1
// 2 history2
// 3 history3
history.add("history1");
history.add("history2");
history.add("history3");
reader.setHistory(history);

// Validate !n
assertExpansionIllegalArgumentException(reader, "!0"); // fail
assertEquals("history1", reader.expandEvents("!1")); // fail
assertEquals("history2", reader.expandEvents("!2")); // fail
assertEquals("history3", reader.expandEvents("!3")); // fail
assertExpansionIllegalArgumentException(reader, "!4");

// Validate !-n
assertExpansionIllegalArgumentException(reader, "!-0"); // fail
assertEquals("history3", reader.expandEvents("!-1"));
assertEquals("history2", reader.expandEvents("!-2"));
assertEquals("history1", reader.expandEvents("!-3")); // fail
assertExpansionIllegalArgumentException(reader, "!-4");

// Validate !!
assertEquals("history3", reader.expandEvents("!!"));

// Add two new entries. Because maxSize=3, history is:
// 3 history3
// 4 history4
// 5 history5
history.add("history4");
history.add("history5");

// Validate !n
assertExpansionIllegalArgumentException(reader, "!0");
assertExpansionIllegalArgumentException(reader, "!1");
assertExpansionIllegalArgumentException(reader, "!2"); // fail
assertEquals("history3", reader.expandEvents("!3")); // fail
assertEquals("history4", reader.expandEvents("!4")); // fail
assertEquals("history5", reader.expandEvents("!5")); // fail
assertExpansionIllegalArgumentException(reader, "!6");

// Validate !-n
assertExpansionIllegalArgumentException(reader, "!-0"); // fail
assertEquals("history5", reader.expandEvents("!-1"));
assertEquals("history4", reader.expandEvents("!-2"));
assertEquals("history3", reader.expandEvents("!-3")); // fail
assertExpansionIllegalArgumentException(reader, "!-4");

// Validate !!
assertEquals("history5", reader.expandEvents("!!"));
}