()
| 113 | |
| 114 | |
| 115 | def test_ai_comment_pattern(): |
| 116 | # Create minimal IO and Coder instances for testing |
| 117 | io = InputOutput(pretty=False, fancy_input=False, yes=False) |
| 118 | coder = MinimalCoder(io) |
| 119 | watcher = FileWatcher(coder) |
| 120 | fixtures_dir = Path(__file__).parent.parent / "fixtures" |
| 121 | |
| 122 | # Test Python fixture |
| 123 | py_path = fixtures_dir / "watch.py" |
| 124 | py_lines, py_comments, py_has_bang = watcher.get_ai_comments(str(py_path)) |
| 125 | |
| 126 | # Count unique AI comments (excluding duplicates and variations with extra spaces) |
| 127 | unique_py_comments = set(comment.strip().lower() for comment in py_comments) |
| 128 | |
| 129 | py_expected = 10 |
| 130 | assert len(unique_py_comments) == 10, ( |
| 131 | f"Expected {py_expected} unique AI comments in Python fixture, found" |
| 132 | f" {len(unique_py_comments)}" |
| 133 | ) |
| 134 | assert py_has_bang == "!", "Expected at least one bang (!) comment in Python fixture" |
| 135 | |
| 136 | # Test JavaScript fixture |
| 137 | js_path = fixtures_dir / "watch.js" |
| 138 | js_lines, js_comments, js_has_bang = watcher.get_ai_comments(str(js_path)) |
| 139 | js_expected = 16 |
| 140 | assert ( |
| 141 | len(js_lines) == js_expected |
| 142 | ), f"Expected {js_expected} AI comments in JavaScript fixture, found {len(js_lines)}" |
| 143 | assert js_has_bang == "!", "Expected at least one bang (!) comment in JavaScript fixture" |
| 144 | |
| 145 | # Test watch_question.js fixture |
| 146 | question_js_path = fixtures_dir / "watch_question.js" |
| 147 | question_js_lines, question_js_comments, question_js_has_bang = watcher.get_ai_comments( |
| 148 | str(question_js_path) |
| 149 | ) |
| 150 | question_js_expected = 6 |
| 151 | assert len(question_js_lines) == question_js_expected, ( |
| 152 | f"Expected {question_js_expected} AI comments in watch_question.js fixture, found" |
| 153 | f" {len(question_js_lines)}" |
| 154 | ) |
| 155 | assert ( |
| 156 | question_js_has_bang == "?" |
| 157 | ), "Expected at least one bang (!) comment in watch_question.js fixture" |
| 158 | |
| 159 | # Test Lisp fixture |
| 160 | lisp_path = fixtures_dir / "watch.lisp" |
| 161 | lisp_lines, lisp_comments, lisp_has_bang = watcher.get_ai_comments(str(lisp_path)) |
| 162 | lisp_expected = 7 |
| 163 | assert ( |
| 164 | len(lisp_lines) == lisp_expected |
| 165 | ), f"Expected {lisp_expected} AI comments in Lisp fixture, found {len(lisp_lines)}" |
| 166 | assert lisp_has_bang == "!", "Expected at least one bang (!) comment in Lisp fixture" |
nothing calls this directly
no test coverage detected