diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-08 16:40:39 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-08 16:40:39 +0100 |
commit | 4f645c54efe33d7a11e314676e503118761f08a7 (patch) | |
tree | 8d98ceaaf843e7087adf4103e34e3ee29b21acde /src/testdir/test_random.vim | |
parent | 165315584d6587e287f54d6c8820e050114b5694 (diff) | |
download | vim-git-4f645c54efe33d7a11e314676e503118761f08a7.tar.gz |
patch 8.2.0233: crash when using garbagecollect() in between rand()v8.2.0233
Problem: Crash when using garbagecollect() in between rand().
Solution: Redesign the rand() and srand() implementation. (Yasuhiro
Matsumoto, closes #5587, closes #5588)
Diffstat (limited to 'src/testdir/test_random.vim')
-rw-r--r-- | src/testdir/test_random.vim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/testdir/test_random.vim b/src/testdir/test_random.vim index 747e43848..bdb7e1db0 100644 --- a/src/testdir/test_random.vim +++ b/src/testdir/test_random.vim @@ -11,7 +11,7 @@ func Test_Rand() 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 @@ func Test_Rand() 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 @@ func Test_Rand() call test_settime(0) endfunc + +func Test_issue_5587() + call rand() + call garbagecollect() + call rand() +endfunc |