test: add curly bracket import test
@@ -341,6 +341,7 @@ pub fn create_parent_dir_all(file: impl AsRef<Path>) -> Result<(), SolcError> {
#[cfg(test)]
mod tests {
use super::*;
+ use solang_parser::pt::SourceUnitPart;
use std::{
collections::HashSet,
fs::{create_dir_all, File},
@@ -383,6 +384,22 @@ mod tests {
assert_eq!(files, expected);
}
+ #[test]
+ fn can_parse_curly_bracket_imports() {
+ let s =
+ r#"import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";"#;
+
+ let (unit, _) = solang_parser::parse(s, 0).unwrap();
+ assert_eq!(unit.0.len(), 1);
+ match unit.0[0] {
+ SourceUnitPart::ImportDirective(_, _) => {}
+ _ => unreachable!("failed to parse import"),
+ }
+ let imports: Vec<_> = find_import_paths(s).map(|m| m.as_str()).collect();
+
+ assert_eq!(imports, vec!["@openzeppelin/contracts/utils/ReentrancyGuard.sol"])
+ }
+
#[test]
fn can_find_single_quote_imports() {
let content = r#"
