forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
package com.fanruan.api.function; |
|
|
|
import com.fanruan.api.Prepare; |
|
import com.fanruan.api.function.shell.FineFunc; |
|
import com.fr.script.Calculator; |
|
import com.fr.stable.UtilEvalError; |
|
import org.junit.Test; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
import static org.junit.Assert.assertNotEquals; |
|
|
|
/** |
|
* @ClassName FunctionKitTest |
|
* @Author zack |
|
* @Date 2019/8/23 |
|
* @Version 10.0 |
|
*/ |
|
public class FunctionKitTest extends Prepare { |
|
|
|
@Test |
|
public void testFuncAdd() { |
|
FunctionKit.removeFunc("com.fanruan.api.function.TestFunc"); |
|
FunctionKit.addFunc(new FineFunc("TestFunc", "com.fanruan.api.function.TestFunc")); |
|
try { |
|
assertEquals("OK", Calculator.createCalculator().evalValue("TESTFUNC()")); |
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
} |
|
|
|
} |
|
|
|
@Test |
|
public void testFuncRemove() { |
|
FunctionKit.removeFunc("com.fanruan.api.function.TestFunc"); |
|
FunctionKit.addFunc(new FineFunc("TestFunc", "com.fanruan.api.function.TestFunc")); |
|
FunctionKit.removeFunc("com.fanruan.api.function.TestFunc"); |
|
String result = "ERROR"; |
|
try { |
|
result = Calculator.createCalculator().evalValue("TESTFUNC()").toString(); |
|
} catch (Throwable e) { |
|
|
|
} |
|
assertNotEquals("OK", result); |
|
} |
|
|
|
} |