Mercurial > vim
comparison src/testdir/test_vimscript.vim @ 15969:9cc42db77a54 v8.1.0990
patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
commit https://github.com/vim/vim/commit/e21c1580b7acb598a6e3c38565434fe5d0e2ad7a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 2 11:57:09 2019 +0100
patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Problem: Floating point exception with "%= 0" and "/= 0".
Solution: Avoid dividing by zero. (Dominique Pelle, closes https://github.com/vim/vim/issues/4058)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 02 Mar 2019 12:00:06 +0100 |
parents | 05d836c8f1c4 |
children | d13aa9c5a1d1 |
comparison
equal
deleted
inserted
replaced
15968:867ac4696428 | 15969:9cc42db77a54 |
---|---|
19 | 19 |
20 " MakeScript() - Make a script file from a function. {{{2 | 20 " MakeScript() - Make a script file from a function. {{{2 |
21 " | 21 " |
22 " Create a script that consists of the body of the function a:funcname. | 22 " Create a script that consists of the body of the function a:funcname. |
23 " Replace any ":return" by a ":finish", any argument variable by a global | 23 " Replace any ":return" by a ":finish", any argument variable by a global |
24 " variable, and and every ":call" by a ":source" for the next following argument | 24 " variable, and every ":call" by a ":source" for the next following argument |
25 " in the variable argument list. This function is useful if similar tests are | 25 " in the variable argument list. This function is useful if similar tests are |
26 " to be made for a ":return" from a function call or a ":finish" in a script | 26 " to be made for a ":return" from a function call or a ":finish" in a script |
27 " file. | 27 " file. |
28 func MakeScript(funcname, ...) | 28 func MakeScript(funcname, ...) |
29 let script = tempname() | 29 let script = tempname() |
1455 let x %= 3 | 1455 let x %= 3 |
1456 call assert_equal(2, x) | 1456 call assert_equal(2, x) |
1457 let x .= 'n' | 1457 let x .= 'n' |
1458 call assert_equal('2n', x) | 1458 call assert_equal('2n', x) |
1459 | 1459 |
1460 " Test special cases: division or modulus with 0. | |
1461 let x = 1 | |
1462 let x /= 0 | |
1463 if has('num64') | |
1464 call assert_equal(0x7FFFFFFFFFFFFFFF, x) | |
1465 else | |
1466 call assert_equal(0x7fffffff, x) | |
1467 endif | |
1468 | |
1469 let x = -1 | |
1470 let x /= 0 | |
1471 if has('num64') | |
1472 call assert_equal(-0x7FFFFFFFFFFFFFFF, x) | |
1473 else | |
1474 call assert_equal(-0x7fffffff, x) | |
1475 endif | |
1476 | |
1477 let x = 0 | |
1478 let x /= 0 | |
1479 if has('num64') | |
1480 call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x) | |
1481 else | |
1482 call assert_equal(-0x7FFFFFFF - 1, x) | |
1483 endif | |
1484 | |
1485 let x = 1 | |
1486 let x %= 0 | |
1487 call assert_equal(0, x) | |
1488 | |
1489 let x = -1 | |
1490 let x %= 0 | |
1491 call assert_equal(0, x) | |
1492 | |
1493 let x = 0 | |
1494 let x %= 0 | |
1495 call assert_equal(0, x) | |
1496 | |
1460 " Test for string | 1497 " Test for string |
1461 let x = 'str' | 1498 let x = 'str' |
1462 let x .= 'ing' | 1499 let x .= 'ing' |
1463 call assert_equal('string', x) | 1500 call assert_equal('string', x) |
1464 let x += 1 | 1501 let x += 1 |