Welcome to mirror list, hosted at ThFree Co, Russian Federation.

EvaluateOnCallFrameTests.cs « DebuggerTestSuite « wasm « sdks - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 315ee5f522cb78040f97bbd2d383e44fe34a7546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Xunit;
using WebAssembly.Net.Debugging;

namespace DebuggerTests
{

	public class EvaluateOnCallFrameTests : DebuggerTestBase {

		[Fact]
		public async Task EvaluateThisProperties ()
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", 20, 16,
				"run",
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "a");
					CheckContentValue (evaluate, "1");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "b");
					CheckContentValue (evaluate, "2");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "c");
					CheckContentValue (evaluate, "3");

					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "dt");
					await CheckDateTimeValue (evaluate, new DateTime (2000, 5, 4, 3, 2, 1));
				});

		[Theory]
		[InlineData (58, 3, "EvaluateTestsStructInstanceMethod")]
		[InlineData (74, 3, "GenericInstanceMethodOnStruct<int>")]
		[InlineData (97, 3, "EvaluateTestsGenericStructInstanceMethod")]
		public async Task EvaluateThisPropertiesOnStruct (int line, int col, string method_name)
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", line, col,
				method_name,
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "a");
					CheckContentValue (evaluate, "1");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "b");
					CheckContentValue (evaluate, "2");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "c");
					CheckContentValue (evaluate, "3");

					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "dateTime");
					await CheckDateTimeValue (evaluate, new DateTime (2020, 1, 2, 3, 4, 5));
				});

		[Fact]
		public async Task EvaluateParameters ()
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", 20, 16,
				"run",
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "g");
					CheckContentValue (evaluate, "100");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "h");
					CheckContentValue (evaluate, "200");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "valString");
					CheckContentValue (evaluate, "test");
				});

		[Fact]
		public async Task EvaluateLocals ()
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", 20, 16,
				"run",
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "d");
					CheckContentValue (evaluate, "101");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "e");
					CheckContentValue (evaluate, "102");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "f");
					CheckContentValue (evaluate, "103");

					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "local_dt");
					await CheckDateTimeValue (evaluate, new DateTime (2010, 9, 8, 7, 6, 5));
				});

		[Fact]
		public async Task EvaluateLocalsAsync ()
		{
			var bp_loc = "dotnet://debugger-test.dll/debugger-array-test.cs";
			int line = 227; int col = 3;
			var function_name = "MoveNext";
			await CheckInspectLocalsAtBreakpointSite (
				bp_loc, line, col,
				function_name,
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.ArrayTestsClass:EntryPointForStructMethod', true); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());

					// sc_arg
					{
						var sc_arg = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "sc_arg");
						await CheckValue (sc_arg, TObject ("DebuggerTests.SimpleClass"), "sc_arg#1");

						var sc_arg_props = await GetProperties (sc_arg ["objectId"]?.Value<string> ());
						await CheckProps (sc_arg_props, new {
							X                     = TNumber (10),
							Y                     = TNumber (45),
							Id                    = TString ("sc#Id"),
							Color                 = TEnum   ("DebuggerTests.RGB", "Blue"),
							PointWithCustomGetter = TGetter ("PointWithCustomGetter")
						}, "sc_arg_props#1");
					}

					// local_gs
					{
						var local_gs = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "local_gs");
						await CheckValue (local_gs, TValueType ("DebuggerTests.SimpleGenericStruct<int>"), "local_gs#1");

						var local_gs_props = await GetProperties (local_gs ["objectId"]?.Value<string> ());
						await CheckProps (local_gs_props, new {
							Id    = TObject ("string", is_null: true),
							Color = TEnum   ("DebuggerTests.RGB", "Red"),
							Value = TNumber (0)
						}, "local_gs_props#1");
					}

					// step, check local_gs
					pause_location = await StepAndCheck (StepKind.Over, bp_loc, line + 1, col, function_name);
					{
						var local_gs = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "local_gs");
						await CheckValue (local_gs, TValueType ("DebuggerTests.SimpleGenericStruct<int>"), "local_gs#2");

						var local_gs_props = await GetProperties (local_gs ["objectId"]?.Value<string> ());
						await CheckProps (local_gs_props, new {
							Id    = TString ("local_gs#Id"),
							Color = TEnum   ("DebuggerTests.RGB", "Green"),
							Value = TNumber (4)
						}, "local_gs_props#2");
					}

					// step check sc_arg.Id
					pause_location = await StepAndCheck (StepKind.Over, bp_loc, line + 2, col, function_name);
					{
						var sc_arg = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "sc_arg");
						await CheckValue (sc_arg, TObject ("DebuggerTests.SimpleClass"), "sc_arg#2");

						var sc_arg_props = await GetProperties (sc_arg ["objectId"]?.Value<string> ());
						await CheckProps (sc_arg_props, new {
							X                     = TNumber (10),
							Y                     = TNumber (45),
							Id                    = TString ("sc_arg#Id"), // <------- This changed
							Color                 = TEnum   ("DebuggerTests.RGB", "Blue"),
							PointWithCustomGetter = TGetter ("PointWithCustomGetter")
						}, "sc_arg_props#2");
					}
				});
		}

		[Fact]
		public async Task EvaluateExpressions ()
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", 20, 16,
				"run",
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "d + e");
					CheckContentValue (evaluate, "203");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "e + 10");
					CheckContentValue (evaluate, "112");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "a + a");
					CheckContentValue (evaluate, "2");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "this.a + this.b");
					CheckContentValue (evaluate, "3");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "\"test\" + \"test\"");
					CheckContentValue (evaluate, "testtest");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "5 + 5");
					CheckContentValue (evaluate, "10");
				});

		[Fact]
		public async Task EvaluateThisExpressions ()
			=> await CheckInspectLocalsAtBreakpointSite (
				"dotnet://debugger-test.dll/debugger-evaluate-test.cs", 20, 16,
				"run",
				"window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })",
				wait_for_event_fn: async (pause_location) => {
					var locals = await GetProperties (pause_location ["callFrames"][0] ["callFrameId"].Value<string> ());
					var evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "this.a");
					CheckContentValue (evaluate, "1");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "this.b");
					CheckContentValue (evaluate, "2");
					evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "this.c");
					CheckContentValue (evaluate, "3");

					// FIXME: not supported yet
					// evaluate = await EvaluateOnCallFrame (pause_location ["callFrames"][0] ["callFrameId"].Value<string> (), "this.dt");
					// await CheckDateTimeValue (evaluate, new DateTime (2000, 5, 4, 3, 2, 1));
				});
	}

}