优化
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
package io.legado.app
|
package io.legado.app
|
||||||
|
|
||||||
|
import com.script.SimpleBindings
|
||||||
|
import com.script.rhino.RhinoScriptEngine
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
*
|
*
|
||||||
@@ -13,4 +16,18 @@ class ExampleUnitTest {
|
|||||||
fun addition_isCorrect() {
|
fun addition_isCorrect() {
|
||||||
assertEquals(4, 2 + 2)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -35,5 +35,5 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(fileTree(dir: 'lib', include: ['rhino-1.7.14-2.jar']))
|
api(fileTree(dir: 'lib', include: ['rhino-1.7.13-2.jar']))
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user