### Question:
NameParser { static List<Object> parseFunction(String string) { Matcher matcher = functionAndParameter.matcher(string); if (matcher.matches()) { List<Object> parameters = new ArrayList<Object>(); parameters.add(matcher.group(1)); parameters.addAll(parseParameters(matcher.group(3))); return parameters; } matcher = functionAndStringParameter.matcher(string); if (matcher.matches()) { List<Object> parameters = new ArrayList<Object>(); parameters.add(matcher.group(1)); String quotedString = matcher.group(3); parameters.add(quotedString.substring(1, quotedString.length() - 1)); return parameters; } throw new IllegalArgumentException("Syntax error: function should be like xxx(num1, num2, ...) or xxx(\"string\") and was " + string); }    }### Answer:
@Test(expected=IllegalArgumentException.class) public void testError4() { NameParser.parseFunction("test(1.0 2.0)"); }
@Test(expected=IllegalArgumentException.class) public void testError5() { NameParser.parseFunction("test(1.O)"); }
@Test(expected=IllegalArgumentException.class) public void testError6() { NameParser.parseFunction("test(1.1.2)"); }
@Test(expected=IllegalArgumentException.class) public void testError7() { NameParser.parseFunction("test1.2"); }
@Test public void testParsing() { List<Object> parameters = NameParser.parseFunction("sine(1.0,2.0)"); assertThat(parameters, equalTo(Arrays.asList((Object) "sine", 1.0, 2.0))); parameters = NameParser.parseFunction("ramp(-1,.5, 23.25)"); assertThat(parameters, equalTo(Arrays.asList((Object) "ramp", -1.0, 0.5, 23.25))); parameters = NameParser.parseFunction("replay(\"test.xml\")"); assertThat(parameters, equalTo(Arrays.asList((Object) "replay", "test.xml"))); }