optimize arithmetics
This commit is contained in:
1 parent
161f3f74e2
commit
d8454a11fc
21 files changed
+913
-208
No files matched your search
+9
-5
@@ -17,7 +17,9 @@
|
||||
|
||||
package net.sergeych.lyng.io.net
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import net.sergeych.lyng.Compiler
|
||||
import net.sergeych.lyng.Script
|
||||
@@ -29,9 +31,9 @@ import kotlin.test.assertEquals
|
||||
class LyngNetTcpServerExampleTest {
|
||||
|
||||
@Test
|
||||
fun tcpServerExampleRoundTripsOverLoopback() = runBlocking {
|
||||
fun tcpServerExampleRoundTripsOverLoopback() = runTest {
|
||||
val engine = getSystemNetEngine()
|
||||
if (!engine.isSupported || !engine.isTcpAvailable || !engine.isTcpServerAvailable) return@runBlocking
|
||||
if (!engine.isSupported || !engine.isTcpAvailable || !engine.isTcpServerAvailable) return@runTest
|
||||
|
||||
val scope = Script.newScope()
|
||||
createNetModule(PermitAllNetAccessPolicy, scope)
|
||||
@@ -60,8 +62,10 @@ class LyngNetTcpServerExampleTest {
|
||||
"${'$'}{accepted.await()}: ${'$'}reply"
|
||||
""".trimIndent()
|
||||
|
||||
val result = withTimeout(5_000) {
|
||||
Compiler.compile(code).execute(scope).inspect(scope)
|
||||
val result = withContext(Dispatchers.Default) {
|
||||
withTimeout(5_000) {
|
||||
Compiler.compile(code).execute(scope).inspect(scope)
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("\"ping: echo:ping\"", result)
|
||||
|
||||
+17
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.sergeych.lyng.io.net
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
+17
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.sergeych.lyngio
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
Reference in new issue
Block a user