@@ -33,7 +33,7 @@ const integration: Suite = framework.suite('Integration tests: Debugger'); // mu
3333
3434integration . testee ( 'emulator [:8500]' , new EmulatorSpecification ( 8500 ) ) ;
3535
36- const expectDUMP : Expectation [ ] = [
36+ const expectSnapshot : Expectation [ ] = [
3737 { 'programCounter' : { kind : 'description' , value : Description . defined } as Expected < number > } ,
3838 {
3939 'breakpoints' : {
@@ -44,130 +44,65 @@ const expectDUMP: Expectation[] = [
4444 } ,
4545 ] ;
4646
47- const expectDUMPLocals : Expectation [ ] = [
48- { 'values' : { kind : 'description' , value : Description . defined } as Expected < Array < unknown > > } ] ;
49-
50- const DUMP : Step = {
51- title : 'Send DUMP command' ,
47+ const SNAPSHOT : Step = {
48+ title : 'Send SNAPSHOT command' ,
5249 instruction : { kind : Kind . Request , value : Message . snapshot } ,
53- expected : expectDUMP
50+ expected : expectSnapshot
5451} ;
5552
56- // Test *dump* command
57-
58- integration . test ( {
59- title : 'Test DUMP blink' ,
60- program : `${ EXAMPLES } blink.wast` ,
61- steps : [ DUMP ]
62- } ) ;
53+ // Test full snapshot command
6354
64- integration . test ( {
65- title : 'Test DUMP button' ,
66- program : `${ EXAMPLES } button.wast` ,
67- steps : [ DUMP ]
68- } ) ;
69-
70- integration . test ( {
71- title : 'Test DUMP call' ,
72- program : `${ EXAMPLES } call.wast` ,
73- steps : [ DUMP ]
74- } ) ;
75-
76- integration . test ( {
77- title : 'Test DUMP factorial' ,
78- program : `${ EXAMPLES } factorial.wast` ,
79- steps : [ DUMP ]
80- } ) ;
81-
82- // Test *dump local* command
83-
84- integration . test ( {
85- title : 'Test DUMPLocals blink' ,
55+ const snapshotTest : TestScenario = {
56+ title : 'Test snapshot' ,
8657 program : `${ EXAMPLES } blink.wast` ,
8758 steps : [ {
88- title : 'Send DUMPLocals command' ,
89- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
90- expected : expectDUMPLocals
91- } ]
92- } ) ;
93-
94- integration . test ( {
95- title : 'Test DUMPLocals button' ,
96- program : `${ EXAMPLES } button.wast` ,
97- steps : [ {
98- title : 'Send DUMPLocals command' ,
99- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
100- expected : expectDUMPLocals
59+ title : 'Send snapshot command' ,
60+ instruction : { kind : Kind . Request , value : Message . snapshot } ,
61+ expected : expectSnapshot
10162 } ]
102- } ) ;
63+ } ;
10364
104- integration . test ( {
105- title : 'Test DUMPLocals call' ,
106- program : `${ EXAMPLES } call.wast` ,
107- steps : [ {
108- title : 'Send DUMPLocals command' ,
109- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
110- expected : expectDUMPLocals
111- } ]
112- } ) ;
65+ integration . test ( snapshotTest ) ;
11366
114- integration . test ( {
115- title : 'Test DUMPLocals factorial' ,
116- program : `${ EXAMPLES } factorial.wast` ,
117- steps : [ {
118- title : 'Send DUMPLocals command' ,
119- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
120- expected : expectDUMPLocals
121- } ]
122- } ) ;
67+ const expectSnapshotLocals : Expectation [ ] = [
68+ ...expectSnapshot ,
69+ { 'locals' : { kind : 'description' , value : Description . defined } as Expected < Object > } ,
70+ { 'locals.values' : { kind : 'description' , value : Description . defined } as Expected < Array < unknown > > }
71+ ] ;
12372
12473integration . test ( {
125- title : 'Test DUMPLocals button' ,
126- program : `${ EXAMPLES } button.wast` ,
127- steps : [ {
128- title : 'Send DUMPLocals command' ,
129- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
130- expected : expectDUMPLocals
131- } ]
74+ title : 'Test SNAPSHOT button' ,
75+ program : EXAMPLES + 'button.wast' ,
76+ steps : [ SNAPSHOT ]
13277} ) ;
13378
13479integration . test ( {
135- title : 'Test DUMPLocals call' ,
136- program : `${ EXAMPLES } call.wast` ,
137- steps : [ {
138- title : 'Send DUMPLocals command' ,
139- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
140- expected : expectDUMPLocals
141- } ]
80+ title : 'Test SNAPSHOT call' ,
81+ program : EXAMPLES + 'call.wast' ,
82+ steps : [ SNAPSHOT ]
14283} ) ;
14384
14485integration . test ( {
145- title : 'Test DUMPLocals factorial' ,
146- program : `${ EXAMPLES } factorial.wast` ,
147- steps : [ {
148- title : 'Send DUMPLocals command' ,
149- instruction : { kind : Kind . Request , value : Message . dumpLocals } ,
150- expected : expectDUMPLocals
151- } ]
86+ title : 'Test SNAPSHOT factorial' ,
87+ program : EXAMPLES + 'factorial.wast' ,
88+ steps : [ SNAPSHOT ]
15289} ) ;
15390
154- // Test *dump full* command
155-
156- const snapshotTest : TestScenario = {
157- title : 'Test snapshot' ,
158- program : `${ EXAMPLES } blink.wast` ,
159- steps : [ {
160- title : 'Send snapshot command' ,
161- instruction : { kind : Kind . Request , value : Message . snapshot } ,
162- expected : expectDUMP
163- } ]
164- } ;
165-
166- integration . test ( snapshotTest ) ;
91+ for ( const [ name , program ] of [ [ 'blink' , 'blink.wast' ] , [ 'button' , 'button.wast' ] , [ 'call' , 'call.wast' ] , [ 'factorial' , 'factorial.wast' ] ] as const ) {
92+ integration . test ( {
93+ title : 'Test SNAPSHOT locals ' + name ,
94+ program : EXAMPLES + program ,
95+ steps : [ {
96+ title : 'Send SNAPSHOT command' ,
97+ instruction : { kind : Kind . Request , value : Message . snapshot } ,
98+ expected : expectSnapshotLocals
99+ } ]
100+ } ) ;
101+ }
167102
168103// Test *run* command
169104
170- const running : Step [ ] = [ DUMP , {
105+ const running : Step [ ] = [ SNAPSHOT , {
171106 title : 'Send RUN command' ,
172107 instruction : { kind : Kind . Request , value : Message . run } ,
173108} , {
@@ -204,7 +139,7 @@ const pauseTest: TestScenario = {
204139 title : 'Send PAUSE command' ,
205140 instruction : { kind : Kind . Request , value : Message . pause } ,
206141 } , {
207- title : 'Send DUMP command' ,
142+ title : 'Send SNAPSHOT command' ,
208143 instruction : { kind : Kind . Request , value : Message . snapshot } ,
209144 expected : [ {
210145 'programCounter' : { kind : 'description' , value : Description . defined } as Expected < number >
@@ -226,7 +161,7 @@ integration.test(pauseTest);
226161
227162function stepping ( start : number , end : number ) : Step [ ] {
228163 return [ {
229- title : 'Send DUMP command' ,
164+ title : 'Send SNAPSHOT command' ,
230165 instruction : { kind : Kind . Request , value : Message . snapshot } ,
231166 expected : [ { 'programCounter' : { kind : 'primitive' , value : start } as Expected < number > } ]
232167 } , {
@@ -275,7 +210,7 @@ const stepOverTest: TestScenario = {
275210 title : 'Test STEP OVER' ,
276211 program : `${ EXAMPLES } call.wast` ,
277212 steps : [ {
278- title : 'Send DUMP command' ,
213+ title : 'Send SNAPSHOT command' ,
279214 instruction : { kind : Kind . Request , value : Message . snapshot } ,
280215 expected : [ { 'programCounter' : { kind : 'primitive' , value : 167 } as Expected < number > } ]
281216 } , {
@@ -306,41 +241,13 @@ integration.test(stepOverTest);
306241
307242// EDWARD tests with mock proxy
308243
309- const dumpEventsTest : TestScenario = {
310- title : 'Test DUMPEvents' ,
311- program : `${ EXAMPLES } button.wast` ,
312- steps : [ {
313- title : 'CHECK: event queue' ,
314- instruction : { kind : Kind . Request , value : Message . dumpAllEvents } ,
315- expected : [ {
316- 'events' : {
317- kind : 'comparison' ,
318- value : ( _ : string , value : Array < any > ) => value . length === 0 ,
319- message : 'events queue is should be empty'
320- } as Expected < Array < any > >
321- } ]
322- } ]
323- } ;
324-
325- integration . test ( dumpEventsTest ) ;
326-
327244integration . test ( {
328245 title : 'Test INSPECT' ,
329246 program : `${ EXAMPLES } blink.wast` ,
330247 steps : [ {
331248 title : 'Inspect complete state' ,
332249 instruction : { kind : Kind . Request , value : Message . inspect ( [ ] ) } ,
333- expected : expectDUMP
334- } ]
335- } ) ;
336-
337- integration . test ( {
338- title : 'Test DUMPEvents range' ,
339- program : `${ EXAMPLES } button.wast` ,
340- steps : [ {
341- title : 'Dump event range' ,
342- instruction : { kind : Kind . Request , value : Message . dumpEvents ( { start : 0 , end : 0 } ) } ,
343- expected : [ { totalCount : { kind : 'primitive' , value : 0 } as Expected < number > } ]
250+ expected : expectSnapshot
344251 } ]
345252} ) ;
346253
@@ -389,7 +296,7 @@ integration.test({
389296 program : `${ EXAMPLES } blink.wast` ,
390297 steps : [
391298 { title : 'Reset runtime' , instruction : { kind : Kind . Request , value : Message . reset } } ,
392- { title : 'Check reset state' , instruction : { kind : Kind . Request , value : Message . snapshot } , expected : expectDUMP }
299+ { title : 'Check reset state' , instruction : { kind : Kind . Request , value : Message . snapshot } , expected : expectSnapshot }
393300 ]
394301} ) ;
395302
@@ -407,12 +314,6 @@ const operationSucceeded: Expectation[] = [
407314 { success : { kind : "primitive" , value : true } as Expected < boolean > }
408315] ;
409316
410- const dumpCommand : Request < DebugProtocol . Snapshot > = {
411- ...Message . dump ,
412- notification : DebugProtocol . NotificationType . NOTIFICATION_SNAPSHOT ,
413- parser : DebugProtocol . Snapshot . decode
414- } ;
415-
416317const proxyCallWithoutProxy : Request < DebugProtocol . OperationResult > = {
417318 ...Message . proxyCall ( { functionIndex : 3 , arguments : [ ] } ) ,
418319 notification : DebugProtocol . NotificationType . NOTIFICATION_OPERATION_RESULT ,
@@ -438,15 +339,12 @@ integration.test({
438339 title : "Test remaining debugger requests" ,
439340 program : `${ EXAMPLES } blink.wast` ,
440341 steps : [
441- { title : "Dump function metadata" , instruction : { kind : Kind . Request , value : dumpCommand } , expected : [ { programCounter : { kind : "description" , value : Description . defined } as Expected < number > } ] } ,
442- { title : "Dump callback mapping" , instruction : { kind : Kind . Request , value : Message . dumpCallbackmapping } , expected : [ { entries : { kind : "description" , value : Description . defined } as Expected < Object > } ] } ,
443342 { title : "Update function body" , instruction : { kind : Kind . Request , value : Message . updateFunction ( { functionIndex : 3 , instructions : Buffer . from ( [ 0x0b ] ) } ) } , expected : operationSucceeded } ,
444343 { title : "Update local value" , instruction : { kind : Kind . Request , value : Message . updateLocal ( 0 , { i32Bits : 7 , index : 0 } ) } , expected : operationSucceeded } ,
445344 { title : "Update stack value" , instruction : { kind : Kind . Request , value : Message . updateStack ( 0 , { i32Bits : 8 , index : 0 } ) } , expected : operationSucceeded } ,
446345 { title : "Update global value" , instruction : { kind : Kind . Request , value : Message . updateGlobal ( 0 , { i32Bits : 9 , index : 0 } ) } , expected : operationSucceeded } ,
447346 { title : "Update callback mapping" , instruction : { kind : Kind . Request , value : Message . updateCallbacks ( { entries : [ ] } ) } , expected : operationSucceeded } ,
448347 { title : "Push an event" , instruction : { kind : Kind . Request , value : Message . pushEvent ( "test" , "payload" ) } } ,
449- { title : "Dump pushed event" , instruction : { kind : Kind . Request , value : Message . dumpEvents ( { start : 0 , end : 0 } ) } , expected : [ { totalCount : { kind : "primitive" , value : 1 } as Expected < number > } ] } ,
450348 { title : "Pop event" , instruction : { kind : Kind . Request , value : popEventWithoutCallback } , expected : [ { success : { kind : "primitive" , value : false } as Expected < boolean > } ] } ,
451349 { title : "Load snapshot state" , instruction : { kind : Kind . Request , value : Message . loadSnapshot ( { programCounter : 0 , state : DebugProtocol . State . STATE_WARDUINO_PAUSE , breakpoints : [ ] , functions : [ ] , callstack : [ ] , globals : [ ] , stack : [ ] , branchTable : [ ] , io : [ ] , overrides : [ ] , heapUsed : 0 } ) } , expected : operationSucceeded } ,
452350 { title : "Set snapshot policy" , instruction : { kind : Kind . Request , value : Message . setSnapshotPolicy ( { policy : DebugProtocol . SnapshotPolicy . SNAPSHOT_POLICY_NONE , interval : 1 , minimumReturnCount : 0 , selectedState : Buffer . alloc ( 0 ) } ) } , expected : operationSucceeded } ,
0 commit comments