]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Rewrite mostly useless assert in test_trans.py (#3810)
authorfreddiewanah <freddie.wanah@gmail.com>
Thu, 27 Jul 2023 16:51:28 +0000 (02:51 +1000)
committerGitHub <noreply@github.com>
Thu, 27 Jul 2023 16:51:28 +0000 (12:51 -0400)
This PR updates an assert statement that checks the bounds of a
string-slicing operation. The updated assertion provides more accurate
and informative error handling by specifically checking the relative
values of the indices and the string length.

The original assertion was essentially checking if Python's string
slicing was behaving as expected. However, it wasn't providing any
guarantees or useful information about the bounds i and j themselves.

The updated assertion checks that the indices used for slicing are
within the bounds of the string. It will throw an AssertionError if the
indices are out of bounds or if i > j, providing a more specific and
informative error.

tests/test_trans.py

index dce8a939677657549fa5abb35b19e0546d862893..784e852e12a53f1b47faea654e9a208347a8c2ea 100644 (file)
@@ -13,7 +13,7 @@ def test_fexpr_spans() -> None:
         # a glance than only spans
         assert len(spans) == len(expected_slices)
         for (i, j), slice in zip(spans, expected_slices):
-            assert len(string[i:j]) == j - i
+            assert 0 <= i <= j <= len(string)
             assert string[i:j] == slice
 
         assert spans == expected_spans