mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-02-11 03:30:00 +00:00
Added support for negative numbers
This commit is contained in:
parent
2483dc48ae
commit
4473418a72
2 changed files with 15 additions and 1 deletions
|
@ -77,7 +77,7 @@ class TomlParser extends BaseParser<Object> {
|
|||
}
|
||||
|
||||
Rule NumberValue() {
|
||||
return Sequence(OneOrMore(FirstOf(Digit(), '.')), pushNumber(match()));
|
||||
return Sequence(Sequence(Optional('-'), OneOrMore(FirstOf(Digit(), '.'))), pushNumber(match()));
|
||||
}
|
||||
|
||||
Rule StringValue() {
|
||||
|
|
|
@ -29,6 +29,13 @@ public class TomlTest {
|
|||
assertEquals(1001, toml.getLong("b").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_get_negative_number() throws Exception {
|
||||
Toml toml = new Toml().parse("b = -1001");
|
||||
|
||||
assertEquals(-1001, toml.getLong("b").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_get_list() throws Exception {
|
||||
Toml toml = new Toml().parse("list = [\"a\", \"b\", \"c\"]");
|
||||
|
@ -63,6 +70,13 @@ public class TomlTest {
|
|||
assertEquals(5.25D, toml.getDouble("double").doubleValue(), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_get_negative_double() throws Exception {
|
||||
Toml toml = new Toml().parse("double = -5.25");
|
||||
|
||||
assertEquals(-5.25D, toml.getDouble("double").doubleValue(), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_get_key_group() throws Exception {
|
||||
Toml toml = new Toml().parse("[group]\nkey = \"value\"");
|
||||
|
|
Loading…
Reference in a new issue