Skip to content

Commit

Permalink
add tests for validate_nu_tree_sitter_code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelarie committed Oct 10, 2024
1 parent 2525978 commit 1e04bb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/syntax_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pub use printer::print_tree;
pub use traverser::traverse_tree;

pub use alias::find_aliases;
pub use nushell::validate_nu_tree_sitter_code;
19 changes: 19 additions & 0 deletions src/syntax_tree/nushell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,22 @@ pub fn validate_nu_tree_sitter_code(content: &String) -> bool {

parser.parse(content, None).is_some()
}

// pub fn validate_nu_parsing(content: &String) -> bool {
// // TODO:
// }

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

#[test]
fn test_validate_nu_tree_sitter_code_valid_input() {
let valid_nu_code = "alias ll = ls -alF".to_string();
let result = validate_nu_tree_sitter_code(&valid_nu_code);
assert!(
result,
"Expected valid Nu code to return true, but got false"
);
}
}

0 comments on commit 1e04bb4

Please sign in to comment.