Remove Locator class

This commit is contained in:
serso
2016-02-28 23:49:41 +01:00
parent 218dec4a36
commit d1d6ab62dd
49 changed files with 704 additions and 1593 deletions

View File

@@ -41,7 +41,7 @@ public class JsclMathEngine implements MathEngine {
@Nonnull
private NumeralBase numeralBase = DEFAULT_NUMERAL_BASE;
@Nonnull
private ConstantsRegistry constantsRegistry;
private final ConstantsRegistry constantsRegistry = new ConstantsRegistry();
@Nonnull
private MessageRegistry messageRegistry = Messages.synchronizedMessageRegistry(new FixedCapacityListMessageRegistry(10));
@@ -50,8 +50,7 @@ public class JsclMathEngine implements MathEngine {
decimalGroupSymbols.setGroupingSeparator(GROUPING_SEPARATOR_DEFAULT.charAt(0));
}
private JsclMathEngine() {
this.constantsRegistry = new ConstantsRegistry();
public JsclMathEngine() {
}
@Nonnull
@@ -176,7 +175,7 @@ public class JsclMathEngine implements MathEngine {
if (name.equals(Constants.PI_INV.getName()) || name.equals(Constants.ANS)) {
return false;
}
return !name.equals(Constants.PI.getName()) || JsclMathEngine.getInstance().getAngleUnits() == AngleUnit.rad;
return !name.equals(Constants.PI.getName()) || getAngleUnits() == AngleUnit.rad;
}
});

View File

@@ -4,57 +4,54 @@ import jscl.JsclMathEngine;
import jscl.MathEngine;
import jscl.text.ParseException;
import jscl.text.msg.Messages;
import junit.framework.Assert;
import org.junit.Test;
/**
* User: serso
* Date: 12/15/11
* Time: 10:41 PM
*/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class DoubleFactorialTest {
@Test
public void testDoubleFactorial() throws Exception {
final MathEngine me = JsclMathEngine.getInstance();
Assert.assertEquals("1", me.evaluate("0!"));
Assert.assertEquals("1", me.evaluate("1!"));
Assert.assertEquals("2", me.evaluate("2!"));
Assert.assertEquals("6", me.evaluate("3!"));
Assert.assertEquals("24", me.evaluate("4!"));
assertEquals("1", me.evaluate("0!"));
assertEquals("1", me.evaluate("1!"));
assertEquals("2", me.evaluate("2!"));
assertEquals("6", me.evaluate("3!"));
assertEquals("24", me.evaluate("4!"));
try {
me.evaluate("(-1)!!");
Assert.fail();
fail();
} catch (ArithmeticException e) {
// ok
}
Assert.assertEquals("-1", me.evaluate("-1!!"));
Assert.assertEquals("1", me.evaluate("0!!"));
Assert.assertEquals("1", me.evaluate("1!!"));
Assert.assertEquals("2", me.evaluate("2!!"));
Assert.assertEquals("2", me.evaluate("(2!!)!"));
Assert.assertEquals("2", me.evaluate("(2!)!!"));
Assert.assertEquals("3", me.evaluate("3!!"));
Assert.assertEquals("48", me.evaluate("(3!)!!"));
Assert.assertEquals("6", me.evaluate("(3!!)!"));
Assert.assertEquals("8", me.evaluate("4!!"));
Assert.assertEquals("15", me.evaluate("5!!"));
Assert.assertEquals("48", me.evaluate("6!!"));
Assert.assertEquals("105", me.evaluate("7!!"));
Assert.assertEquals("384", me.evaluate("8!!"));
Assert.assertEquals("945", me.evaluate("9!!"));
assertEquals("-1", me.evaluate("-1!!"));
assertEquals("1", me.evaluate("0!!"));
assertEquals("1", me.evaluate("1!!"));
assertEquals("2", me.evaluate("2!!"));
assertEquals("2", me.evaluate("(2!!)!"));
assertEquals("2", me.evaluate("(2!)!!"));
assertEquals("3", me.evaluate("3!!"));
assertEquals("48", me.evaluate("(3!)!!"));
assertEquals("6", me.evaluate("(3!!)!"));
assertEquals("8", me.evaluate("4!!"));
assertEquals("15", me.evaluate("5!!"));
assertEquals("48", me.evaluate("6!!"));
assertEquals("105", me.evaluate("7!!"));
assertEquals("384", me.evaluate("8!!"));
assertEquals("945", me.evaluate("9!!"));
try {
me.evaluate("9!!!");
Assert.fail();
fail();
} catch (ParseException e) {
if (Messages.msg_18.equals(e.getMessageCode())) {
// ok
} else {
Assert.fail();
fail();
}
}