-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// autocorrect: false | ||
use super::*; | ||
use autocorrect_derive::GrammarParser; | ||
use pest::Parser as P; | ||
use pest_derive::Parser; | ||
|
||
#[derive(GrammarParser, Parser)] | ||
#[grammar = "../grammar/rust.pest"] | ||
struct ZigParser; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use indoc::indoc; | ||
use pretty_assertions::assert_eq; | ||
|
||
#[test] | ||
fn it_format_yaml() { | ||
let example = indoc! {r###" | ||
//! 这是top-level文档注释 | ||
const std = @import("std"); | ||
/// 这是main函数 | ||
pub fn main() !void { | ||
// 这是comment | ||
const text = "hello你好"; | ||
} | ||
"###}; | ||
|
||
let expect = indoc! {r###" | ||
//! 这是 top-level 文档注释 | ||
const std = @import("std"); | ||
/// 这是 main 函数 | ||
pub fn main() !void { | ||
// 这是 comment | ||
const text = "hello 你好"; | ||
} | ||
"###}; | ||
|
||
assert_eq!(expect, format_for(example, "zig").to_string()) | ||
} | ||
} |