Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Applied @radical's suggestions.
  • Loading branch information
ilonatommy authored and github-actions committed Sep 13, 2022
commit d73905af65af2081f84ac9f9f3750ae479f86f44
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ public async Task<JObject> Resolve(ElementAccessExpressionSyntax elementAccess,
// indexing with expressions, e.g. x[a + 1]
else
{
SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(arg + @";", cancellationToken: token);
indexObject = await ExpressionEvaluator.EvaluateSimpleExpression(this, syntaxTree.ToString(), arg.ToString(), variableDefinitions, logger, token);
string expression = arg.ToString();
indexObject = await ExpressionEvaluator.EvaluateSimpleExpression(this, expression, expression, variableDefinitions, logger, token);
string type = indexObject["type"].Value<string>();
if (type != "number")
throw new InvalidOperationException($"Cannot index with an object of type '{type}'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,32 +632,30 @@ public async Task EvaluateIndexingByExpression() => await CheckInspectLocalsAtBr
"DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 5, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })",
wait_for_event_fn: async (pause_location) =>
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

await EvaluateOnCallFrameAndCheck(id,
("f.numList[i + 1]", TNumber(2)),
("f.textList[(2 * j) - 1]", TString("2")),
("f.textList[j - 1]", TString("1")),
("f.numArray[f.numList[j - 1]]", TNumber(2))
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
await EvaluateOnCallFrameAndCheck(id,
("f.numList[i + 1]", TNumber(2)),
("f.textList[(2 * j) - 1]", TString("2")),
("f.textList[j - 1]", TString("1")),
("f.numArray[f.numList[j - 1]]", TNumber(2))
);
});
});

[Fact]
public async Task EvaluateIndexingByExpressionMultidimensional() => await CheckInspectLocalsAtBreakpointSite(
"DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests", "EvaluateLocals", 5, "DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests.EvaluateLocals",
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests:EvaluateLocals'); })",
wait_for_event_fn: async (pause_location) =>
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();

await EvaluateOnCallFrameAndCheck(id,
("f.numArray2D[0, j - 1]", TNumber(1)), // 0, 0
("f.numArray2D[f.idx1, i + j]", TNumber(4)), // 1, 1
("f.numArray2D[(f.idx1 - j) * 5, i + j]", TNumber(2)), // 0, 1
("f.numArray2D[i + j, f.idx1 - 1]", TNumber(3)) // 1, 0
{
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
await EvaluateOnCallFrameAndCheck(id,
("f.numArray2D[0, j - 1]", TNumber(1)), // 0, 0
("f.numArray2D[f.idx1, i + j]", TNumber(4)), // 1, 1
("f.numArray2D[(f.idx1 - j) * 5, i + j]", TNumber(2)), // 0, 1
("f.numArray2D[i + j, f.idx1 - 1]", TNumber(3)) // 1, 0
);
});
});

[ConditionalFact(nameof(RunningOnChrome))]
public async Task EvaluateIndexingByExpressionNegative() => await CheckInspectLocalsAtBreakpointSite(
Expand All @@ -669,7 +667,7 @@ public async Task EvaluateIndexingByExpressionNegative() => await CheckInspectLo
var id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
var (_, res) = await EvaluateOnCallFrame(id, "f.numList[\"a\" + 1]", expect_ok: false );
Assert.Equal("Unable to evaluate element access 'f.numList[\"a\" + 1]': Cannot index with an object of type 'string'", res.Error["message"]?.Value<string>());
});
});

[Fact]
public async Task EvaluateIndexingByMemberVariables() => await CheckInspectLocalsAtBreakpointSite(
Expand Down