patch 8.2.0233: crash when using garbagecollect() in between rand()

Problem:    Crash when using garbagecollect() in between rand().
Solution:   Redesign the rand() and srand() implementation. (Yasuhiro
            Matsumoto, closes #5587, closes #5588)
diff --git a/src/testdir/test_random.vim b/src/testdir/test_random.vim
index 747e438..bdb7e1d 100644
--- a/src/testdir/test_random.vim
+++ b/src/testdir/test_random.vim
@@ -11,7 +11,7 @@
 
   call test_settime(12341234)
   let s = srand()
-  if filereadable('/dev/urandom')
+  if !has('win32') && filereadable('/dev/urandom')
     " using /dev/urandom
     call assert_notequal(s, srand())
   else
@@ -21,9 +21,10 @@
     call assert_notequal(s, srand())
   endif
 
-  call srand()
-  let v = rand()
-  call assert_notequal(v, rand())
+  call test_srand_seed(123456789)
+  call assert_equal(4284103975, rand())
+  call assert_equal(1001954530, rand())
+  call test_srand_seed()
 
   if has('float')
     call assert_fails('echo srand(1.2)', 'E805:')
@@ -38,3 +39,9 @@
 
   call test_settime(0)
 endfunc
+
+func Test_issue_5587()
+  call rand()
+  call garbagecollect()
+  call rand()
+endfunc