[JS IR] Emit original names for local vars to sourcemaps
#KT-35655 Fixed
This commit is contained in:
committed by
Space Team
parent
8efa72ca36
commit
7b7c517dbb
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
import com.google.gwt.dev.js.parserExceptions.AbortParsingException
|
||||
import com.google.gwt.dev.js.rhino.CodePosition
|
||||
import com.google.gwt.dev.js.rhino.ErrorReporter
|
||||
import com.google.gwt.dev.js.rhino.Utils.isEndOfLine
|
||||
import com.google.gwt.dev.js.rhino.offsetOf
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
@@ -148,35 +148,6 @@ class JsCodeErrorReporter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates an offset from the start of a text for a position,
|
||||
* defined by line and offset in that line.
|
||||
*/
|
||||
private fun String.offsetOf(position: CodePosition): Int {
|
||||
var i = 0
|
||||
var lineCount = 0
|
||||
var offsetInLine = 0
|
||||
|
||||
while (i < length) {
|
||||
val c = this[i]
|
||||
|
||||
if (lineCount == position.line && offsetInLine == position.offset) {
|
||||
return i
|
||||
}
|
||||
|
||||
i++
|
||||
offsetInLine++
|
||||
|
||||
if (isEndOfLine(c.code)) {
|
||||
offsetInLine = 0
|
||||
lineCount++
|
||||
assert(lineCount <= position.line)
|
||||
}
|
||||
}
|
||||
|
||||
return length
|
||||
}
|
||||
|
||||
private val KtExpression.isConstantStringLiteral: Boolean
|
||||
get() = this is KtStringTemplateExpression && entries.all { it is KtLiteralStringTemplateEntry }
|
||||
|
||||
|
||||
@@ -26,3 +26,32 @@ class CodePosition(val line: Int, val offset: Int) : Comparable<CodePosition> {
|
||||
|
||||
override fun toString(): String = "($line, $offset)"
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates an offset from the start of a text for a position,
|
||||
* defined by line and offset in that line.
|
||||
*/
|
||||
fun String.offsetOf(position: CodePosition): Int {
|
||||
var i = 0
|
||||
var lineCount = 0
|
||||
var offsetInLine = 0
|
||||
|
||||
while (i < length) {
|
||||
val c = this[i]
|
||||
|
||||
if (lineCount == position.line && offsetInLine == position.offset) {
|
||||
return i
|
||||
}
|
||||
|
||||
i++
|
||||
offsetInLine++
|
||||
|
||||
if (Utils.isEndOfLine(c.code)) {
|
||||
offsetInLine = 0
|
||||
lineCount++
|
||||
assert(lineCount <= position.line)
|
||||
}
|
||||
}
|
||||
|
||||
return length
|
||||
}
|
||||
|
||||
@@ -158,6 +158,10 @@ fun main(args: Array<String>) {
|
||||
model("debug/stepping")
|
||||
}
|
||||
|
||||
testClass<AbstractIrJsLocalVariableTest> {
|
||||
model("debug/localVariables")
|
||||
}
|
||||
|
||||
testClass<AbstractFir2IrJsTextTest>(
|
||||
suiteTestClassName = "Fir2IrJsTextTestGenerated"
|
||||
) {
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.test
|
||||
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.AdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.test.services.ModuleStructureExtractor
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.File
|
||||
|
||||
class JsSteppingTestAdditionalSourceProvider(testServices: TestServices) : AdditionalSourceProvider(testServices) {
|
||||
|
||||
override fun produceAdditionalFiles(globalDirectives: RegisteredDirectives, module: TestModule): List<TestFile> {
|
||||
// HACK: For some reason if we add the same additional files to each module (not only the main one),
|
||||
// we get the 'Symbol already bound' exception during linking.
|
||||
// The craziest part is that we run most of the box tests with additional files, where we _do_ add the same additional files
|
||||
// to each module (using JsAdditionalSourceProvider), but the linker doesn't complain.
|
||||
// For some reason, it doesn't like _specifically_ the symbols defined in compiler/testData/debug/jsTestHelpers.
|
||||
return if (module.name == ModuleStructureExtractor.DEFAULT_MODULE_NAME) {
|
||||
buildList {
|
||||
if (containsDirective(globalDirectives, module, ConfigurationDirectives.WITH_STDLIB))
|
||||
add(File(WITH_STDLIB_HELPER_PATH).toTestFile())
|
||||
else
|
||||
add(File(MINIMAL_HELPER_PATH).toTestFile())
|
||||
add(File(COMMON_HELPER_PATH).toTestFile())
|
||||
}
|
||||
} else
|
||||
emptyList()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HELPERS_DIR = "compiler/testData/debug/jsTestHelpers"
|
||||
private const val COMMON_HELPER_PATH = "$HELPERS_DIR/jsCommonTestHelpers.kt"
|
||||
private const val MINIMAL_HELPER_PATH = "$HELPERS_DIR/jsMinimalTestHelpers.kt"
|
||||
private const val WITH_STDLIB_HELPER_PATH = "$HELPERS_DIR/jsWithStdlibTestHelpers.kt"
|
||||
}
|
||||
}
|
||||
@@ -310,6 +310,9 @@ class Runtime(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
@SerialName("symbol")
|
||||
SYMBOL,
|
||||
|
||||
@SerialName("accessor")
|
||||
ACCESSOR,
|
||||
|
||||
@SerialName("bigint")
|
||||
BIGINT,
|
||||
}
|
||||
@@ -396,6 +399,10 @@ class Runtime(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
* Object class (constructor) name. Specified for [ValueType.OBJECT] type values only.
|
||||
*/
|
||||
val className: String? = null,
|
||||
/**
|
||||
* Remote object value in case of primitive values or JSON values (if it was requested).
|
||||
*/
|
||||
val value: JsonElement? = null,
|
||||
/**
|
||||
* String representation of the object.
|
||||
*/
|
||||
@@ -403,7 +410,7 @@ class Runtime(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
/**
|
||||
* Unique object identifier (for non-primitive values).
|
||||
*/
|
||||
val objectId: RemoteObjectId? = null
|
||||
val objectId: RemoteObjectId? = null,
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -718,7 +725,11 @@ class Debugger(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private class EvaluateOnCallFrameRequestParams(val callFrameId: CallFrameId, val expression: String) : CDPRequestParams()
|
||||
private class EvaluateOnCallFrameRequestParams(
|
||||
val callFrameId: CallFrameId,
|
||||
val expression: String,
|
||||
val returnByValue: Boolean? = null,
|
||||
) : CDPRequestParams()
|
||||
|
||||
/**
|
||||
* Evaluates expression on a given call frame.
|
||||
@@ -727,15 +738,19 @@ class Debugger(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
*
|
||||
* @param callFrameId Call frame identifier to evaluate on.
|
||||
* @param expression Expression to evaluate.
|
||||
* @param returnByValue Whether the result is expected to be a JSON object that should be sent by value.
|
||||
*/
|
||||
suspend fun evaluateOnCallFrame(callFrameId: CallFrameId, expression: String) =
|
||||
requestEvaluator.evaluateRequest<Runtime.EvaluationResult> { messageId ->
|
||||
encodeCDPMethodCall<Runtime.EvaluationResult, EvaluateOnCallFrameRequestParams>(
|
||||
messageId,
|
||||
"Debugger.evaluateOnCallFrame",
|
||||
EvaluateOnCallFrameRequestParams(callFrameId, expression)
|
||||
)
|
||||
}
|
||||
suspend fun evaluateOnCallFrame(
|
||||
callFrameId: CallFrameId,
|
||||
expression: String,
|
||||
returnByValue: Boolean? = null,
|
||||
) = requestEvaluator.evaluateRequest<Runtime.EvaluationResult> { messageId ->
|
||||
encodeCDPMethodCall<Runtime.EvaluationResult, EvaluateOnCallFrameRequestParams>(
|
||||
messageId,
|
||||
"Debugger.evaluateOnCallFrame",
|
||||
EvaluateOnCallFrameRequestParams(callFrameId, expression, returnByValue)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Breakpoint identifier.
|
||||
@@ -803,6 +818,11 @@ class Debugger(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
*/
|
||||
val location: Location,
|
||||
|
||||
/**
|
||||
* Scope chain for this call frame.
|
||||
*/
|
||||
val scopeChain: List<Scope>,
|
||||
|
||||
/**
|
||||
* `this` object for this call frame.
|
||||
*/
|
||||
@@ -814,6 +834,66 @@ class Debugger(private val requestEvaluator: CDPRequestEvaluator) {
|
||||
val returnValue: Runtime.RemoteObject? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class Scope private constructor(
|
||||
|
||||
/**
|
||||
* Scope type.
|
||||
*/
|
||||
val type: ScopeType,
|
||||
|
||||
/**
|
||||
* Object representing the scope. For [ScopeType.GLOBAL] and [Scopetype.WITH] scopes it represents the actual object;
|
||||
* for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
|
||||
*/
|
||||
val `object`: Runtime.RemoteObject,
|
||||
|
||||
val name: String? = null,
|
||||
|
||||
/**
|
||||
* Location in the source code where scope starts
|
||||
*/
|
||||
val startLocation: Location? = null,
|
||||
|
||||
/**
|
||||
* Location in the source code where scope ends
|
||||
*/
|
||||
val endLocation: Location? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
enum class ScopeType {
|
||||
@SerialName("global")
|
||||
GLOBAL,
|
||||
|
||||
@SerialName("local")
|
||||
LOCAL,
|
||||
|
||||
@SerialName("with")
|
||||
WITH,
|
||||
|
||||
@SerialName("closure")
|
||||
CLOSURE,
|
||||
|
||||
@SerialName("catch")
|
||||
CATCH,
|
||||
|
||||
@SerialName("block")
|
||||
BLOCK,
|
||||
|
||||
@SerialName("script")
|
||||
SCRIPT,
|
||||
|
||||
@SerialName("eval")
|
||||
EVAL,
|
||||
|
||||
@SerialName("module")
|
||||
MODULE,
|
||||
|
||||
@SerialName("wasm-expression-stack")
|
||||
WASM_EXPRESSION_STACK,
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class PauseReason {
|
||||
|
||||
|
||||
@@ -16,8 +16,11 @@ try {
|
||||
vm.runInContext(code, sandbox, testFilePath);
|
||||
// language=JavaScript
|
||||
vm.runInContext(`
|
||||
const __continuation = main.testUtils.makeEmptyContinuation();
|
||||
// noinspection JSUnusedLocalSymbols (called in debugger, see JsDebugRunner)
|
||||
const __makeValueDescriptionForSteppingTests = main.testUtils.makeValueDescriptionForSteppingTests;
|
||||
debugger;
|
||||
main.box();
|
||||
main.box(__continuation);
|
||||
`,
|
||||
sandbox
|
||||
);
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
*/
|
||||
package org.jetbrains.kotlin.js.test.handlers
|
||||
|
||||
import com.google.gwt.dev.js.ThrowExceptionOnErrorReporter
|
||||
import com.google.gwt.dev.js.rhino.CodePosition
|
||||
import com.google.gwt.dev.js.rhino.offsetOf
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.TranslationMode
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.parser.parseFunction
|
||||
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
||||
import org.jetbrains.kotlin.js.test.debugger.*
|
||||
import org.jetbrains.kotlin.js.test.utils.getAllFilesForRunner
|
||||
@@ -15,9 +23,7 @@ import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
import org.jetbrains.kotlin.test.utils.SteppingTestLoggedData
|
||||
import org.jetbrains.kotlin.test.utils.checkSteppingTestResult
|
||||
import org.jetbrains.kotlin.test.utils.formatAsSteppingTestExpectation
|
||||
import org.jetbrains.kotlin.test.utils.*
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
@@ -39,7 +45,7 @@ import java.net.URISyntaxException
|
||||
* supported.
|
||||
*
|
||||
*/
|
||||
class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(testServices) {
|
||||
class JsDebugRunner(testServices: TestServices, private val localVariables: Boolean) : AbstractJsArtifactsCollector(testServices) {
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
|
||||
if (someAssertionWasFailed) return
|
||||
|
||||
@@ -69,7 +75,7 @@ class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(t
|
||||
mainModule: TestModule,
|
||||
) {
|
||||
val originalFile = mainModule.files.first { !it.isAdditional }.originalFile
|
||||
val debuggerFacade = NodeJsDebuggerFacade(jsFilePath)
|
||||
val debuggerFacade = NodeJsDebuggerFacade(jsFilePath, localVariables)
|
||||
|
||||
val jsFile = File(jsFilePath)
|
||||
|
||||
@@ -105,7 +111,7 @@ class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(t
|
||||
repeatedlyStepInto { callFrame ->
|
||||
callFrame.isInFileUnderTest().also {
|
||||
if (it)
|
||||
addCallFrameInfoToLoggedItems(sourceMap, callFrame, loggedItems)
|
||||
addCallFrameInfoToLoggedItems(jsFile, sourceMap, callFrame, loggedItems)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +126,8 @@ class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(t
|
||||
)
|
||||
}
|
||||
|
||||
private fun addCallFrameInfoToLoggedItems(
|
||||
private suspend fun NodeJsDebuggerFacade.Context.addCallFrameInfoToLoggedItems(
|
||||
jsFile: File,
|
||||
sourceMap: SourceMap,
|
||||
topMostCallFrame: Debugger.CallFrame,
|
||||
loggedItems: MutableList<SteppingTestLoggedData>
|
||||
@@ -139,6 +146,7 @@ class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(t
|
||||
sourceLine + 1,
|
||||
originalFunctionName ?: topMostCallFrame.functionName,
|
||||
false,
|
||||
getLocalVariables(jsFile, sourceMap, topMostCallFrame),
|
||||
)
|
||||
loggedItems.add(SteppingTestLoggedData(sourceLine + 1, false, expectation))
|
||||
}
|
||||
@@ -164,7 +172,7 @@ class JsDebugRunner(testServices: TestServices) : AbstractJsArtifactsCollector(t
|
||||
*
|
||||
* @param jsFilePath the test file to execute and debug.
|
||||
*/
|
||||
private class NodeJsDebuggerFacade(jsFilePath: String) {
|
||||
private class NodeJsDebuggerFacade(jsFilePath: String, private val localVariables: Boolean) {
|
||||
|
||||
private val inspector =
|
||||
NodeJsInspectorClient("js/js.tests/test/org/jetbrains/kotlin/js/test/debugger/stepping_test_executor.js", listOf(jsFilePath))
|
||||
@@ -173,6 +181,8 @@ private class NodeJsDebuggerFacade(jsFilePath: String) {
|
||||
|
||||
private var pausedEvent: Debugger.Event.Paused? = null
|
||||
|
||||
private val sourceCache = mutableMapOf<URI, String>()
|
||||
|
||||
init {
|
||||
inspector.onEvent { event ->
|
||||
when (event) {
|
||||
@@ -220,6 +230,100 @@ private class NodeJsDebuggerFacade(jsFilePath: String) {
|
||||
}
|
||||
|
||||
suspend fun waitForResumeEvent() = waitForConditionToBecomeTrue { pausedEvent == null }
|
||||
|
||||
suspend fun getLocalVariables(
|
||||
jsFile: File,
|
||||
sourceMap: SourceMap,
|
||||
callFrame: Debugger.CallFrame
|
||||
): List<LocalVariableRecord>? {
|
||||
if (!localVariables) return null
|
||||
val functionScope = callFrame.scopeChain.find { it.type in setOf(Debugger.ScopeType.LOCAL, Debugger.ScopeType.CLOSURE) }
|
||||
?: return null
|
||||
val scopeStart = functionScope.startLocation?.toCodePosition() ?: error("Missing scope location")
|
||||
val scopeEnd = functionScope.endLocation?.toCodePosition() ?: error("Missing scope location")
|
||||
val jsFileURI = jsFile.makeURI()
|
||||
require(URI(scriptUrlByScriptId(functionScope.startLocation.scriptId)) == jsFileURI) {
|
||||
"Invalid scope location: $scopeStart. Expected scope location to be in $jsFile"
|
||||
}
|
||||
|
||||
val sourceText = sourceCache.getOrPut(jsFileURI, jsFile::readText)
|
||||
|
||||
val scopeText = sourceText.let {
|
||||
it.substring(it.offsetOf(scopeStart), it.offsetOf(scopeEnd))
|
||||
}
|
||||
|
||||
val prefix = "function"
|
||||
|
||||
// Function scope starts with an open paren, so we need to add the keyword to make it valid JavaScript.
|
||||
// TODO: This will not work with arrows. As of 2022 we don't generate them, but we might in the future.
|
||||
val parseableScopeText = prefix + scopeText
|
||||
val scope = JsProgram().scope
|
||||
val jsFunction = parseFunction(
|
||||
parseableScopeText,
|
||||
jsFile.name,
|
||||
CodePosition(scopeStart.line, scopeStart.offset - prefix.length),
|
||||
0,
|
||||
ThrowExceptionOnErrorReporter,
|
||||
scope
|
||||
) ?: error("Could not parse scope: \n$parseableScopeText")
|
||||
|
||||
val variables = mutableListOf<SourceInfoAwareJsNode /* JsVars.JsVar | JsParameter */>()
|
||||
|
||||
object : JsVisitor() {
|
||||
override fun visitElement(node: JsNode) {
|
||||
node.acceptChildren(this)
|
||||
}
|
||||
|
||||
override fun visit(x: JsVars.JsVar) {
|
||||
super.visit(x)
|
||||
variables.add(x)
|
||||
}
|
||||
|
||||
override fun visitParameter(x: JsParameter) {
|
||||
super.visitParameter(x)
|
||||
variables.add(x)
|
||||
}
|
||||
}.accept(jsFunction)
|
||||
|
||||
val nameMapping = variables.mapNotNull { variable ->
|
||||
if (variable !is HasName) error("Unexpected JsNode: $variable")
|
||||
|
||||
// Filter out variables declared in nested functions
|
||||
if (!jsFunction.scope.hasOwnName(variable.name.toString())) return@mapNotNull null
|
||||
|
||||
val location = variable.source
|
||||
if (location !is JsLocation?) error("JsLocation expected. Found instead: $location")
|
||||
if (location == null)
|
||||
null
|
||||
else sourceMap.segmentForGeneratedLocation(location.startLine, location.startChar)?.name?.let {
|
||||
it to variable.name.toString()
|
||||
}
|
||||
}
|
||||
|
||||
if (nameMapping.isEmpty()) return emptyList()
|
||||
|
||||
val expression = nameMapping.joinToString(separator = ",", prefix = "[", postfix = "]") { (_, generatedName) ->
|
||||
"__makeValueDescriptionForSteppingTests($generatedName)"
|
||||
}
|
||||
val evaluationResult = debugger.evaluateOnCallFrame(callFrame.callFrameId, expression, returnByValue = true)
|
||||
if (evaluationResult.exceptionDetails != null) {
|
||||
evaluationResult.exceptionDetails.rethrow()
|
||||
}
|
||||
|
||||
val valueDescriptions =
|
||||
Json.Default.decodeFromJsonElement<List<ValueDescription?>>(evaluationResult.result.value ?: error("missing value"))
|
||||
|
||||
return nameMapping.mapIndexedNotNull { i, (originalName, _) ->
|
||||
valueDescriptions[i]?.toLocalVariableRecord(originalName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Runtime.ExceptionDetails.rethrow(): Nothing {
|
||||
if (exception?.description != null) error(exception.description)
|
||||
if (scriptId == null) error(text)
|
||||
val scriptURL = scriptUrls[scriptId] ?: url ?: error(text)
|
||||
error("$text ($scriptURL:$lineNumber:$columnNumber)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +332,8 @@ private fun File.makeURI(): URI = absoluteFile.toURI().withAuthority("")
|
||||
private fun URI.withAuthority(newAuthority: String?) =
|
||||
URI(scheme, newAuthority, path, query, fragment)
|
||||
|
||||
private fun Debugger.Location.toCodePosition() = CodePosition(lineNumber, columnNumber ?: -1)
|
||||
|
||||
private fun SourceMap.segmentForGeneratedLocation(lineNumber: Int, columnNumber: Int?): SourceMapSegment? {
|
||||
|
||||
val group = groups.getOrNull(lineNumber)?.takeIf { it.segments.isNotEmpty() } ?: return null
|
||||
@@ -245,3 +351,16 @@ private fun SourceMap.segmentForGeneratedLocation(lineNumber: Int, columnNumber:
|
||||
group.segments[candidateIndex - 1]
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private class ValueDescription(val isNull: Boolean, val isReferenceType: Boolean, val valueDescription: String, val typeName: String) {
|
||||
fun toLocalVariableRecord(variableName: String) = LocalVariableRecord(
|
||||
variable = variableName,
|
||||
variableType = null, // In JavaScript variables are untyped
|
||||
value = when {
|
||||
isNull -> LocalNullValue
|
||||
isReferenceType -> LocalReference("", typeName)
|
||||
else -> LocalPrimitive(valueDescription, typeName)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.js.test.ir
|
||||
|
||||
import org.jetbrains.kotlin.js.test.AbstractJsBlackBoxCodegenTestBase
|
||||
import org.jetbrains.kotlin.js.test.JsAdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.js.test.JsSteppingTestAdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.js.test.converters.JsIrBackendFacade
|
||||
import org.jetbrains.kotlin.js.test.converters.JsKlibBackendFacade
|
||||
import org.jetbrains.kotlin.js.test.converters.incremental.RecompileModuleJsIrBackendFacade
|
||||
@@ -157,8 +158,25 @@ open class AbstractIrJsSteppingTest : AbstractJsIrTest(
|
||||
defaultDirectives {
|
||||
+JsEnvironmentConfigurationDirectives.NO_COMMON_FILES
|
||||
}
|
||||
useAdditionalSourceProviders(::JsSteppingTestAdditionalSourceProvider)
|
||||
jsArtifactsHandlersStep {
|
||||
useHandlers(::JsDebugRunner)
|
||||
useHandlers({ JsDebugRunner(it, localVariables = false) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractIrJsLocalVariableTest : AbstractJsIrTest(
|
||||
pathToTestDir = "compiler/testData/debug/localVariables/",
|
||||
testGroupOutputDirPrefix = "debug/localVariables/"
|
||||
) {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
commonConfigurationForJsBlackBoxCodegenTest()
|
||||
defaultDirectives {
|
||||
+JsEnvironmentConfigurationDirectives.NO_COMMON_FILES
|
||||
}
|
||||
useAdditionalSourceProviders(::JsSteppingTestAdditionalSourceProvider)
|
||||
jsArtifactsHandlersStep {
|
||||
useHandlers({ JsDebugRunner(it, localVariables = true) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.test.ir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/debug/localVariables")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class IrJsLocalVariableTestGenerated extends AbstractIrJsLocalVariableTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInLocalVariables() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/assignment.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("catchClause.kt")
|
||||
public void testCatchClause() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/catchClause.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("copyFunction.kt")
|
||||
public void testCopyFunction() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/copyFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("directInvoke.kt")
|
||||
public void testDirectInvoke() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/directInvoke.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doWhile.kt")
|
||||
public void testDoWhile() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/doWhile.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyFun.kt")
|
||||
public void testEmptyFun() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/emptyFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forLoopMultiline.kt")
|
||||
public void testForLoopMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/forLoopMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineProperty.kt")
|
||||
public void testInlineProperty() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/inlineProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsCode.kt")
|
||||
public void testJsCode() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFun.kt")
|
||||
public void testLocalFun() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/localFun.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunUnused.kt")
|
||||
public void testLocalFunUnused() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/localFunUnused.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally.kt")
|
||||
public void testTryFinally() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally10.kt")
|
||||
public void testTryFinally10() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally10.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally11.kt")
|
||||
public void testTryFinally11() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally11.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally12.kt")
|
||||
public void testTryFinally12() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally12.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally13.kt")
|
||||
public void testTryFinally13() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally13.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally14.kt")
|
||||
public void testTryFinally14() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally14.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally15.kt")
|
||||
public void testTryFinally15() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally15.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally16.kt")
|
||||
public void testTryFinally16() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally16.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally17.kt")
|
||||
public void testTryFinally17() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally17.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally2.kt")
|
||||
public void testTryFinally2() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally3.kt")
|
||||
public void testTryFinally3() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally4.kt")
|
||||
public void testTryFinally4() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally5.kt")
|
||||
public void testTryFinally5() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally5.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally6.kt")
|
||||
public void testTryFinally6() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally6.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally7.kt")
|
||||
public void testTryFinally7() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally7.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally8.kt")
|
||||
public void testTryFinally8() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally8.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("tryFinally9.kt")
|
||||
public void testTryFinally9() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/tryFinally9.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreNames.kt")
|
||||
public void testUnderscoreNames() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/underscoreNames.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/debug/localVariables/constructors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Constructors {
|
||||
@Test
|
||||
public void testAllFilesPresentInConstructors() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/constructors"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleConstructors.kt")
|
||||
public void testMultipleConstructors() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/constructors/multipleConstructors.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("property.kt")
|
||||
public void testProperty() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/constructors/property.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/debug/localVariables/destructuring")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Destructuring {
|
||||
@Test
|
||||
public void testAllFilesPresentInDestructuring() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/destructuring"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignment.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentCustomComponentNs.kt")
|
||||
public void testAssignmentCustomComponentNs() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignmentCustomComponentNs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentCustomComponentNsMultiline.kt")
|
||||
public void testAssignmentCustomComponentNsMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignmentCustomComponentNsMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentMultiline.kt")
|
||||
public void testAssignmentMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignmentMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentUnderscoreNames.kt")
|
||||
public void testAssignmentUnderscoreNames() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignmentUnderscoreNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("assignmentUnderscoreNamesMultiline.kt")
|
||||
public void testAssignmentUnderscoreNamesMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/assignmentUnderscoreNamesMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forLoop.kt")
|
||||
public void testForLoop() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/forLoop.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forLoopMultiline.kt")
|
||||
public void testForLoopMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/forLoopMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/lambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaCustomComponentNs.kt")
|
||||
public void testLambdaCustomComponentNs() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/lambdaCustomComponentNs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaCustomComponentNsMultiline.kt")
|
||||
public void testLambdaCustomComponentNsMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/lambdaCustomComponentNsMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaMultiline.kt")
|
||||
public void testLambdaMultiline() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/lambdaMultiline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaMultipleDestructs.kt")
|
||||
public void testLambdaMultipleDestructs() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/destructuring/lambdaMultipleDestructs.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/debug/localVariables/receiverMangling")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ReceiverMangling {
|
||||
@Test
|
||||
public void testAllFilesPresentInReceiverMangling() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/receiverMangling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedThisField.kt")
|
||||
public void testCapturedThisField() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labeledThisParameterLabel.kt")
|
||||
public void testLabeledThisParameterLabel() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithExtensionReceiver.kt")
|
||||
public void testLambdaWithExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/lambdaWithExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("receiverParameter.kt")
|
||||
public void testReceiverParameter() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/receiverParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleCapturedReceiver.kt")
|
||||
public void testSimpleCapturedReceiver() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleCapturedReceiverWithLabel.kt")
|
||||
public void testSimpleCapturedReceiverWithLabel() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleCapturedReceiverWithParenthesis.kt")
|
||||
public void testSimpleCapturedReceiverWithParenthesis() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/debug/localVariables/suspend")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Suspend {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspend() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/suspend"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineLocalsStateMachineTransform.kt")
|
||||
public void testInlineLocalsStateMachineTransform() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/inlineLocalsStateMachineTransform.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localsStateMachineTransform.kt")
|
||||
public void testLocalsStateMachineTransform() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/localsStateMachineTransform.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mergeLvt.kt")
|
||||
public void testMergeLvt() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/mergeLvt.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/simple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreNames.kt")
|
||||
public void testUnderscoreNames() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/underscoreNames.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/debug/localVariables/suspend/completion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Completion {
|
||||
@Test
|
||||
public void testAllFilesPresentInCompletion() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/suspend/completion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonStaticSimple.kt")
|
||||
public void testNonStaticSimple() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/nonStaticSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonStaticStateMachine.kt")
|
||||
public void testNonStaticStateMachine() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/nonStaticStateMachine.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("staticSimple.kt")
|
||||
public void testStaticSimple() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/staticSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("staticSimpleReceiver.kt")
|
||||
public void testStaticSimpleReceiver() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/staticSimpleReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("staticStateMachine.kt")
|
||||
public void testStaticStateMachine() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/staticStateMachine.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("staticStateMachineReceiver.kt")
|
||||
public void testStaticStateMachineReceiver() throws Exception {
|
||||
runTest("compiler/testData/debug/localVariables/suspend/completion/staticStateMachineReceiver.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-6
@@ -247,12 +247,6 @@ public class IrJsSteppingTestGenerated extends AbstractIrJsSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/inlineSimpleCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsCode.kt")
|
||||
public void testJsCode() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt15259.kt")
|
||||
public void testKt15259() throws Exception {
|
||||
|
||||
-6
@@ -205,12 +205,6 @@ public class JsIrLineNumberTestGenerated extends AbstractJsIrLineNumberTest {
|
||||
runTest("js/js.translator/testData/lineNumbers/isOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsCode.kt")
|
||||
public void testJsCode() throws Exception {
|
||||
runTest("js/js.translator/testData/lineNumbers/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithClosure.kt")
|
||||
public void testLambdaWithClosure() throws Exception {
|
||||
|
||||
+2
-2
@@ -19,5 +19,5 @@ fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
// LINES(JS): 1 11 3 3 5 5 6 6 8 8 9 9 2 2 * 13 20 15 15 18 18
|
||||
// LINES(JS_IR): 1 1 3 3 * 5 5 5 6 6 * 8 8 8 9 9 * 13 13 15 15 17 17 17 18 18
|
||||
// LINES(JS): 1 11 3 3 5 5 6 6 8 8 9 9 2 2 * 13 20 15 15 18 18
|
||||
// LINES(JS_IR): 1 1 3 3 * 5 5 6 6 * 8 8 9 9 * 13 13 15 15 17 17 18 18
|
||||
|
||||
@@ -15,4 +15,4 @@ fun A.foo() {
|
||||
fun baz() = 23
|
||||
|
||||
// LINES(JS): 1 * 5 5 5 6 9 7 7 8 8 * 3 13 4 4 11 11 12 12 15 15 15
|
||||
// LINES(JS_IR): 1 1 3 3 4 4 11 11 12 12 15 15 15 15 5 5 * 6 7 7 8 8
|
||||
// LINES(JS_IR): 1 1 3 3 4 11 11 12 12 15 15 15 15 5 3 4 5 * 6 7 7 8 8
|
||||
|
||||
+2
-2
@@ -5,5 +5,5 @@ fun box(x: Int, y: Int): Int {
|
||||
return foo(y)
|
||||
}
|
||||
|
||||
// LINES(JS): 2 2 2 4 4 1 6 2 2 5 5
|
||||
// LINES(JS_IR): 1 1 5 5 2 4 4 4
|
||||
// LINES(JS): 2 2 2 4 4 1 6 2 2 5 5
|
||||
// LINES(JS_IR): 1 1 5 5 2 1 3 4 4 4
|
||||
|
||||
+2
-2
@@ -11,5 +11,5 @@ fun baz() = 1
|
||||
|
||||
fun bar() = 2
|
||||
|
||||
// LINES(JS): 1 3 3 2 2 4 3 4 4 4 5 5 2 8 8 10 10 10 12 12 12
|
||||
// LINES(JS_IR): 1 * 3 3 4 5 * 8 8 10 10 10 10 12 12 12 12
|
||||
// LINES(JS): 1 3 3 2 2 4 3 4 4 4 5 5 2 8 8 10 10 10 12 12 12
|
||||
// LINES(JS_IR): 1 2 * 3 4 5 * 8 8 10 10 10 10 12 12 12 12
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ suspend fun bar(): Unit {
|
||||
}
|
||||
|
||||
// LINES(JS): 39 4 4 4 7 5 5 45 45 5 93 45 5 5 6 4 4 4 9 15 9 9 9 * 9 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14 * 9 15 9 9 9 9
|
||||
// LINES(JS_IR): 4 4 * 19 * 19 19 * 5 * 45 * 50 50 93 93 3 45 3 45 45 6 6 19 19 7 7 9 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 13 14 14 15 15
|
||||
// LINES(JS_IR): 4 4 * 19 * 19 * 5 * 45 * 50 93 93 3 45 3 45 45 6 6 19 7 7 9 9 * 9 * 9 * 10 10 * 11 * 11 12 12 * 13 * 13 14 14 15 15
|
||||
|
||||
@@ -9,4 +9,4 @@ suspend fun delay() {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 6 1 1 * 1 6 2 2 2 2 2 * 3 3 4 4 4 4 4 5 5 * 1 6 1 1 1 1 8 9
|
||||
// LINES(JS_IR): 1 1 * 8 8 9 9 * 1 * 2 * 3 3 3 * 5 5 6 6
|
||||
// LINES(JS_IR): 1 1 * 8 8 9 9 1 * 1 * 2 * 3 3 3 * 5 5 6 6
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ data class A(
|
||||
)
|
||||
|
||||
// LINES(JS): 1 2 3 * 1 2 2 1 3 3 1 1 1 2 3 1 1 1 2 3 1 1 1 2 3 1 1 1 1 1 2 3
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 2 2 2 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 * 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
// LINES(JS_IR): 1 2 3 1 2 2 3 3 2 2 2 3 3 3 1 1 1 1 1 1 1 2 3 1 1 1 1 2 3 1 1 * 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
|
||||
@@ -14,4 +14,4 @@ class Delegate(val f: () -> Int) {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 2 3 * 2 2 3 3 3 3 * 6 8 7 7 10 10 11 13 12 12
|
||||
// LINES(JS_IR): 3 3 3 3 1 1 3 3 3 2 3 3 3 2 1 2 6 6 7 7 10 10 10 10 10 10 10 11 12 12 2 2
|
||||
// LINES(JS_IR): 3 3 3 3 1 1 3 3 3 2 3 3 3 2 1 2 6 6 7 7 10 10 10 10 10 10 10 11 12 12 2 2 18 * 2
|
||||
|
||||
@@ -16,4 +16,4 @@ class B {
|
||||
}
|
||||
|
||||
// LINES(JS): 3 4 5 * 4 4 4 * 8 9 11 10 10 13 15 14 14
|
||||
// LINES(JS_IR): 3 3 5 5 4 5 5 5 4 1 4 5 4 5 5 5 4 1 4 8 8 9 10 10 13 14 14 4 4 * 4 4
|
||||
// LINES(JS_IR): 3 3 5 5 4 5 5 5 4 1 4 5 4 5 5 5 4 1 4 8 8 9 10 10 13 14 14 4 4 20 * 4 20 * 4 4 20 * 4 20
|
||||
|
||||
+1
-1
@@ -28,4 +28,4 @@ fun bar(f: (Pair<String, String>) -> Unit) {
|
||||
|
||||
|
||||
// LINES(JS): 15 22 16 16 17 18 20 20 21 21 22 22 3 23 9 9 9 9 4 9 9 9 5 5 6 7 11 11 12 12 15 15 25 27 26 26 * 1 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 9 9 9 4 9 9 6 6 9 7 7 9 11 11 12 12 15 15 25 25 26 26 15 15 17 17 16 18 18 16 20 20 21 21 22 22 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 9 9 4 9 6 9 7 9 11 11 12 12 15 15 25 25 26 26 15 16 15 17 16 18 16 20 20 21 21 22 22 * 1
|
||||
|
||||
@@ -33,4 +33,4 @@ inline operator fun P.component1() = a
|
||||
inline operator fun P.component2() = b
|
||||
|
||||
// LINES(JS): 15 22 17 17 31 18 18 33 20 20 21 21 22 22 3 23 9 9 9 9 4 9 9 9 6 6 31 7 7 33 11 11 12 12 15 15 25 27 26 26 29 29 29 * 31 31 31 33 33 33 * 1 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 9 9 9 4 9 9 * 6 * 31 31 9 6 6 * 7 * 33 33 9 7 7 11 11 12 12 15 15 25 25 26 26 29 29 29 29 29 29 29 29 29 29 29 29 31 31 31 31 33 33 33 33 15 15 * 17 * 31 31 16 17 17 * 18 * 33 33 16 18 18 20 20 21 21 22 22 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 9 9 4 9 * 6 * 31 31 9 6 * 7 * 33 33 9 7 11 11 12 12 15 15 25 25 26 26 29 29 29 29 29 29 29 29 29 29 29 29 31 31 31 31 33 33 33 33 15 16 15 * 17 * 31 31 16 17 * 18 * 33 33 16 18 20 20 21 21 22 22 * 1
|
||||
|
||||
@@ -13,5 +13,5 @@ fun box() {
|
||||
)
|
||||
}
|
||||
|
||||
// LINES(JS): 1 14 8 8 7 3 2 2 3 3 3 8 8 11 11 * 3 7 12 3 3 4 4
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 4 4 * 8 8 8 8 8 11 11 * 7 12
|
||||
// LINES(JS): 1 14 8 8 7 3 2 2 3 3 3 8 8 11 11 * 3 7 12 3 3 4 4
|
||||
// LINES(JS_IR): 1 1 2 3 3 4 4 * 8 8 8 8 11 11 * 7 12
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ fun box(x: String?) {
|
||||
fun foo() = "bar"
|
||||
|
||||
// LINES(JS): 3 8 7 7 4 4 4 5 5 7 7 7 7 * 5 4 5 10 10 10 * 1 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 4 5 5 * 5 5 * 7 7 7 * 5 4 4 10 10 10 10 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 4 5 * 5 5 * 7 7 7 * 5 4 4 10 10 10 10 * 1
|
||||
|
||||
@@ -7,4 +7,4 @@ enum class Foo {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 1 1 1 1 1 1 1 2 2 4 * 2 2 2 2 4 4 5 5 * 4 4 4 4 4 4 4 * 1 1 1 * 1 1 1 1 1 1
|
||||
// LINES(JS_IR): 4 4 * 5 5 5 5 5 * 1 * 1 * 1 1
|
||||
// LINES(JS_IR): 4 4 * 5 5 5 5 5 * 1 * 1 1 * 1 1
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ enum class E {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 1 1 1 1 1 1 1 2 2 4 8 * 2 2 2 2 4 4 4 5 5 5 * 4 4 4 4 8 8 8 9 9 9 * 8 8 8 8 * 1 1 1 * 1 1 1 1 1 1 1 1 1 1
|
||||
// LINES(JS_IR): 4 4 * 5 5 5 * 8 8 * 9 9 9 * 1 * 1 * 1 1
|
||||
// LINES(JS_IR): 4 4 * 5 5 5 * 8 8 * 9 9 9 * 1 * 1 1 * 1 1
|
||||
|
||||
+1
-1
@@ -18,4 +18,4 @@ fun box() {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 18 2 2 10 2 2 2 2 2 2 3 3 6 6 6 6 7 7 10 10 10 10 10 10 11 11 14 14 15 15 15 15 16 16
|
||||
// LINES(JS_IR): 1 1 * 2 * 35 * 18 * 12 2 18 18 35 35 2 2 2 2 2 2 2 2 2 2 2 2 3 3 6 6 6 6 6 6 6 6 6 7 7 10 10 10 10 10 10 11 11 14 14 15 15 15 15 15 15 15 15 15 15 15 16 16
|
||||
// LINES(JS_IR): 1 1 * 2 * 35 * 18 * 12 2 18 18 35 35 2 2 2 2 2 2 2 2 3 3 6 6 6 6 6 6 6 7 7 10 10 10 10 11 11 14 15 15 15 15 15 15 15 15 16 16
|
||||
|
||||
+2
-2
@@ -8,5 +8,5 @@ fun foo(x: Int) {
|
||||
println(y)
|
||||
}
|
||||
|
||||
// LINES(JS): 1 9 2 2 3 3 4 4 5 5 6 6 7 7 8 8
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 3 3 4 4 5 5 6 6 7 7 8 8
|
||||
// LINES(JS): 1 9 2 2 3 3 4 4 5 5 6 6 7 7 8 8
|
||||
// LINES(JS_IR): 1 1 2 3 3 3 4 4 5 5 6 6 7 7 8 8
|
||||
|
||||
@@ -12,4 +12,4 @@ inline fun foo(x: Int) {
|
||||
fun bar() = 23
|
||||
|
||||
// LINES(JS): 3 5 4 4 8 8 9 9 7 10 8 8 9 9 12 12 12 * 1 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 4 * 4 4 8 8 9 9 7 7 8 8 9 9 12 12 12 12 * 1
|
||||
// LINES(JS_IR): 1 1 1 1 1 1 1 1 * 3 3 4 * 4 8 8 9 9 7 7 8 8 9 9 12 12 12 12 * 1
|
||||
|
||||
@@ -10,4 +10,4 @@ fun bar() {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 1 1 1 6 2 2 3 3 4 4 8 10 2 2 9 2 3 3 4 4
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 3 4 4 8 8 9 * 2 2 3 3 3 4 4
|
||||
// LINES(JS_IR): 1 1 2 3 3 3 4 4 8 8 9 * 2 3 3 3 4 4
|
||||
|
||||
+1
-1
@@ -22,4 +22,4 @@ fun bar(x: Int) {
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 1 1 1 1 1 1 1 17 2 2 3 3 4 7 7 9 9 10 10 11 14 14 16 16 19 22 20 20 20 20 17 2 2 3 3 4 3 7 7 9 9 10 10 11 10 14 14 16 16 20 21 21
|
||||
// LINES(JS_IR): 1 1 2 2 2 3 3 4 7 7 9 9 9 10 10 11 14 14 16 16 19 19 * 20 * 20 20 2 2 2 3 3 4 * 7 7 9 9 9 10 10 11 * 14 14 16 16 20 20 21 21
|
||||
// LINES(JS_IR): 1 1 2 2 2 3 3 4 7 7 9 9 9 10 10 11 14 14 16 16 19 19 * 20 * 20 2 2 2 3 3 4 * 7 7 9 9 9 10 10 11 * 14 14 16 16 20 20 21 21
|
||||
|
||||
+3
-1
@@ -5,5 +5,7 @@ fun foo() {
|
||||
println("after: $x")
|
||||
}
|
||||
|
||||
// DONT_TARGET_EXACT_BACKEND: JS_IR
|
||||
// ^There is a better stepping test
|
||||
|
||||
// LINES(JS): 1 6 2 2 3 3 4 4 5 5
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 4 4 5 5
|
||||
|
||||
@@ -5,4 +5,4 @@ fun foo(x: Int): () -> Unit = {
|
||||
fun bar() = 23
|
||||
|
||||
// LINES(JS): 1 1 1 3 2 2 3 3 1 1 1 5 5 5
|
||||
// LINES(JS_IR): 1 1 3 3 1 5 5 5 5 1 1 2 2 3 3
|
||||
// LINES(JS_IR): 1 1 3 3 1 5 5 5 5 1 1 1 2 2 3 3
|
||||
|
||||
@@ -24,5 +24,5 @@ fun baz() = "baz"
|
||||
|
||||
fun boo() = "boo"
|
||||
|
||||
// LINES(JS): 1 17 9 4 6 6 7 7 3 3 3 * 13 12 13 13 14 19 21 20 20 23 23 23 25 25 25
|
||||
// LINES(JS_IR): 1 1 * 2 * 20 * 4 * 6 6 7 * 3 20 20 * 11 * 20 * 12 12 12 13 14 20 20 19 19 20 20 23 23 23 23 25 25 25 25
|
||||
// LINES(JS): 1 17 9 4 6 6 7 7 3 3 3 * 13 12 13 13 14 19 21 20 20 23 23 23 25 25 25
|
||||
// LINES(JS_IR): 1 1 * 2 * 20 * 4 * 6 7 * 3 20 20 * 11 * 20 * 12 12 13 14 20 20 19 19 20 20 23 23 23 23 25 25 25 25
|
||||
|
||||
+2
-2
@@ -7,5 +7,5 @@ fun box(
|
||||
println(y)
|
||||
}
|
||||
|
||||
// LINES(JS): 1 8 2 2 2 2 3 3 3 4 6 6 7 7
|
||||
// LINES(JS_IR): 1 2 4 6 6 7 7
|
||||
// LINES(JS): 1 8 2 2 2 2 3 3 3 4 6 6 7 7
|
||||
// LINES(JS_IR): 1 2 3 2 4 6 6 7 7
|
||||
|
||||
@@ -25,5 +25,5 @@ class C : A {
|
||||
)
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 3 * 1 1 1 1 1 1 7 * 9 10 11 * 15 15 16 17 14 19 15 15 22 22 23 24 22 22
|
||||
// LINES(JS_IR): 1 1 * 3 * 7 7 9 9 10 11 15 16 17 15 19 * 15 * 22 23 24 23 * 22 * 14
|
||||
// LINES(JS): 1 1 3 * 1 1 1 1 1 1 7 * 9 10 11 * 15 15 16 17 14 19 15 15 22 22 23 24 22 22
|
||||
// LINES(JS_IR): 1 1 * 3 * 7 7 9 9 10 11 15 15 16 17 15 19 * 15 15 * 22 23 24 23 * 22 * 14
|
||||
|
||||
@@ -8,5 +8,5 @@ enum class E {
|
||||
}
|
||||
}
|
||||
|
||||
// LINES(JS): 1 1 1 1 1 1 1 1 1 2 2 3 3 4 * 2 2 2 2 * 3 3 3 3 4 4 4 6 6 * 4 4 4 4 * 1 1 1 * 1 1 1 1 1 1 1 1 1 1
|
||||
// LINES(JS_IR): 4 4 * 6 6 * 1 * 1 * 1 1
|
||||
// LINES(JS): 1 1 1 1 1 1 1 1 1 2 2 3 3 4 * 2 2 2 2 * 3 3 3 3 4 4 4 6 6 * 4 4 4 4 * 1 1 1 * 1 1 1 1 1 1 1 1 1 1
|
||||
// LINES(JS_IR): 4 4 * 6 6 * 1 * 1 1 * 1 1
|
||||
|
||||
+2
-2
@@ -7,5 +7,5 @@ fun foo() {
|
||||
A(23, "foo")
|
||||
}
|
||||
|
||||
// LINES(JS): 1 2 3 * 6 8 7 7
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 2 2 2 3 3 3 6 6 7 7
|
||||
// LINES(JS): 1 2 3 * 6 8 7 7
|
||||
// LINES(JS_IR): 1 2 3 1 2 2 3 3 2 2 2 3 3 3 6 6 7 7
|
||||
|
||||
@@ -18,5 +18,5 @@ fun box(x: Int) {
|
||||
)
|
||||
}
|
||||
|
||||
// LINES(JS): 1 19 4 4 3 3 4 6 9 9 6 11 13 13 11 16 16 3 2
|
||||
// LINES(JS_IR): 1 1 4 4 2 8 7 6 7 8 9 12 11 12 13 16
|
||||
// LINES(JS): 1 19 4 4 3 3 4 6 9 9 6 11 13 13 11 16 16 3 2
|
||||
// LINES(JS_IR): 1 1 4 2 8 7 6 7 8 9 12 11 12 13 16
|
||||
|
||||
+2
-2
@@ -28,5 +28,5 @@ fun four() = 4
|
||||
|
||||
fun five() = 5
|
||||
|
||||
// LINES(JS): 1 19 4 4 3 6 4 6 4 7 4 8 9 9 11 4 11 4 12 13 13 16 16 2 21 21 21 23 23 23 25 25 25 27 27 27 29 29 29
|
||||
// LINES(JS_IR): 1 1 4 4 2 8 7 6 7 8 9 12 11 12 13 16 21 21 21 21 23 23 23 23 25 25 25 25 27 27 27 27 29 29 29 29
|
||||
// LINES(JS): 1 19 4 4 3 6 4 6 4 7 4 8 9 9 11 4 11 4 12 13 13 16 16 2 21 21 21 23 23 23 25 25 25 27 27 27 29 29 29
|
||||
// LINES(JS_IR): 1 1 4 2 8 7 6 7 8 9 12 11 12 13 16 21 21 21 21 23 23 23 23 25 25 25 25 27 27 27 27 29 29 29 29
|
||||
|
||||
+2
-2
@@ -13,5 +13,5 @@ fun foo(): Int = 23
|
||||
|
||||
fun bar(): IntRange = 1000..2000
|
||||
|
||||
// LINES(JS): 1 10 2 2 2 2 3 3 4 4 5 5 6 6 7 7 8 8 12 12 12 14 14 14
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 4 4 5 5 6 6 7 7 7 7 7 7 8 8 12 12 12 12 14 14 14 14
|
||||
// LINES(JS): 1 10 2 2 2 2 3 3 4 4 5 5 6 6 7 7 8 8 12 12 12 14 14 14
|
||||
// LINES(JS_IR): 1 1 2 3 3 4 4 5 5 6 6 7 7 7 7 8 8 12 12 12 12 14 14 14 14
|
||||
|
||||
+1
-1
@@ -14,4 +14,4 @@ open class A
|
||||
open class B : A()
|
||||
|
||||
// LINES(JS): 1 10 2 2 2 2 3 3 4 4 5 5 6 6 8 8 12 * 14 14
|
||||
// LINES(JS_IR): 1 1 2 2 3 3 4 4 5 5 6 6 8 8 12 12 14 14 14
|
||||
// LINES(JS_IR): 1 1 2 3 3 4 4 5 5 6 6 8 8 12 12 14 14 14
|
||||
|
||||
@@ -12,5 +12,5 @@ fun box() {
|
||||
}
|
||||
}
|
||||
|
||||
// LINES(JS): 1 13 5 5 4 2 2 3 5 5 8 8 * 3 4 9 3 11 11
|
||||
// LINES(JS_IR): 1 1 2 2 * 3 * 5 5 5 5 5 8 8 * 4 9 * 11 11
|
||||
// LINES(JS): 1 13 5 5 4 2 2 3 5 5 8 8 * 3 4 9 3 11 11
|
||||
// LINES(JS_IR): 1 1 2 * 3 * 5 5 5 5 8 8 * 4 9 * 11 11
|
||||
|
||||
Reference in New Issue
Block a user