Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
test: add curly bracket import test (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Feb 18, 2022
1 parent 28df48b commit f2796cc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ethers-solc/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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#"
Expand Down

0 comments on commit f2796cc

Please sign in to comment.