@@ -135,7 +135,7 @@ describe("Debug Adapter Tests", function () {
135135 if ( e . body . exitCode == 0 )
136136 resolve ( e )
137137 else
138- reject ( new Error ( "Expecting ExitCode 1 " ) )
138+ reject ( new Error ( "Expecting ExitCode 0 " ) )
139139 } ) )
140140 ] ) ;
141141 } ) ;
@@ -746,5 +746,114 @@ describe("Debug Adapter Tests", function () {
746746
747747 } )
748748 } )
749+
750+ describe ( "Conditional breakpoints (issue #111)" , function ( ) {
751+ it ( "Conditional expression breakpoints" , async ( ) => {
752+ let config = mkConfig ( {
753+ projectRoot : "/data/T111" ,
754+ entryFile : "T111.hs" ,
755+ entryPoint : "main" ,
756+ entryArgs : [ ] ,
757+ extraGhcArgs : [ ]
758+ } )
759+
760+ const expected = { path : config . projectRoot + "/" + config . entryFile , line : 13 }
761+
762+ await Promise . all ( [
763+ dc . waitForEvent ( 'initialized' ) . then ( event => {
764+ return dc . setBreakpointsRequest ( {
765+ lines : [ 13 ] ,
766+ breakpoints : [ { line : 13 , condition : "im IM.! 0 == 2" } ] ,
767+ source : { path : config . entryFile }
768+ } ) ;
769+ } ) . then ( response => {
770+ return dc . configurationDoneRequest ( ) ;
771+ } ) ,
772+
773+ dc . launch ( config ) ,
774+
775+ dc . assertStoppedLocation ( 'breakpoint' , expected )
776+ ] ) ;
777+
778+ // Assert we only stopped when im IM.! 0 == 2 (and not earlier)
779+ const variables = await fetchLocalVars ( )
780+ const imVar = variables . get ( 'im' ) ;
781+
782+ assert . strictEqual ( imVar . value , 'Bin' ) ;
783+ const imChild = await expandVar ( imVar ) ;
784+ const _2Var = await imChild . get ( "_2" ) ;
785+ const _3Var = await imChild . get ( "_3" ) ;
786+ const _2Child = await expandVar ( _2Var )
787+ const _3Child = await expandVar ( _3Var )
788+ const _2_2Var = await _2Child . get ( "_2" )
789+ const _3_2Var = await _3Child . get ( "_2" )
790+ assert . strictEqual ( _2_2Var . value , '2' ) ;
791+ assert . strictEqual ( _3_2Var . value , '4' ) ;
792+
793+ // And doesn't stop again
794+ await dc . continueRequest ( ) ;
795+
796+ await dc . waitForEvent ( 'exited' ) . then ( e => new Promise ( ( resolve , reject ) => {
797+ if ( e . body . exitCode == 0 )
798+ resolve ( e )
799+ else
800+ reject ( new Error ( "Expecting ExitCode 0" ) )
801+ } ) )
802+ } )
803+
804+ it ( "Hit count breakpoints" , async ( ) => {
805+ let config = mkConfig ( {
806+ projectRoot : "/data/T111" ,
807+ entryFile : "T111.hs" ,
808+ entryPoint : "main" ,
809+ entryArgs : [ ] ,
810+ extraGhcArgs : [ ]
811+ } )
812+
813+ const expected = { path : config . projectRoot + "/" + config . entryFile , line : 13 }
814+ const ignoreCount = 2 // ignore 2 hits and stop at third
815+
816+ await Promise . all ( [
817+ dc . waitForEvent ( 'initialized' ) . then ( event => {
818+ return dc . setBreakpointsRequest ( {
819+ lines : [ 13 ] ,
820+ breakpoints : [ { line : 13 , hitCondition : `${ ignoreCount } ` } ] ,
821+ source : { path : config . entryFile }
822+ } ) ;
823+ } ) . then ( response => {
824+ return dc . configurationDoneRequest ( ) ;
825+ } ) ,
826+
827+ dc . launch ( config ) ,
828+
829+ dc . assertStoppedLocation ( 'breakpoint' , expected )
830+ ] ) ;
831+
832+ // Assert we only stopped at the 3rd hit
833+ const variables = await fetchLocalVars ( )
834+ const imVar = variables . get ( 'im' ) ;
835+
836+ assert . strictEqual ( imVar . value , 'Bin' ) ;
837+ const imChild = await expandVar ( imVar ) ;
838+ const _2Var = await imChild . get ( "_2" ) ;
839+ const _3Var = await imChild . get ( "_3" ) ;
840+ const _2Child = await expandVar ( _2Var )
841+ const _3Child = await expandVar ( _3Var )
842+ const _2_2Var = await _2Child . get ( "_2" )
843+ const _3_2Var = await _3Child . get ( "_2" )
844+ assert . strictEqual ( _2_2Var . value , '2' ) ;
845+ assert . strictEqual ( _3_2Var . value , '4' ) ;
846+
847+ // And doesn't stop again
848+ await dc . continueRequest ( ) ;
849+
850+ await dc . waitForEvent ( 'exited' ) . then ( e => new Promise ( ( resolve , reject ) => {
851+ if ( e . body . exitCode == 0 )
852+ resolve ( e )
853+ else
854+ reject ( new Error ( "Expecting ExitCode 0" ) )
855+ } ) )
856+ } )
857+ } )
749858} )
750859
0 commit comments