@Test
public void testValueOf() throws Exception {

    Value i = this.getLocalValue("i");
    Map<String, Object> options = formatter.getDefaultOptions();
    Value newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());
    options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.HEX);
    newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());
    options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.OCT);
    newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());
    newValue = formatter.valueOf("-12121212", i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "-12121212", newValue.toString());
    newValue = formatter.valueOf("0", i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "0", newValue.toString());
    VirtualMachine vm = getVM();
    newValue = formatter.valueOf("0", vm.mirrorOf(10.0f).type(), options);
    assertNotNull("NumericFormatter should be able to create float by string.", newValue);
    assertTrue("Should create an float value.", newValue instanceof FloatValue);
    assertEquals("Should create an float with right value.", "0.0", newValue.toString());
    newValue = formatter.valueOf("10.0", vm.mirrorOf(10.0).type(), options);
    assertNotNull("NumericFormatter should be able to create double by string.", newValue);
    assertTrue("Should create an double value.", newValue instanceof DoubleValue);
    assertEquals("Should create an double with right value.", "10.0", newValue.toString());
    newValue = formatter.valueOf("10", vm.mirrorOf((short)10).type(), options);
    assertNotNull("NumericFormatter should be able to create short by string.", newValue);
    assertTrue("Should create an short value.", newValue instanceof ShortValue);
    assertEquals("Should create an short with right value.", "10", newValue.toString());
    newValue = formatter.valueOf("10", vm.mirrorOf(10L).type(), options);
    assertNotNull("NumericFormatter should be able to create long by string.", newValue);
    assertTrue("Should create an long value.", newValue instanceof LongValue);
    assertEquals("Should create an long with right value.", "10", newValue.toString());
    newValue = formatter.valueOf("10", vm.mirrorOf((byte) 10).type(), options);
    assertNotNull("NumericFormatter should be able to create byte by string.", newValue);
    assertTrue("Should create an byte value.", newValue instanceof ByteValue);
    assertEquals("Should create an byte with right value.", "10", newValue.toString());
}