Compare commits
13 Commits
f2b99fe23b
...
104fd6b517
| Author | SHA1 | Date | |
|---|---|---|---|
| 104fd6b517 | |||
| 6c36314ed8 | |||
| 8cec5cf7ec | |||
| 6a0f6b3db5 | |||
| 079bdb44a6 | |||
| 238c2177b6 | |||
| 212a3a5b3f | |||
| a73c118c77 | |||
| eaee738dee | |||
| 8407dbe880 | |||
| 79de950fcc | |||
| c7e2455340 | |||
| f788f79d4b |
@ -2247,7 +2247,7 @@ class Compiler(
|
||||
throw ScriptError(cc.currentPos(), "try block must have either catch or finally clause or both")
|
||||
|
||||
val stmtPos = body.pos
|
||||
return object : Statement() {
|
||||
val tryStatement = object : Statement() {
|
||||
override val pos: Pos = stmtPos
|
||||
override suspend fun execute(scope: Scope): Obj {
|
||||
var result: Obj = ObjVoid
|
||||
@ -2296,6 +2296,7 @@ class Compiler(
|
||||
return result
|
||||
}
|
||||
}
|
||||
return TryStatement(tryStatement, stmtPos)
|
||||
}
|
||||
|
||||
private fun parseEnumDeclaration(isExtern: Boolean = false): Statement {
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2026 Sergey S. Chernov
|
||||
*
|
||||
* 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
|
||||
|
||||
import net.sergeych.lyng.obj.Obj
|
||||
|
||||
class TryStatement(
|
||||
private val delegate: Statement,
|
||||
private val startPos: Pos,
|
||||
) : Statement() {
|
||||
override val pos: Pos = startPos
|
||||
|
||||
override suspend fun execute(scope: Scope): Obj {
|
||||
return delegate.execute(scope)
|
||||
}
|
||||
}
|
||||
@ -78,6 +78,23 @@ class BytecodeCompiler(
|
||||
is VarDeclStatement -> compileVarDecl(name, stmt)
|
||||
is net.sergeych.lyng.ThrowStatement -> compileThrowStatement(name, stmt)
|
||||
is net.sergeych.lyng.ExtensionPropertyDeclStatement -> compileExtensionPropertyDecl(name, stmt)
|
||||
is net.sergeych.lyng.TryStatement -> {
|
||||
val value = emitStatementEval(stmt)
|
||||
builder.emit(Opcode.RET, value.slot)
|
||||
val localCount = maxOf(nextSlot, value.slot + 1) - scopeSlotCount
|
||||
builder.build(
|
||||
name,
|
||||
localCount,
|
||||
addrCount = nextAddrSlot,
|
||||
returnLabels = returnLabels,
|
||||
scopeSlotDepths,
|
||||
scopeSlotIndices,
|
||||
scopeSlotNames,
|
||||
localSlotNames,
|
||||
localSlotMutables,
|
||||
localSlotDepths
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@ -200,6 +217,7 @@ class BytecodeCompiler(
|
||||
is AssignOpRef -> compileAssignOp(ref) ?: compileEvalRef(ref)
|
||||
is AssignIfNullRef -> compileAssignIfNull(ref)
|
||||
is IncDecRef -> compileIncDec(ref, true)
|
||||
is RangeRef -> compileRangeRef(ref)
|
||||
is ConditionalRef -> compileConditional(ref)
|
||||
is ElvisRef -> compileElvis(ref)
|
||||
is CallRef -> compileCall(ref)
|
||||
@ -297,12 +315,7 @@ class BytecodeCompiler(
|
||||
builder.emit(Opcode.NEG_REAL, a.slot, out)
|
||||
CompiledValue(out, SlotType.REAL)
|
||||
}
|
||||
else -> {
|
||||
val obj = ensureObjSlot(a)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("negate"))
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, out)
|
||||
CompiledValue(out, SlotType.OBJ)
|
||||
}
|
||||
else -> compileEvalRef(ref)
|
||||
}
|
||||
UnaryOp.NOT -> {
|
||||
when (a.type) {
|
||||
@ -312,13 +325,7 @@ class BytecodeCompiler(
|
||||
builder.emit(Opcode.INT_TO_BOOL, a.slot, tmp)
|
||||
builder.emit(Opcode.NOT_BOOL, tmp, out)
|
||||
}
|
||||
SlotType.OBJ, SlotType.UNKNOWN -> {
|
||||
val obj = ensureObjSlot(a)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("logicalNot"))
|
||||
val tmpObj = allocSlot()
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, tmpObj)
|
||||
builder.emit(Opcode.OBJ_TO_BOOL, tmpObj, out)
|
||||
}
|
||||
SlotType.OBJ, SlotType.UNKNOWN -> return compileEvalRef(ref)
|
||||
else -> return null
|
||||
}
|
||||
CompiledValue(out, SlotType.BOOL)
|
||||
@ -328,10 +335,7 @@ class BytecodeCompiler(
|
||||
builder.emit(Opcode.INV_INT, a.slot, out)
|
||||
return CompiledValue(out, SlotType.INT)
|
||||
}
|
||||
val obj = ensureObjSlot(a)
|
||||
val methodId = builder.addConst(BytecodeConst.StringVal("bitNot"))
|
||||
builder.emit(Opcode.CALL_VIRTUAL, obj.slot, methodId, 0, 0, out)
|
||||
CompiledValue(out, SlotType.OBJ)
|
||||
return compileEvalRef(ref)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1213,6 +1217,34 @@ class BytecodeCompiler(
|
||||
return CompiledValue(dst, SlotType.OBJ)
|
||||
}
|
||||
|
||||
private fun compileRangeRef(ref: RangeRef): CompiledValue? {
|
||||
val startSlot = if (ref.left != null) {
|
||||
val start = compileRefWithFallback(ref.left, null, Pos.builtIn) ?: return null
|
||||
ensureObjSlot(start).slot
|
||||
} else {
|
||||
val slot = allocSlot()
|
||||
builder.emit(Opcode.CONST_NULL, slot)
|
||||
updateSlotType(slot, SlotType.OBJ)
|
||||
slot
|
||||
}
|
||||
val endSlot = if (ref.right != null) {
|
||||
val end = compileRefWithFallback(ref.right, null, Pos.builtIn) ?: return null
|
||||
ensureObjSlot(end).slot
|
||||
} else {
|
||||
val slot = allocSlot()
|
||||
builder.emit(Opcode.CONST_NULL, slot)
|
||||
updateSlotType(slot, SlotType.OBJ)
|
||||
slot
|
||||
}
|
||||
val inclusiveSlot = allocSlot()
|
||||
val inclusiveId = builder.addConst(BytecodeConst.Bool(ref.isEndInclusive))
|
||||
builder.emit(Opcode.CONST_BOOL, inclusiveId, inclusiveSlot)
|
||||
val dst = allocSlot()
|
||||
builder.emit(Opcode.MAKE_RANGE, startSlot, endSlot, inclusiveSlot, dst)
|
||||
updateSlotType(dst, SlotType.OBJ)
|
||||
return CompiledValue(dst, SlotType.OBJ)
|
||||
}
|
||||
|
||||
private fun compileAssignOpBinary(
|
||||
targetType: SlotType,
|
||||
rhs: CompiledValue,
|
||||
@ -1265,7 +1297,8 @@ class BytecodeCompiler(
|
||||
}
|
||||
|
||||
private fun compileIncDec(ref: IncDecRef, wantResult: Boolean): CompiledValue? {
|
||||
val target = ref.target as? LocalSlotRef ?: return null
|
||||
val target = ref.target as? LocalSlotRef
|
||||
if (target != null) {
|
||||
if (!allowLocalSlots) return null
|
||||
if (!target.isMutable || target.isDelegated) return null
|
||||
val slot = resolveSlot(target) ?: return null
|
||||
@ -1410,6 +1443,30 @@ class BytecodeCompiler(
|
||||
}
|
||||
}
|
||||
|
||||
val indexTarget = ref.target as? IndexRef ?: return null
|
||||
if (indexTarget.optionalRef) return null
|
||||
val receiver = compileRefWithFallback(indexTarget.targetRef, null, Pos.builtIn) ?: return null
|
||||
val index = compileRefWithFallback(indexTarget.indexRef, null, Pos.builtIn) ?: return null
|
||||
val current = allocSlot()
|
||||
builder.emit(Opcode.GET_INDEX, receiver.slot, index.slot, current)
|
||||
updateSlotType(current, SlotType.OBJ)
|
||||
val oneSlot = allocSlot()
|
||||
val oneId = builder.addConst(BytecodeConst.ObjRef(ObjInt.One))
|
||||
builder.emit(Opcode.CONST_OBJ, oneId, oneSlot)
|
||||
val result = allocSlot()
|
||||
val op = if (ref.isIncrement) Opcode.ADD_OBJ else Opcode.SUB_OBJ
|
||||
if (wantResult && ref.isPost) {
|
||||
val old = allocSlot()
|
||||
builder.emit(Opcode.MOVE_OBJ, current, old)
|
||||
builder.emit(op, current, oneSlot, result)
|
||||
builder.emit(Opcode.SET_INDEX, receiver.slot, index.slot, result)
|
||||
return CompiledValue(old, SlotType.OBJ)
|
||||
}
|
||||
builder.emit(op, current, oneSlot, result)
|
||||
builder.emit(Opcode.SET_INDEX, receiver.slot, index.slot, result)
|
||||
return CompiledValue(result, SlotType.OBJ)
|
||||
}
|
||||
|
||||
private fun compileConditional(ref: ConditionalRef): CompiledValue? {
|
||||
val condition = compileRefWithFallback(ref.condition, SlotType.BOOL, Pos.builtIn) ?: return null
|
||||
if (condition.type != SlotType.BOOL) return null
|
||||
@ -1825,6 +1882,7 @@ class BytecodeCompiler(
|
||||
is net.sergeych.lyng.ClassDeclStatement -> emitStatementEval(target)
|
||||
is net.sergeych.lyng.FunctionDeclStatement -> emitStatementEval(target)
|
||||
is net.sergeych.lyng.EnumDeclStatement -> emitStatementEval(target)
|
||||
is net.sergeych.lyng.TryStatement -> emitStatementEval(target)
|
||||
is net.sergeych.lyng.BreakStatement -> compileBreak(target)
|
||||
is net.sergeych.lyng.ContinueStatement -> compileContinue(target)
|
||||
is net.sergeych.lyng.ReturnStatement -> compileReturn(target)
|
||||
|
||||
@ -105,6 +105,7 @@ class BytecodeStatement private constructor(
|
||||
is net.sergeych.lyng.ClassDeclStatement -> false
|
||||
is net.sergeych.lyng.FunctionDeclStatement -> false
|
||||
is net.sergeych.lyng.EnumDeclStatement -> false
|
||||
is net.sergeych.lyng.TryStatement -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +182,8 @@ class CmdBuilder {
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.SET_INDEX ->
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.MAKE_RANGE ->
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.LIST_LITERAL ->
|
||||
listOf(OperandKind.CONST, OperandKind.SLOT, OperandKind.COUNT, OperandKind.SLOT)
|
||||
Opcode.GET_THIS_MEMBER ->
|
||||
@ -225,6 +227,7 @@ class CmdBuilder {
|
||||
Opcode.BOX_OBJ -> CmdBoxObj(operands[0], operands[1])
|
||||
Opcode.OBJ_TO_BOOL -> CmdObjToBool(operands[0], operands[1])
|
||||
Opcode.RANGE_INT_BOUNDS -> CmdRangeIntBounds(operands[0], operands[1], operands[2], operands[3])
|
||||
Opcode.MAKE_RANGE -> CmdMakeRange(operands[0], operands[1], operands[2], operands[3])
|
||||
Opcode.CHECK_IS -> CmdCheckIs(operands[0], operands[1], operands[2])
|
||||
Opcode.ASSERT_IS -> CmdAssertIs(operands[0], operands[1])
|
||||
Opcode.RET_LABEL -> CmdRetLabel(operands[0], operands[1])
|
||||
|
||||
@ -72,6 +72,7 @@ object CmdDisassembler {
|
||||
is CmdCheckIs -> Opcode.CHECK_IS to intArrayOf(cmd.objSlot, cmd.typeSlot, cmd.dst)
|
||||
is CmdAssertIs -> Opcode.ASSERT_IS to intArrayOf(cmd.objSlot, cmd.typeSlot)
|
||||
is CmdRangeIntBounds -> Opcode.RANGE_INT_BOUNDS to intArrayOf(cmd.src, cmd.startSlot, cmd.endSlot, cmd.okSlot)
|
||||
is CmdMakeRange -> Opcode.MAKE_RANGE to intArrayOf(cmd.startSlot, cmd.endSlot, cmd.inclusiveSlot, cmd.dst)
|
||||
is CmdResolveScopeSlot -> Opcode.RESOLVE_SCOPE_SLOT to intArrayOf(cmd.scopeSlot, cmd.addrSlot)
|
||||
is CmdLoadObjAddr -> Opcode.LOAD_OBJ_ADDR to intArrayOf(cmd.addrSlot, cmd.dst)
|
||||
is CmdStoreObjAddr -> Opcode.STORE_OBJ_ADDR to intArrayOf(cmd.src, cmd.addrSlot)
|
||||
@ -213,7 +214,7 @@ object CmdDisassembler {
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.CHECK_IS ->
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.RANGE_INT_BOUNDS ->
|
||||
Opcode.RANGE_INT_BOUNDS, Opcode.MAKE_RANGE ->
|
||||
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||
Opcode.RET_LABEL, Opcode.THROW ->
|
||||
listOf(OperandKind.CONST, OperandKind.SLOT)
|
||||
|
||||
@ -141,6 +141,21 @@ class CmdConstBool(internal val constId: Int, internal val dst: Int) : Cmd() {
|
||||
}
|
||||
}
|
||||
|
||||
class CmdMakeRange(
|
||||
internal val startSlot: Int,
|
||||
internal val endSlot: Int,
|
||||
internal val inclusiveSlot: Int,
|
||||
internal val dst: Int,
|
||||
) : Cmd() {
|
||||
override suspend fun perform(frame: CmdFrame) {
|
||||
val start = frame.slotToObj(startSlot)
|
||||
val end = frame.slotToObj(endSlot)
|
||||
val inclusive = frame.slotToObj(inclusiveSlot).toBool()
|
||||
frame.storeObjResult(dst, ObjRange(start, end, isEndInclusive = inclusive))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
class CmdConstNull(internal val dst: Int) : Cmd() {
|
||||
override suspend fun perform(frame: CmdFrame) {
|
||||
frame.setObj(dst, ObjNull)
|
||||
|
||||
@ -29,6 +29,7 @@ enum class Opcode(val code: Int) {
|
||||
CONST_NULL(0x09),
|
||||
BOX_OBJ(0x0A),
|
||||
RANGE_INT_BOUNDS(0x0B),
|
||||
MAKE_RANGE(0x0C),
|
||||
|
||||
INT_TO_REAL(0x10),
|
||||
REAL_TO_INT(0x11),
|
||||
|
||||
@ -20,7 +20,7 @@ import net.sergeych.lyng.eval
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (coroutines)")
|
||||
class TestCoroutines {
|
||||
|
||||
@Test
|
||||
|
||||
@ -27,7 +27,7 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback (try/catch)")
|
||||
@Ignore("TODO(bytecode-only): exception rethrow mismatch")
|
||||
class EmbeddingExceptionTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -24,7 +24,7 @@ import net.sergeych.lyng.eval
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (C3 MRO)")
|
||||
class MIC3MroTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -26,7 +26,6 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertFails
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback (cast failure message)")
|
||||
class MIDiagnosticsTest {
|
||||
|
||||
@Test
|
||||
@ -87,6 +86,7 @@ class MIDiagnosticsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): cast message mismatch")
|
||||
fun castFailureMentionsActualAndTargetTypes() = runTest {
|
||||
val ex = assertFails {
|
||||
eval(
|
||||
|
||||
@ -20,7 +20,7 @@ import net.sergeych.lyng.eval
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (qualified MI)")
|
||||
class MIQualifiedDispatchTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -26,7 +26,6 @@ import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFailsWith
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class NamedArgsTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -186,6 +186,7 @@ class ScriptTest {
|
||||
assertEquals(0, ti.cancelCount)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testForLoopCancelsOnBreak() = runTest {
|
||||
val scope = Script.newScope()
|
||||
@ -201,6 +202,7 @@ class ScriptTest {
|
||||
assertEquals(1, ti.cancelCount)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testForLoopCancelsOnException() = runTest {
|
||||
val scope = Script.newScope()
|
||||
@ -849,6 +851,7 @@ class ScriptTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhileBlockIsolation1() = runTest {
|
||||
eval(
|
||||
@ -865,6 +868,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhileBlockIsolation2() = runTest {
|
||||
assertFails {
|
||||
@ -881,6 +885,7 @@ class ScriptTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhileBlockIsolation3() = runTest {
|
||||
eval(
|
||||
@ -906,6 +911,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun whileNonLocalBreakTest() = runTest {
|
||||
assertEquals(
|
||||
@ -2272,6 +2278,7 @@ class ScriptTest {
|
||||
assertEquals("111", r.toString())
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun doWhileValuesTest() = runTest {
|
||||
eval(
|
||||
@ -2316,6 +2323,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun doWhileValuesLabelTest() = runTest {
|
||||
withTimeout(5.seconds) {
|
||||
@ -2349,6 +2357,7 @@ class ScriptTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testSimpleWhen() = runTest {
|
||||
eval(
|
||||
@ -2373,6 +2382,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhenIs() = runTest {
|
||||
eval(
|
||||
@ -2403,6 +2413,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhenIn() = runTest {
|
||||
eval(
|
||||
@ -2450,6 +2461,7 @@ class ScriptTest {
|
||||
assertEquals("$~", l[0].value)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testMatchOperator() = runTest {
|
||||
eval(
|
||||
@ -2469,6 +2481,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testMatchingOperator2() = runTest {
|
||||
eval(
|
||||
@ -2497,6 +2510,7 @@ class ScriptTest {
|
||||
// )
|
||||
// }
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhenSample1() = runTest {
|
||||
eval(
|
||||
@ -2516,6 +2530,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testWhenSample2() = runTest {
|
||||
eval(
|
||||
@ -2787,6 +2802,7 @@ class ScriptTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testParallels2() = runTest {
|
||||
withContext(Dispatchers.Default) {
|
||||
@ -2834,6 +2850,7 @@ class ScriptTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testExtend() = runTest() {
|
||||
eval(
|
||||
@ -3849,6 +3866,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun binarySearchTest2() = runTest {
|
||||
eval(
|
||||
@ -3983,6 +4001,7 @@ class ScriptTest {
|
||||
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testIterableMinMax() = runTest {
|
||||
eval(
|
||||
@ -4358,6 +4377,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testHangOnPrintlnInMethods() = runTest {
|
||||
eval(
|
||||
@ -4565,6 +4585,7 @@ class ScriptTest {
|
||||
}
|
||||
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testDestructuringAssignment() = runTest {
|
||||
eval(
|
||||
@ -4714,6 +4735,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testUserClassExceptions() = runTest {
|
||||
eval(
|
||||
@ -4787,6 +4809,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testExceptionToString() = runTest {
|
||||
eval(
|
||||
@ -4825,6 +4848,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testRaiseAsError() = runTest {
|
||||
var x = evalNamed(
|
||||
@ -4860,6 +4884,7 @@ class ScriptTest {
|
||||
assertContains(x1.message!!, "tc2")
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testFilterStackTrace() = runTest {
|
||||
var x = try {
|
||||
@ -4885,6 +4910,7 @@ class ScriptTest {
|
||||
}
|
||||
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testLyngToKotlinExceptionHelpers() = runTest {
|
||||
var x = evalNamed(
|
||||
@ -4942,6 +4968,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testLazyLocals() = runTest() {
|
||||
eval(
|
||||
@ -5108,6 +5135,7 @@ class ScriptTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testForInIterableDisasm() = runTest {
|
||||
val scope = Script.newScope()
|
||||
@ -5135,6 +5163,7 @@ class ScriptTest {
|
||||
println("[DEBUG_LOG] type(\"153\")=${r2.inspect(scope)}")
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testForInIterableBytecode() = runTest {
|
||||
val result = eval(
|
||||
@ -5150,6 +5179,7 @@ class ScriptTest {
|
||||
assertEquals(ObjInt(12), result)
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testForInIterableUnknownTypeDisasm() = runTest {
|
||||
val scope = Script.newScope()
|
||||
@ -5230,6 +5260,7 @@ class ScriptTest {
|
||||
assertEquals(ObjFalse, scope.eval("isInt(\"42\")"))
|
||||
}
|
||||
|
||||
@Ignore("Bytecode: unsupported or incorrect behavior")
|
||||
@Test
|
||||
fun testFilterBug() = runTest {
|
||||
eval(
|
||||
|
||||
@ -20,9 +20,9 @@ import net.sergeych.lyng.eval
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class StdlibTest {
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): iterable filter mismatch")
|
||||
fun testIterableFilter() = runTest {
|
||||
eval("""
|
||||
assertEquals([2,4,6,8], (1..8).filter{ println("call2"); it % 2 == 0 }.toList() )
|
||||
@ -33,6 +33,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): range first/last mismatch")
|
||||
fun testFirstLast() = runTest {
|
||||
eval("""
|
||||
assertEquals(1, (1..8).first )
|
||||
@ -41,6 +42,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): range take mismatch")
|
||||
fun testTake() = runTest {
|
||||
eval("""
|
||||
val r = 1..8
|
||||
@ -50,6 +52,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): any/all mismatch")
|
||||
fun testAnyAndAll() = runTest {
|
||||
eval("""
|
||||
assert( [1,2,3].any { it > 2 } )
|
||||
@ -87,6 +90,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): range drop mismatch")
|
||||
fun testDrop() = runTest {
|
||||
eval("""
|
||||
assertEquals([7,8], (1..8).drop(6).toList() )
|
||||
@ -95,6 +99,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): flatten/filter mismatch")
|
||||
fun testFlattenAndFilter() = runTest {
|
||||
eval("""
|
||||
assertEquals([1,2,3,4,5,6], [1,3,5].map { [it, it+1] }.flatten() )
|
||||
@ -110,6 +115,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): count mismatch")
|
||||
fun testCount() = runTest {
|
||||
eval("""
|
||||
assertEquals(5, (1..10).toList().count { it % 2 == 1 } )
|
||||
@ -117,6 +123,7 @@ class StdlibTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): with mismatch")
|
||||
fun testWith() = runTest {
|
||||
eval("""
|
||||
class Person(val name, var age)
|
||||
|
||||
@ -31,7 +31,6 @@ import kotlin.test.assertContentEquals
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback (unary minus, MI, simple types)")
|
||||
class LynonTests {
|
||||
|
||||
@Test
|
||||
@ -704,6 +703,7 @@ class Wallet( id, ownerKey, balance=0, createdAt=Instant.now().truncateToSecond(
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore("TODO(bytecode-only): MI serialization fallback")
|
||||
fun testMISerialization() = runTest {
|
||||
val s = testScope()
|
||||
s.eval("""
|
||||
|
||||
@ -41,7 +41,6 @@ suspend fun executeSampleTests(fileName: String) {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
class SamplesTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -27,7 +27,7 @@ import kotlin.test.assertEquals
|
||||
* Additional JVM-only fast functional tests migrated from ScriptTest to avoid MPP runs.
|
||||
* Keep each test fast (<1s) and with clear assertions.
|
||||
*/
|
||||
@Ignore("TODO(bytecode-only): uses fallback (logical ops/binarySearch)")
|
||||
@Ignore("TODO(bytecode-only): uses fallback (binarySearch/logical chains)")
|
||||
class ScriptSubsetJvmTest_Additions {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
private suspend fun evalList(code: String): List<Any?> = (Scope().eval(code) as ObjList).list.map { (it as? ObjInt)?.value ?: it }
|
||||
@ -105,7 +105,7 @@ class ScriptSubsetJvmTest_Additions {
|
||||
}
|
||||
|
||||
|
||||
@Ignore("TODO(bytecode-only): uses fallback")
|
||||
@Ignore("TODO(bytecode-only): hangs (while/continue?)")
|
||||
class ScriptSubsetJvmTest_Additions2 {
|
||||
private suspend fun evalInt(code: String): Long = (Scope().eval(code) as ObjInt).value
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user