mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
优化
This commit is contained in:
parent
abea6b092b
commit
218e56bf98
@ -1,8 +1,11 @@
|
||||
package io.legado.app
|
||||
|
||||
import com.script.SimpleBindings
|
||||
import com.script.rhino.RhinoScriptEngine
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
@ -13,4 +16,18 @@ class ExampleUnitTest {
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun jsTest() {
|
||||
val scriptEngine = RhinoScriptEngine()
|
||||
val map = hashMapOf("id" to "3242532321")
|
||||
map["id"] = "12314123"
|
||||
val bindings = SimpleBindings()
|
||||
bindings["result"] = map
|
||||
val js = "$=result;id=$.id;id"
|
||||
val result = scriptEngine.eval(js, bindings)?.toString()
|
||||
assertEquals("12314123", result)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -35,5 +35,5 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(fileTree(dir: 'lib', include: ['rhino-1.7.14-2.jar']))
|
||||
api(fileTree(dir: 'lib', include: ['rhino-1.7.13-2.jar']))
|
||||
}
|
Loading…
Reference in New Issue
Block a user