|
|
@ -2,9 +2,11 @@ package com.fanruan.api.cal; |
|
|
|
|
|
|
|
|
|
|
|
import com.fanruan.api.Prepare; |
|
|
|
import com.fanruan.api.Prepare; |
|
|
|
import com.fanruan.api.err.KitError; |
|
|
|
import com.fanruan.api.err.KitError; |
|
|
|
|
|
|
|
import com.fr.base.BaseFormula; |
|
|
|
import com.fr.base.Formula; |
|
|
|
import com.fr.base.Formula; |
|
|
|
import com.fr.base.ParameterMapNameSpace; |
|
|
|
import com.fr.base.ParameterMapNameSpace; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
|
|
|
import com.fr.stable.UtilEvalError; |
|
|
|
import com.fr.stable.script.CalculatorProvider; |
|
|
|
import com.fr.stable.script.CalculatorProvider; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
@ -43,6 +45,19 @@ public class FormulaKitTest extends Prepare { |
|
|
|
Assert.fail(); |
|
|
|
Assert.fail(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testScriptFormula() { |
|
|
|
|
|
|
|
BaseFormula formula = FormulaKit.newScriptFormula("=return Math.abs(-1)"); |
|
|
|
|
|
|
|
CalculatorProvider provider = CalculatorKit.createCalculator(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Object r = formula.evalValue(provider); |
|
|
|
|
|
|
|
Assert.assertEquals(1, r); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testCheckFormulaContent() { |
|
|
|
public void testCheckFormulaContent() { |
|
|
|
assertEquals(true, FormulaKit.checkFormulaContent(new Formula(""))); |
|
|
|
assertEquals(true, FormulaKit.checkFormulaContent(new Formula(""))); |
|
|
|