ppTests MESSY Rearrange tests alphabetically.

- This should be the last messy commit.
- Renamed and re-arranged tests are now easier to navigate.
- Six test failing for different reasons.
This commit is contained in:
damc 2022-07-21 13:34:23 +02:00
parent 812014ea16
commit daa55135bc

View File

@ -882,6 +882,90 @@ mod tests {
contents contents
} }
#[test]
fn escaped_identifier() {
let (ret, _) = preprocess(
testfile_path("escaped_identifier.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/escaped_identifier.sv")
);
}
#[test]
#[allow(non_snake_case)]
fn IEEE18002017_macro_mix_quotes() {
let (ret, _) = preprocess(
testfile_path("IEEE18002017_macro_mix_quotes.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/IEEE18002017_macro_mix_quotes.sv")
);
}
#[test]
#[allow(non_snake_case)]
fn IEEE18002017_macro_noexpand_string() {
let (ret, _) = preprocess(
testfile_path("IEEE18002017_macro_noexpand_string.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/IEEE18002017_macro_noexpand_string.sv")
);
}
#[test]
fn ifdef_nested() {
let (ret, _) = preprocess(
testfile_path("ifdef_nested.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/ifdef_nested.sv")
);
}
#[test]
fn ifdef_predefined() {
let mut defines = HashMap::new();
defines.insert(String::from("behavioral"), None);
let (ret, _) = preprocess(
testfile_path("ifdef_predefined.sv"),
&defines,
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/ifdef_predefined.sv")
)
}
#[test] #[test]
fn ifdef_undefined() { fn ifdef_undefined() {
let (ret, _) = preprocess( let (ret, _) = preprocess(
@ -906,12 +990,10 @@ mod tests {
} }
#[test] #[test]
fn ifdef_predefined() { fn ifndef_undefined() {
let mut defines = HashMap::new();
defines.insert(String::from("behavioral"), None);
let (ret, _) = preprocess( let (ret, _) = preprocess(
testfile_path("ifdef_predefined.sv"), testfile_path("ifndef_undefined.sv"),
&defines, &HashMap::new(),
&[] as &[String], &[] as &[String],
false, false,
false, false,
@ -919,8 +1001,57 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
ret.text(), ret.text(),
testfile_contents("expected/ifdef_predefined.sv") testfile_contents("expected/ifndef_undefined.sv")
);
}
#[test]
fn include_basic() {
let include_paths = [testfile_path("")];
let (ret, _) = preprocess(
testfile_path("include_basic.sv"),
&HashMap::new(),
&include_paths,
false,
false,
) )
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/include_basic.sv")
);
assert_eq!(
ret.origin(10).unwrap().0,
&PathBuf::from(testfile_path("include_basic.sv"))
);
assert_eq!(ret.origin(10).unwrap().1, 10);
assert_eq!(
ret.origin(60).unwrap().0,
&PathBuf::from(testfile_path("test2.svh"))
);
assert_eq!(ret.origin(60).unwrap().1, 74);
assert_eq!(
ret.origin(80).unwrap().0,
&PathBuf::from(testfile_path("include_basic.sv"))
);
assert_eq!(ret.origin(80).unwrap().1, 60);
}
#[test]
fn include_ignore() {
let include_paths = [testfile_path("")];
let (ret, _) = preprocess(
testfile_path("include_ignore.sv"),
&HashMap::new(),
&include_paths,
false,
true,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/include_ignore.sv")
);
} }
#[test] #[test]
@ -956,19 +1087,141 @@ mod tests {
} }
#[test] #[test]
fn include_ignore() { fn include_sameline_comment() {
let include_paths = [testfile_path("")]; let include_paths = [testfile_path("")];
let (ret, _) = preprocess( let (ret, _) = preprocess(
testfile_path("include_ignore.sv"), testfile_path("include_sameline_comment.sv"),
&HashMap::new(), &HashMap::new(),
&include_paths, &include_paths,
false, false,
true, false,
) )
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
ret.text(), ret.text(),
testfile_contents("expected/include_ignore.sv") testfile_contents("expected/include_sameline_comment.sv")
);
assert_eq!(
ret.origin(10).unwrap().0,
&PathBuf::from(testfile_path("include_sameline_comment.sv"))
);
assert_eq!(ret.origin(10).unwrap().1, 10);
assert_eq!(
ret.origin(50).unwrap().0,
&PathBuf::from(testfile_path("test2.svh"))
);
assert_eq!(ret.origin(50).unwrap().1, 73);
assert_eq!(
ret.origin(70).unwrap().0,
&PathBuf::from(testfile_path("include_sameline_comment.sv"))
);
assert_eq!(ret.origin(70).unwrap().1, 50);
}
#[test]
fn include_sameline_include() {
let include_paths = [testfile_path("")];
let ret = preprocess(
testfile_path("include_sameline_include.sv"),
&HashMap::new(),
&include_paths,
false,
false,
);
assert_eq!(format!("{:?}", ret), "Err(IncludeLine)");
}
#[test]
fn include_sameline_keyword() {
let include_paths = [testfile_path("")];
let ret = preprocess(
testfile_path("include_sameline_keyword.sv"),
&HashMap::new(),
&include_paths,
false,
false,
);
assert_eq!(format!("{:?}", ret), "Err(IncludeLine)");
}
#[test]
fn macro_basic() {
let (ret, _) = preprocess(
testfile_path("macro_basic.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_basic.sv")
);
}
#[test]
fn macro_comment() {
let (ret, _) = preprocess(
testfile_path("macro_comment.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_comment.sv")
);
}
#[test]
fn macro_identifier() {
let (ret, _) = preprocess(
testfile_path("macro_identifier.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_identifier.sv")
);
}
#[test]
#[allow(non_snake_case)]
fn macro_LINE() {
let (ret, _) = preprocess(
testfile_path("macro_LINE.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_LINE.sv")
);
}
#[test]
fn macro_multiline_comment() {
let (ret, _) = preprocess(
testfile_path("macro_multiline_comment.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_multiline_comment.sv")
); );
} }
@ -1004,40 +1257,6 @@ mod tests {
); );
} }
#[test]
#[allow(non_snake_case)]
fn IEEE18002017_macro_noexpand_string() {
let (ret, _) = preprocess(
testfile_path("IEEE18002017_macro_noexpand_string.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/IEEE18002017_macro_noexpand_string.sv")
);
}
#[test]
#[allow(non_snake_case)]
fn IEEE18002017_macro_mix_quotes() {
let (ret, _) = preprocess(
testfile_path("IEEE18002017_macro_mix_quotes.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/IEEE18002017_macro_mix_quotes.sv")
);
}
#[test] #[test]
fn macro_recursion_direct() { fn macro_recursion_direct() {
let ret = preprocess( let ret = preprocess(
@ -1062,225 +1281,6 @@ mod tests {
assert_eq!(format!("{:?}", ret), "Err(ExceedRecursiveLimit)"); assert_eq!(format!("{:?}", ret), "Err(ExceedRecursiveLimit)");
} }
#[test]
fn include_sameline_include() {
let include_paths = [testfile_path("")];
let ret = preprocess(
testfile_path("include_sameline_include.sv"),
&HashMap::new(),
&include_paths,
false,
false,
);
assert_eq!(format!("{:?}", ret), "Err(IncludeLine)");
}
#[test]
fn include_sameline_keyword() {
let include_paths = [testfile_path("")];
let ret = preprocess(
testfile_path("include_sameline_keyword.sv"),
&HashMap::new(),
&include_paths,
false,
false,
);
assert_eq!(format!("{:?}", ret), "Err(IncludeLine)");
}
#[test]
#[allow(non_snake_case)]
fn macro_LINE() {
let (ret, _) = preprocess(
testfile_path("macro_LINE.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_LINE.sv")
);
}
#[test]
fn escaped_identifier() {
let (ret, _) = preprocess(
testfile_path("escaped_identifier.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/escaped_identifier.sv")
);
}
#[test]
fn macro_comment() {
let (ret, _) = preprocess(
testfile_path("macro_comment.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_comment.sv")
);
}
#[test]
fn ifdef_nested() {
let (ret, _) = preprocess(
testfile_path("ifdef_nested.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/ifdef_nested.sv")
);
}
#[test]
fn macro_basic() {
let (ret, _) = preprocess(
testfile_path("macro_basic.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_basic.sv")
);
}
#[test]
fn macro_identifier() {
let (ret, _) = preprocess(
testfile_path("macro_identifier.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_identifier.sv")
);
}
#[test]
fn macro_multiline_comment() {
let (ret, _) = preprocess(
testfile_path("macro_multiline_comment.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/macro_multiline_comment.sv")
);
}
#[test]
fn ifndef_undefined() {
let (ret, _) = preprocess(
testfile_path("ifndef_undefined.sv"),
&HashMap::new(),
&[] as &[String],
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/ifndef_undefined.sv")
);
}
#[test]
fn include_sameline_comment() {
let include_paths = [testfile_path("")];
let (ret, _) = preprocess(
testfile_path("include_sameline_comment.sv"),
&HashMap::new(),
&include_paths,
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/include_sameline_comment.sv")
);
assert_eq!(
ret.origin(10).unwrap().0,
&PathBuf::from(testfile_path("include_sameline_comment.sv"))
);
assert_eq!(ret.origin(10).unwrap().1, 10);
assert_eq!(
ret.origin(50).unwrap().0,
&PathBuf::from(testfile_path("test2.svh"))
);
assert_eq!(ret.origin(50).unwrap().1, 73);
assert_eq!(
ret.origin(70).unwrap().0,
&PathBuf::from(testfile_path("include_sameline_comment.sv"))
);
assert_eq!(ret.origin(70).unwrap().1, 50);
}
#[test]
fn include_basic() {
let include_paths = [testfile_path("")];
let (ret, _) = preprocess(
testfile_path("include_basic.sv"),
&HashMap::new(),
&include_paths,
false,
false,
)
.unwrap();
assert_eq!(
ret.text(),
testfile_contents("expected/include_basic.sv")
);
assert_eq!(
ret.origin(10).unwrap().0,
&PathBuf::from(testfile_path("include_basic.sv"))
);
assert_eq!(ret.origin(10).unwrap().1, 10);
assert_eq!(
ret.origin(60).unwrap().0,
&PathBuf::from(testfile_path("test2.svh"))
);
assert_eq!(ret.origin(60).unwrap().1, 74);
assert_eq!(
ret.origin(80).unwrap().0,
&PathBuf::from(testfile_path("include_basic.sv"))
);
assert_eq!(ret.origin(80).unwrap().1, 60);
}
// Check that preprocess() doesn't introduce extra whitespace within and // Check that preprocess() doesn't introduce extra whitespace within and
// around compiler directives. // around compiler directives.
#[test] #[test]