kunfei 3 лет назад
Родитель
Сommit
f3d70f440b
2 измененных файлов с 18 добавлено и 1 удалено
  1. 17 0
      app/src/test/java/io/legado/app/ExampleUnitTest.kt
  2. 1 1
      rhino/build.gradle

+ 17 - 0
app/src/test/java/io/legado/app/ExampleUnitTest.kt

@@ -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
rhino/build.gradle

@@ -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']))
 }
 }