Skip to content

Commit

Permalink
test(nim): validate nimpretty
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Mar 7, 2024
1 parent a840ad3 commit 23fa16d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# Used by nimpretty
- uses: jiro4989/setup-nim-action@v1

- run: rustup toolchain install stable --profile minimal
- run: rustup component add rustfmt clippy
Expand Down
27 changes: 27 additions & 0 deletions src/formatters/nimpretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,30 @@ pub fn format_using_nimpretty(file_path: &std::path::Path) -> std::io::Result<Op

Ok(None)
}

#[cfg(test)]
mod test_nimpretty {
use crate::{
formatters::{nimpretty::format_using_nimpretty, setup_snippet},
languages::Language,
};

#[test]
fn it_should_format_toml() {
let input = "proc add( a :int , b:int ) : int =
return a + b ";

let expected_output = "proc add(a: int, b: int): int =
return a + b
";

let snippet =
setup_snippet(input, Language::Nim.to_file_ext()).expect("it to create a snippet file");

let output = format_using_nimpretty(snippet.path())
.expect("it to be succesful")
.expect("it to be some");

assert_eq!(expected_output, output);
}
}

0 comments on commit 23fa16d

Please sign in to comment.