-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
510745c
commit e3a24c5
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/com/ql/util/express/bugfix/ExecuteReentrantTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.ql.util.express.bugfix; | ||
|
||
import com.ql.util.express.ArraySwap; | ||
import com.ql.util.express.DefaultContext; | ||
import com.ql.util.express.ExpressRunner; | ||
import com.ql.util.express.InstructionSetContext; | ||
import com.ql.util.express.OperateData; | ||
import com.ql.util.express.instruction.op.OperatorBase; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* 线程可重入执行测试 | ||
*/ | ||
public class ExecuteReentrantTest { | ||
|
||
@Test | ||
public void executeReentrantTest() throws Exception { | ||
String express = "eval('eval(\\'1+1\\')')"; | ||
ExpressRunner runner = new ExpressRunner(false, true); | ||
runner.addFunction("eval", new OperatorBase() { | ||
@Override | ||
public OperateData executeInner(InstructionSetContext parent, ArraySwap list) throws Exception { | ||
Object res = runner.execute(list.get(0).toString(), parent, null, | ||
false, true); | ||
return new OperateData(res, res.getClass()); | ||
} | ||
}); | ||
|
||
Object res = runner.execute(express, new DefaultContext<>(), null, | ||
false, true); | ||
Assert.assertEquals(2, res); | ||
|
||
Object res1 = runner.execute("m = 'aaa';" + | ||
"eval('m')", new DefaultContext<>(), null, | ||
false, true); | ||
Assert.assertEquals("aaa", res1); | ||
} | ||
|
||
} |