Skip to content

Commit

Permalink
fix: add a regression test cased for stop words regex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Oct 2, 2023
1 parent 80a17ae commit 0643e57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions crates/tabby-inference/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ impl IncrementalDecoding {
Some(new_text.to_owned())
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_it_should_not_match() {
let stop_words = vec!["\n\n", "\n\n "];
let re = create_stop_regex(&stop_words);
let text = reverse("void write_u32(std::uint32_t val) const {\n write_raw(&val, sizeof(val));\n }\n\n ~llama_file() {\n if (fp) {\n std::fclose(fp);\n }\n }\n};\n\nvoid");
let matched = re.find(&text).is_some();
assert!(!matched);
}
}
1 change: 0 additions & 1 deletion crates/tabby/src/serve/completions/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ lazy_static! {
"\n\n ",
"\n\n ",
"\n\n ",
"\n\n",
"\n\n\t",
"\n\n\t\t",
"\n\n\t\t\t",
Expand Down

0 comments on commit 0643e57

Please sign in to comment.