@@ -9,12 +9,11 @@ describe("semaphore", () => {
99 let executionLog ;
1010 const n = 3 ;
1111 const m = 2 ;
12- const result = "finished" ;
1312 const runner = async ( index ) => {
1413 executionLog . push ( format ( "started %d" , index ) ) ;
1514 await sleep ( 10 ) ;
1615 executionLog . push ( format ( "finished %d" , index ) ) ;
17- return result ;
16+ return format ( " result %d" , index ) ;
1817 } ;
1918
2019 beforeEach ( ( ) => {
@@ -27,15 +26,15 @@ describe("semaphore", () => {
2726 const resultsSecondary = await Promise . all ( Array . from ( { length : m } , ( _ , i ) => runner ( n + i + 1 ) ) ) ;
2827 expect ( resultsPrimary ) . toMatchInlineSnapshot ( `
2928 [
30- "finished ",
31- "finished ",
32- "finished ",
29+ "result 1 ",
30+ "result 2 ",
31+ "result 3 ",
3332 ]
3433 ` ) ;
3534 expect ( resultsSecondary ) . toMatchInlineSnapshot ( `
3635 [
37- "finished ",
38- "finished ",
36+ "result 4 ",
37+ "result 5 ",
3938 ]
4039 ` ) ;
4140 expect ( executionLog ) . toMatchInlineSnapshot ( `
@@ -61,15 +60,15 @@ describe("semaphore", () => {
6160 const resultsSecondary = await Promise . all ( Array . from ( { length : m } , ( _ , i ) => exclusiveRunner ( n + i + 1 ) ) ) ;
6261 expect ( resultsPrimary ) . toMatchInlineSnapshot ( `
6362 [
64- "finished ",
65- "finished ",
66- "finished ",
63+ "result 1 ",
64+ "result 2 ",
65+ "result 3 ",
6766 ]
6867 ` ) ;
6968 expect ( resultsSecondary ) . toMatchInlineSnapshot ( `
7069 [
71- "finished ",
72- "finished ",
70+ "result 4 ",
71+ "result 5 ",
7372 ]
7473 ` ) ;
7574 expect ( executionLog ) . toMatchInlineSnapshot ( `
@@ -95,15 +94,15 @@ describe("semaphore", () => {
9594 const resultsSecondary = await Promise . all ( Array . from ( { length : m } , ( _ , i ) => exclusiveRunner ( n + i + 1 ) ) ) ;
9695 expect ( resultsPrimary ) . toMatchInlineSnapshot ( `
9796 [
98- "finished ",
99- undefined ,
100- undefined ,
97+ "result 1 ",
98+ "result 1" ,
99+ "result 1" ,
101100 ]
102101 ` ) ;
103102 expect ( resultsSecondary ) . toMatchInlineSnapshot ( `
104103 [
105- "finished ",
106- undefined ,
104+ "result 4 ",
105+ "result 4" ,
107106 ]
108107 ` ) ;
109108 expect ( executionLog ) . toMatchInlineSnapshot ( `
0 commit comments