@@ -465,6 +465,72 @@ describe('evaluate request global variables', function () {
465465 } ) ;
466466 } ) ;
467467 } ) ;
468+
469+ it ( 'should be able to set a simple global variable and have that change reflected in the debuggee' , async function ( ) {
470+ // Read global_int using watch
471+ const watchRes = await dc . evaluateRequest ( {
472+ context : 'watch' ,
473+ expression : 'global_int' ,
474+ frameId : scope . frame . id ,
475+ } ) ;
476+ expect ( watchRes . body . result ) . to . equal ( '42' ) ;
477+
478+ // Set global_int using setExpressionRequest
479+ const setRes = await dc . customRequest ( 'setExpression' , {
480+ expression : 'global_int' ,
481+ value : '100' ,
482+ frameId : scope . frame . id ,
483+ } ) ;
484+ expect ( setRes . body . value ) . to . equal ( '100' ) ;
485+
486+ // Read global_int again to check updated value is returned
487+ const watchResUpdated = await dc . evaluateRequest ( {
488+ context : 'watch' ,
489+ expression : 'global_int' ,
490+ frameId : scope . frame . id ,
491+ } ) ;
492+ expect ( watchResUpdated . body . result ) . to . equal ( '100' ) ;
493+ } ) ;
494+
495+ it ( 'should be able to set a complex global variable and have that change reflected in the debuggee' , async function ( ) {
496+ // Read global variable using watch
497+ const watchResParent = await dc . evaluateRequest ( {
498+ context : 'watch' ,
499+ expression : 's1' ,
500+ frameId : scope . frame . id ,
501+ } ) ;
502+ const watchResChild = await dc . evaluateRequest ( {
503+ context : 'watch' ,
504+ expression : 's1.m' ,
505+ frameId : scope . frame . id ,
506+ } ) ;
507+ expect ( watchResParent . body . result ) . to . endWith ( '{...}' ) ;
508+ expect ( watchResChild . body . result ) . to . equal ( '10' ) ;
509+
510+ // Set global variable using setExpressionRequest
511+ const setRes = await dc . customRequest ( 'setExpression' , {
512+ expression : 's1.m' ,
513+ value : '20' ,
514+ frameId : scope . frame . id ,
515+ } ) ;
516+ expect ( setRes . body . value ) . to . equal ( '20' ) ;
517+
518+ // Read global variable again to check updated value is returned
519+ const watchResChildUpdated = await dc . evaluateRequest ( {
520+ context : 'watch' ,
521+ expression : 's1.m' ,
522+ frameId : scope . frame . id ,
523+ } ) ;
524+ expect ( watchResChildUpdated . body . result ) . to . equal ( '20' ) ;
525+
526+ // Check updated value is reflected in the debuggee by evaluating an expression that uses the variable
527+ const evalRes = await dc . evaluateRequest ( {
528+ context : 'repl' ,
529+ expression : 's1.m + 5' ,
530+ frameId : scope . frame . id ,
531+ } ) ;
532+ expect ( evalRes . body . result ) . to . equal ( '25' ) ;
533+ } ) ;
468534} ) ;
469535
470536describe ( 'evaluate request - watch local variable across lexical scope transition' , function ( ) {
0 commit comments