1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-07 06:46:59 -05:00

test: unit tests for ignore directives parsing

This commit is contained in:
Ben Heidemann 2024-10-27 16:03:01 +00:00
parent 42979e479d
commit 1ecd6c59ee

View file

@ -190,13 +190,73 @@ mod tests {
}
#[test]
fn test_parse_line_ignore_comments() {
fn test_parse_range_ignore_comments() {
let source_code = r#"
// deno-coverage-ignore
// deno-coverage-ignore-start
function foo(): any {}
// deno-coverage-ignore-stop
function bar(): any {
// deno-coverage-ignore-start
foo();
// deno-coverage-ignore-stop
}
"#;
parse_and_then(source_code, |program| {
let line_directives = parse_range_ignore_directives(&program);
assert_eq!(line_directives.len(), 2);
});
}
#[test]
fn test_parse_range_ignore_comments_unterminated() {
let source_code = r#"
// deno-coverage-ignore-start
function foo(): any {}
function bar(): any {
// deno-coverage-ignore
foo();
}
"#;
parse_and_then(source_code, |program| {
let line_directives = parse_range_ignore_directives(&program);
assert_eq!(line_directives.len(), 1);
});
}
#[test]
fn test_parse_range_ignore_comments_nested() {
let source_code = r#"
// deno-coverage-ignore-start
function foo(): any {}
function bar(): any {
// deno-coverage-ignore-start
foo();
// deno-coverage-ignore-stop
}
// deno-coverage-ignore-stop
"#;
parse_and_then(source_code, |program| {
let line_directives = parse_range_ignore_directives(&program);
assert_eq!(line_directives.len(), 1);
});
}
#[test]
fn test_parse_next_ignore_comments() {
let source_code = r#"
// deno-coverage-ignore-next
function foo(): any {}
function bar(): any {
// deno-coverage-ignore-next
foo();
}
"#;