changeset 5:7f981c321063

Fix a bug in the mini_fnmatch solution
author Louis Opter <kalessin@kalessin.fr>
date Tue, 10 Dec 2013 19:50:34 -0800
parents 9748b64edb26
children c55a04d93b87
files arrays/mini_fnmatch/solution.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/arrays/mini_fnmatch/solution.py	Sat Jul 13 19:47:11 2013 -0700
+++ b/arrays/mini_fnmatch/solution.py	Tue Dec 10 19:50:34 2013 -0800
@@ -27,7 +27,7 @@
             pat_idx += 1
         else:
             return False
-    return True
+    return name_idx == namelen
 
 def fnmatch_r(name, pat):
     if not name:
@@ -50,6 +50,8 @@
     print('assert fnmatch("toto.py", "*") → ok')
     assert fnmatch("toto.py", "*.py")
     print('assert fnmatch("toto.py", "*.py") → ok')
+    assert not fnmatch("ab.pya", "*.py")
+    print('assert not fnmatch("ab.pya", "*.py") → ok')
     assert not fnmatch("toto.py", "*.c")
     print('assert not fnmatch("toto.py", "*.c") → ok')
     assert fnmatch("toto.py", "toto.*")
@@ -75,6 +77,8 @@
     print('assert fnmatch_r("toto.py", "*") → ok')
     assert fnmatch_r("toto.py", "*.py")
     print('assert fnmatch_r("toto.py", "*.py") → ok')
+    assert not fnmatch("ab.pya", "*.py")
+    print('assert not fnmatch("ab.pya", "*.py") → ok')
     assert not fnmatch_r("toto.py", "*.c")
     print('assert not fnmatch_r("toto.py", "*.c") → ok')
     assert fnmatch_r("toto.py", "toto.*")