Esempio n. 1
0
 public void valueTest(String expr, String expected) throws ParseException, Exception {
   Node node = j.parse(expr);
   Object res = j.evaluate(node);
   if (j.hasError()) fail("Evaluation Failure: " + expr + j.getErrorInfo());
   assertEquals("<" + expr + ">", expected, res.toString());
   System.out.println("Sucess value of <" + expr + "> is " + res.toString());
 }
Esempio n. 2
0
  /*
  	public void simplifyTestString(String expr,String expected) throws ParseException
  	{
  		Node node = j.parse(expr);
  		Node matEqn = j.preprocess(node);
  		String res = j.toString(matEqn);

  		if(!expected.equals(res))
  			System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+expected+"\"");
  		assertEquals("<"+expr+">",expected,res);
  		System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\"");

  //		System.out.print("Full Brackets:\t");
  //		j.pv.setFullBrackets(true);
  //		j.pv.println(simp);
  //		j.pv.setFullBrackets(false);

  	}
  */
  void rpTest(String eqns[], String eqn2) throws ParseException, Exception {
    for (int i = 0; i < eqns.length; ++i) {
      System.out.println("eqns " + eqns[i]);
      Node node = j.parse(eqns[i]);
      j.evaluate(node);
    }
    Node node3 = j.parse(eqn2);
    RpEval rpe = new RpEval(j);
    RpCommandList list = rpe.compile(node3);
    //		rpe.copyVars();
    double rpRes = rpe.evaluate(list);

    Object matRes = j.evaluate(node3);
    //		System.out.println("rpRes: "+rpRes.getClass().getName()+" = "+rpRes.toString());
    if (j.hasError()) fail("Evaluation Failure: " + eqn2 + j.getErrorInfo());
    myAssertEquals("<" + eqn2 + ">", "" + rpRes, matRes.toString());

    if (!matRes.equals(new Double(rpRes))) fail("Expected <" + matRes + "> found <" + rpRes + ">");
  }