Mercurial > vim
comparison src/misc2.c @ 7593:87e607fb6853 v7.4.1096
commit https://github.com/vim/vim/commit/a260b87d9da17f605666630f18c1ed909c2b8bae
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 15 20:48:22 2016 +0100
patch 7.4.1096
Problem: Need several lines to verify a command produces an error.
Solution: Add assert_fails(). (suggested by Nikolay Pavlov)
Make the quickfix alloc test actually work.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 15 Jan 2016 21:00:06 +0100 |
parents | 4c922651fd78 |
children | 80bc36419c21 |
comparison
equal
deleted
inserted
replaced
7592:c4dcf67bb056 | 7593:87e607fb6853 |
---|---|
796 } | 796 } |
797 | 797 |
798 #endif /* MEM_PROFILE */ | 798 #endif /* MEM_PROFILE */ |
799 | 799 |
800 #ifdef FEAT_EVAL | 800 #ifdef FEAT_EVAL |
801 static int alloc_does_fail __ARGS((long_u size)); | |
802 | |
801 static int | 803 static int |
802 alloc_does_fail() | 804 alloc_does_fail(size) |
805 long_u size; | |
803 { | 806 { |
804 if (alloc_fail_countdown == 0) | 807 if (alloc_fail_countdown == 0) |
805 { | 808 { |
806 if (--alloc_fail_repeat <= 0) | 809 if (--alloc_fail_repeat <= 0) |
807 alloc_fail_id = 0; | 810 alloc_fail_id = 0; |
811 do_outofmem_msg(size); | |
808 return TRUE; | 812 return TRUE; |
809 } | 813 } |
810 --alloc_fail_countdown; | 814 --alloc_fail_countdown; |
811 return FALSE; | 815 return FALSE; |
812 } | 816 } |
842 alloc_id(size, id) | 846 alloc_id(size, id) |
843 unsigned size; | 847 unsigned size; |
844 alloc_id_T id UNUSED; | 848 alloc_id_T id UNUSED; |
845 { | 849 { |
846 #ifdef FEAT_EVAL | 850 #ifdef FEAT_EVAL |
847 if (alloc_fail_id == id && alloc_does_fail()) | 851 if (alloc_fail_id == id && alloc_does_fail((long_u)size)) |
848 return NULL; | 852 return NULL; |
849 #endif | 853 #endif |
850 return (lalloc((long_u)size, TRUE)); | 854 return (lalloc((long_u)size, TRUE)); |
851 } | 855 } |
852 | 856 |
1006 long_u size; | 1010 long_u size; |
1007 int message; | 1011 int message; |
1008 alloc_id_T id UNUSED; | 1012 alloc_id_T id UNUSED; |
1009 { | 1013 { |
1010 #ifdef FEAT_EVAL | 1014 #ifdef FEAT_EVAL |
1011 if (alloc_fail_id == id && alloc_does_fail()) | 1015 if (alloc_fail_id == id && alloc_does_fail(size)) |
1012 return NULL; | 1016 return NULL; |
1013 #endif | 1017 #endif |
1014 return (lalloc((long_u)size, message)); | 1018 return (lalloc((long_u)size, message)); |
1015 } | 1019 } |
1016 | 1020 |