public void testDouble() throws Exception {
Collection<RippleList> results;
RippleList stack;
Literal l;
ModelConnection mc = getTestModel().createConnection();
results = reduce("0.0e0");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("0.0", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Leading '-' on exponent.
results = reduce("10E-02");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("0.1", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Leading '+' on exponent.
results = reduce("10.1E+2");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("1010.0", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Extra trailing zeroes are preserved (although according to the XML
// Schema specification, they don't need to be).
results = reduce("0.00e0");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("0.0", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Leading "-" on mantissa
results = reduce("-5e11");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("-5.0E11", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Leading "+" on mantissa
results = reduce("+1.2e1");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("12.0", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
// Leading zeroes
results = reduce("00042E99");
assertEquals(1, results.size());
stack = results.iterator().next();
assertEquals(1, stack.length());
l = (Literal) stack.getFirst().toRDF(mc).sesameValue();
assertEquals("4.2E100", l.getLabel());
assertEquals(XMLSchema.DOUBLE, l.getDatatype());
mc.close();
}