3 <<__EntryPoint
>> function main() {
4 require(__DIR__
. '/common.inc');
6 $path = __FILE__
. ".test";
10 "breakpoints" => varray
[
11 darray
["line" => 20, "calibratedLine" => 20, "condition" => ""],
12 darray
["line" => 21, "calibratedLine" => 21, "condition" => ""],
13 darray
["line" => 23, "calibratedLine" => 24, "condition" => ""],
14 darray
["line" => 28, "calibratedLine" => 28, "condition" => ""],
18 $testProcess = vsDebugLaunch(__FILE__
. ".test", true, $breakpoints);
20 // Skip breakpoint resolution messages.
21 skipMessages(count($breakpoints[0]{'breakpoints'}));
23 // Verify we hit breakpoint 1.
24 verifyBpHit($breakpoints[0]{'path'}, $breakpoints[0]{'breakpoints'}[0]);
26 // Check thread stacks.
27 $seq = sendVsCommand(darray
[
28 "command" => "stackTrace",
30 "arguments" => darray
[
34 $msg = json_decode(getNextVsDebugMessage(), true);
35 checkObjEqualRecursively($msg, darray
[
37 "command" => "stackTrace",
38 "request_seq" => $seq,
42 "stackFrames" => varray
[
44 "source" => darray
["path" => $path, "name" => str_replace(".test", "", basename($path))],
50 "source" => darray
["path" => $path, "name" => str_replace(".test", "", basename($path))],
60 $seq = sendVsCommand(darray
[
61 "command" => "threads",
62 "type" => "request"]);
63 $msg = json_decode(getNextVsDebugMessage(), true);
64 checkObjEqualRecursively($msg, darray
[
66 "command" => "threads",
67 "request_seq" => $seq,
70 "threads" => varray
[darray
["name" => "Request 1", "id" => 1]]
76 $seq = sendVsCommand(darray
[
77 "command" => "scopes",
79 "arguments" => darray
["frameId" => 1]]);
80 $msg = json_decode(getNextVsDebugMessage(), true);
81 checkObjEqualRecursively($msg, darray
[
83 "command" => "scopes",
84 "request_seq" => $seq,
89 "namedVariables" => 1,
93 "namedVariables" => 7,
94 "name" => "Superglobals",
97 "namedVariables" => 2,
98 "name" => "Constants",
103 // Get locals, only $a should be visible right here.
104 $seq = sendVsCommand(darray
[
105 "command" => "variables",
107 "arguments" => darray
["variablesReference" => 3]]);
108 $msg = json_decode(getNextVsDebugMessage(), true);
109 checkObjEqualRecursively($msg, darray
[
110 "type" => "response",
111 "command" => "variables",
112 "request_seq" => $seq,
115 "variables" => varray
[
124 if (count($msg{"body"}{"variables"}) != 1) {
125 throw new UnexpectedValueException("Unexpected variable count");
130 // Verify we hit breakpoint 2.
131 verifyBpHit($breakpoints[0]{'path'}, $breakpoints[0]{'breakpoints'}[1]);
134 // Verify we hit breakpoint 3.
135 verifyBpHit($breakpoints[0]{'path'}, $breakpoints[0]{'breakpoints'}[2]);
138 // Verify we hit breakpoint 4.
139 verifyBpHit($breakpoints[0]{'path'}, $breakpoints[0]{'breakpoints'}[3]);
141 $seq = sendVsCommand(darray
[
142 "command" => "stackTrace",
144 "arguments" => darray
[
147 $msg = json_decode(getNextVsDebugMessage(), true);
149 $seq = sendVsCommand(darray
[
150 "command" => "scopes",
152 "arguments" => darray
["frameId" => 8]]);
153 $msg = json_decode(getNextVsDebugMessage(), true);
155 $seq = sendVsCommand(darray
[
156 "command" => "variables",
158 "arguments" => darray
["variablesReference" => 3]]);
159 $msg = json_decode(getNextVsDebugMessage(), true);
160 checkObjEqualRecursively($msg, darray
[
161 "type" => "response",
162 "command" => "variables",
163 "request_seq" => $seq,
166 "variables" => varray
[
175 "value" => "Hello world",
186 "indexedVariables" => 3,
192 "indexedVariables" => 2,
198 "indexedVariables" => 2,
203 if (count($msg{"body"}{"variables"}) != 6) {
204 throw new UnexpectedValueException("Unexpected variable count");
207 $seq = sendVsCommand(darray
[
208 "command" => "variables",
210 "arguments" => darray
["variablesReference" => 14]]);
212 $msg = json_decode(getNextVsDebugMessage(), true);
213 checkObjEqualRecursively($msg, darray
[
214 "type" => "response",
215 "command" => "variables",
216 "request_seq" => $seq,
219 "variables" => varray
[
224 "namedVariables" => 2,
225 "variablesReference" => 16,
226 "presentationHint" => darray
[
227 "visibility" => "public"
234 "presentationHint" => darray
[
235 "visibility" => "protected"
242 "presentationHint" => darray
[
243 "visibility" => "public"
247 // The private props should contain the base class's copy of $a, only.
249 "variablesReference" => 17,
250 "name" => "Private props",
251 "value" => "class A",
252 "namedVariables" => 1,
253 "presentationHint" => darray
[
254 "attributes" => varray
["constant", "readOnly"]
258 // Two constants should be visible on A, HELLOA and HELLOB, and one
261 "variablesReference" => 18,
262 "name" => "Class Constants",
263 "value" => "class B",
264 "namedVariables" => 3,
265 "presentationHint" => darray
[
266 "attributes" => varray
["constant", "readOnly"]
271 "variablesReference" => 19,
272 "name" => "Static Props",
273 "value" => "class B",
274 "namedVariables" => 1,
275 "presentationHint" => darray
[
276 "attributes" => varray
["constant", "readOnly"]
282 // Check that we can see the correct properties of $aObj
283 $seq = sendVsCommand(darray
[
284 "command" => "variables",
286 "arguments" => darray
["variablesReference" => 16]]);
288 $msg = json_decode(getNextVsDebugMessage(), true);
289 checkObjEqualRecursively($msg, darray
[
290 "type" => "response",
291 "command" => "variables",
292 "request_seq" => $seq,
295 "variables" => varray
[
300 "presentationHint" => darray
[
301 "visibility" => "private"
308 "presentationHint" => darray
[
309 "visibility" => "protected"
313 "name" => "Class Constants",
314 "value" => "class A",
315 "namedVariables" => 2,
316 "presentationHint" => darray
[
317 "attributes" => varray
["constant", "readOnly"]
322 "name" => "Static Props",
323 "value" => "class A",
324 "namedVariables" => 1,
325 "presentationHint" => darray
[
326 "attributes" => varray
["constant", "readOnly"]
332 if (count($msg{"body"}{"variables"}) != 4) {
333 throw new UnexpectedValueException("Unexpected variable count");
336 // Correct private props of $bObj from base class A
337 $seq = sendVsCommand(darray
[
338 "command" => "variables",
340 "arguments" => darray
["variablesReference" => 17]]);
341 $msg = json_decode(getNextVsDebugMessage(), true);
342 checkObjEqualRecursively($msg, darray
[
343 "type" => "response",
344 "command" => "variables",
345 "request_seq" => $seq,
348 "variables" => varray
[
353 "presentationHint" => darray
[
354 "visibility" => "private"
360 if (count($msg{"body"}{"variables"}) != 1) {
361 throw new UnexpectedValueException("Unexpected variable count");
364 // Correct statics, $bObj should see statics inherited from class A
365 $seq = sendVsCommand(darray
[
366 "command" => "variables",
368 "arguments" => darray
["variablesReference" => 19]]);
369 $msg = json_decode(getNextVsDebugMessage(), true);
370 checkObjEqualRecursively($msg, darray
[
371 "type" => "response",
372 "command" => "variables",
373 "request_seq" => $seq,
376 "variables" => varray
[
381 "presentationHint" => darray
[
382 "visibility" => "public"
388 if (count($msg{"body"}{"variables"}) != 1) {
389 throw new UnexpectedValueException("Unexpected variable count");
392 // Correct class constants. Should inclide consts from A and B, sorted by name.
393 $seq = sendVsCommand(darray
[
394 "command" => "variables",
396 "arguments" => darray
["variablesReference" => 18]]);
397 $msg = json_decode(getNextVsDebugMessage(), true);
398 checkObjEqualRecursively($msg, darray
[
399 "type" => "response",
400 "command" => "variables",
401 "request_seq" => $seq,
404 "variables" => varray
[
407 "name" => "A::HELLOA",
409 "presentationHint" => darray
[
410 "attributes" => varray
["constant", "readOnly"]
415 "name" => "A::HELLOB",
417 "presentationHint" => darray
[
418 "attributes" => varray
["constant", "readOnly"]
423 "name" => "B::HELLOB",
425 "presentationHint" => darray
[
426 "attributes" => varray
["constant", "readOnly"]
432 if (count($msg{"body"}{"variables"}) != 3) {
433 throw new UnexpectedValueException("Unexpected variable count");
436 // Check $c, a regular array of ints.
437 $seq = sendVsCommand(darray
[
438 "command" => "variables",
440 "arguments" => darray
["variablesReference" => 12]]);
441 $msg = json_decode(getNextVsDebugMessage(), true);
442 checkObjEqualRecursively($msg, darray
[
443 "type" => "response",
444 "command" => "variables",
445 "request_seq" => $seq,
448 "variables" => varray
[
467 if (count($msg{"body"}{"variables"}) != 3) {
468 throw new UnexpectedValueException("Unexpected variable count");
471 // Ask for a subset of the array.
472 $seq = sendVsCommand(darray
[
473 "command" => "variables",
475 "arguments" =>darray
["variablesReference" => 12, "count" => 2]]);
476 $msg = json_decode(getNextVsDebugMessage(), true);
477 checkObjEqualRecursively($msg, darray
[
478 "type" => "response",
479 "command" => "variables",
480 "request_seq" => $seq,
483 "variables" => varray
[
497 if (count($msg{"body"}{"variables"}) != 2) {
498 throw new UnexpectedValueException("Unexpected variable count");
501 // Check $d, a array of arrays.
502 $seq = sendVsCommand(darray
[
503 "command" => "variables",
505 "arguments" => darray
["variablesReference" => 13]]);
506 $msg = json_decode(getNextVsDebugMessage(), true);
507 checkObjEqualRecursively($msg, darray
[
508 "type" => "response",
509 "command" => "variables",
510 "request_seq" => $seq,
513 "variables" => varray
[
523 "variablesReference" => 22
528 if (count($msg{"body"}{"variables"}) != 2) {
529 throw new UnexpectedValueException("Unexpected variable count");
532 // check $d[1], sub array of ints.
533 $seq = sendVsCommand(darray
[
534 "command" => "variables",
536 "arguments" => darray
["variablesReference" => 22]]);
537 $msg = json_decode(getNextVsDebugMessage(), true);
538 checkObjEqualRecursively($msg, darray
[
539 "type" => "response",
540 "command" => "variables",
541 "request_seq" => $seq,
544 "variables" => varray
[
558 if (count($msg{"body"}{"variables"}) != 2) {
559 throw new UnexpectedValueException("Unexpected variable count");
562 // Check $e, array of objects
563 $seq = sendVsCommand(darray
[
564 "command" => "variables",
566 "arguments" => darray
["variablesReference" => 15]]);
567 $msg = json_decode(getNextVsDebugMessage(), true);
568 checkObjEqualRecursively($msg, darray
[
569 "type" => "response",
570 "command" => "variables",
571 "request_seq" => $seq,
574 "variables" => varray
[
579 "variablesReference" => 14
585 "variablesReference" => 14
590 if (count($msg{"body"}{"variables"}) != 2) {
591 throw new UnexpectedValueException("Unexpected variable count");
594 $seq = sendVsCommand(darray
[
595 "command" => "variables",
597 "arguments" => darray
["variablesReference" => 14]]);
599 $msg = json_decode(getNextVsDebugMessage(), true);
600 checkObjEqualRecursively($msg, darray
[
601 "type" => "response",
602 "command" => "variables",
603 "request_seq" => $seq,
606 "variables" => varray
[
611 "namedVariables" => 2,
612 "variablesReference" => 16,
613 "presentationHint" => darray
[
614 "visibility" => "public"
621 "presentationHint" => darray
[
622 "visibility" => "protected"
629 "presentationHint" => darray
[
630 "visibility" => "public"
634 // The private props should contain the base class's copy of $a, only.
636 "variablesReference" => 23,
637 "name" => "Private props",
638 "value" => "class A",
639 "namedVariables" => 1,
640 "presentationHint" => darray
[
641 "attributes" => varray
["constant", "readOnly"]
645 // Two constants should be visible on A, HELLOA and HELLOB, and one
648 "variablesReference" => 24,
649 "name" => "Class Constants",
650 "value" => "class B",
651 "namedVariables" => 3,
652 "presentationHint" => darray
[
653 "attributes" => varray
["constant", "readOnly"]
658 "variablesReference" => 25,
659 "name" => "Static Props",
660 "value" => "class B",
661 "namedVariables" => 1,
662 "presentationHint" => darray
[
663 "attributes" => varray
["constant", "readOnly"]
669 // Ask for a subset of the array. Give me index 1 only.
670 $seq = sendVsCommand(darray
[
671 "command" => "variables",
674 "arguments" => darray
[
675 "variablesReference" => 12,
679 $msg = json_decode(getNextVsDebugMessage(), true);
680 checkObjEqualRecursively($msg, darray
[
681 "type" => "response",
682 "command" => "variables",
683 "request_seq" => $seq,
686 "variables" => varray
[
695 if (count($msg{"body"}{"variables"}) != 1) {
696 throw new UnexpectedValueException("Unexpected variable count");
699 // Subset of class constants.
700 $seq = sendVsCommand(darray
[
701 "command" => "variables",
705 "variablesReference" => 24,
709 $msg = json_decode(getNextVsDebugMessage(), true);
710 checkObjEqualRecursively($msg, darray
[
711 "type" => "response",
712 "command" => "variables",
713 "request_seq" => $seq,
716 "variables" => varray
[
719 "name" => "A::HELLOB",
721 "presentationHint" => darray
[
722 "attributes" => varray
["constant", "readOnly"]
727 "name" => "B::HELLOB",
729 "presentationHint" => darray
[
730 "attributes" => varray
["constant", "readOnly"]
736 if (count($msg{"body"}{"variables"}) != 2) {
737 throw new UnexpectedValueException("Unexpected variable count");
741 $seq = sendVsCommand(darray
[
742 "command" => "variables",
746 "variablesReference" => 24,
750 $msg = json_decode(getNextVsDebugMessage(), true);
751 checkObjEqualRecursively($msg, darray
[
752 "type" => "response",
753 "command" => "variables",
754 "request_seq" => $seq,
757 "variables" => varray
[
760 "name" => "A::HELLOA",
762 "presentationHint" => darray
[
763 "attributes" => varray
["constant", "readOnly"]
768 if (count($msg{"body"}{"variables"}) != 1) {
769 throw new UnexpectedValueException("Unexpected variable count");
772 $seq = sendVsCommand(darray
[
773 "command" => "variables",
777 "variablesReference" => 24,
781 $msg = json_decode(getNextVsDebugMessage(), true);
782 checkObjEqualRecursively($msg, darray
[
783 "type" => "response",
784 "command" => "variables",
785 "request_seq" => $seq,
788 "variables" => varray
[
791 "name" => "A::HELLOB",
793 "presentationHint" => darray
[
794 "attributes" => varray
["constant", "readOnly"]
799 "name" => "B::HELLOB",
801 "presentationHint" => darray
[
802 "attributes" => varray
["constant", "readOnly"]
807 if (count($msg{"body"}{"variables"}) != 2) {
808 throw new UnexpectedValueException("Unexpected variable count");
813 checkForOutput($testProcess, "hello world 1\n", "stdout");
814 checkForOutput($testProcess, "hello world 2\n", "stdout");
815 vsDebugCleanup($testProcess);