# HG changeset patch # User Louis Opter # Date 1386733834 28800 # Node ID 7f981c3210639a1152987787adaebe3959aee88d # Parent 9748b64edb26606431ab00bda1192920c698b2b5 Fix a bug in the mini_fnmatch solution diff -r 9748b64edb26 -r 7f981c321063 arrays/mini_fnmatch/solution.py --- 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.*")