diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index e69de29bb..5fb61f6fa 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -0,0 +1,33 @@ +from pathlib import Path +from aider.watch import FileWatcher + +def test_ai_comment_pattern(): + # Test various AI comment patterns + test_comments = [ + "# ai do something", + "# AI make this better", + "# ai! urgent change needed", + "# AI! another urgent one", + "//ai javascript style", + "//AI do that thing", + "//ai! urgent js thing", + "// ai with some space", + "// AI with caps", + "// ai! with bang", + ] + + # Non-AI comments that shouldn't match + non_ai_comments = [ + "# this is not an ai comment", + "// this is also not an ai comment", + "# aider is not an ai comment", + "// aider is not an ai comment", + ] + + # Test that all AI comments match + for comment in test_comments: + assert FileWatcher.ai_comment_pattern.search(comment), f"Should match: {comment}" + + # Test that non-AI comments don't match + for comment in non_ai_comments: + assert not FileWatcher.ai_comment_pattern.search(comment), f"Should not match: {comment}" diff --git a/tests/fixtures/watch.py b/tests/fixtures/watch.py index e69de29bb..f636f16aa 100644 --- a/tests/fixtures/watch.py +++ b/tests/fixtures/watch.py @@ -0,0 +1,19 @@ +# Regular AI comment +# ai do something +# AI make this better +# ai! urgent change needed +# AI! another urgent one +//ai javascript style +//AI do that thing +//ai! urgent js thing +// ai with some space +// AI with caps +// ai! with bang +# this is not an ai comment +// this is also not an ai comment +# aider is not an ai comment +// aider is not an ai comment + +def dummy_function(): + # ai inside function + pass