@@ -7,6 +7,7 @@ t.beforeEach(() => {
77
88t . test ( "randm.shuffle randomly re-orders an array of numbers" , function ( t ) {
99 const orig = [ 1 , 2 , 3 , 4 ] ;
10+ randm . next . int . between . returns ( 2 , 1 , 0 ) ; // force a random order
1011 const shuffled = randm . shuffle ( orig ) ;
1112 console . log ( "randm.shuffle([1, 2, 3, 4])" , shuffled ) ;
1213 t . notSame ( orig , shuffled ) ;
@@ -15,6 +16,7 @@ t.test("randm.shuffle randomly re-orders an array of numbers", function (t) {
1516
1617t . test ( "randm.shuffle randomly re-orders an array of strings" , function ( t ) {
1718 const orig = [ "a" , "b" , "c" , "d" ] ;
19+ randm . next . int . between . returns ( 2 , 1 , 0 ) ; // force a random order
1820 const shuffled = randm . shuffle ( orig ) ;
1921 console . log ( 'randm.shuffle(["a", "b", "c", "d"])' , shuffled ) ;
2022 t . notSame ( orig , shuffled ) ;
@@ -26,10 +28,12 @@ t.test("randm.shuffle randomly re-orders an array of objects", function (t) {
2628 { a : 1 , b : "so" } ,
2729 { a : 2 , b : "huh" } ,
2830 { a : 3 , b : "wo" } ,
31+ { a : 4 , b : "ge" } ,
2932 ] ;
33+ randm . next . int . between . returns ( 2 , 1 , 0 ) ; // force a random order
3034 const shuffled = randm . shuffle ( orig ) ;
3135 console . log (
32- 'randm.shuffle([{ a: 1, b: "so" }, { a: 2, b: "huh" }, { a: 3, b: "wo" }])' ,
36+ 'randm.shuffle([{ a: 1, b: "so" }, { a: 2, b: "huh" }, { a: 3, b: "wo" }, { a: 4, b: "ge" } ])' ,
3337 shuffled
3438 ) ;
3539 t . notSame ( orig , shuffled ) ;
@@ -38,6 +42,7 @@ t.test("randm.shuffle randomly re-orders an array of objects", function (t) {
3842
3943t . test ( "randm.shuffle randomly re-orders a string" , function ( t ) {
4044 const orig = "Hello" ;
45+ randm . next . int . between . returns ( 2 , 1 , 0 ) ; // force a random order
4146 const shuffled = randm . shuffle ( orig ) ;
4247 console . log ( "randm.shuffle('Hello')" , shuffled ) ;
4348 t . notSame ( orig , shuffled ) ;
@@ -58,6 +63,7 @@ t.test(
5863
5964t . test ( "randm.shuffle does not mutate the passed array" , function ( t ) {
6065 const orig = [ 1 , 2 , 3 , 4 ] ;
66+ randm . next . int . between . returns ( 2 , 1 , 0 ) ; // force a random order
6167 const shuffled = randm . shuffle ( orig ) ;
6268 t . notSame ( orig , shuffled ) ;
6369 t . same ( orig , [ 1 , 2 , 3 , 4 ] ) ;
0 commit comments