Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame^] | 1 | Test for user functions |
| 2 | |
| 3 | STARTTEST |
| 4 | :so small.vim |
| 5 | :function Table(title, ...) |
| 6 | : let ret = a:title |
| 7 | : let idx = 1 |
| 8 | : while idx <= a:0 |
| 9 | : exe "let ret = ret . a:" . idx |
| 10 | : let idx = idx + 1 |
| 11 | : endwhile |
| 12 | : return ret |
| 13 | :endfunction |
| 14 | :function Compute(n1, n2, divname) |
| 15 | : if a:n2 == 0 |
| 16 | : return "fail" |
| 17 | : endif |
| 18 | : exe "let g:" . a:divname . " = ". a:n1 / a:n2 |
| 19 | : return "ok" |
| 20 | :endfunction |
| 21 | :let retval = "nop" |
| 22 | /^here |
| 23 | C=Table("xxx", 4, "asdf") |
| 24 | =Compute(45, 0, "retval") |
| 25 | =retval |
| 26 | =Compute(45, 5, "retval") |
| 27 | =retval |
| 28 | :.wq! test.out |
| 29 | ENDTEST |
| 30 | |
| 31 | here |