From 5eb5baea6885904264ad46948ddb49d8397ee9da Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 3 Apr 2022 17:05:31 +0200 Subject: [PATCH] test: add multiline flatten test (#1101) --- ethers-solc/Cargo.toml | 4 +-- ethers-solc/tests/project.rs | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/ethers-solc/Cargo.toml b/ethers-solc/Cargo.toml index 6dcf599a..4564afce 100644 --- a/ethers-solc/Cargo.toml +++ b/ethers-solc/Cargo.toml @@ -70,12 +70,12 @@ harness = false [[test]] name = "project" path = "tests/project.rs" -required-features = ["async", "solc-svm", "project-util"] +required-features = ["full", "project-util"] [[test]] name = "mocked" path = "tests/mocked.rs" -required-features = ["async", "solc-svm", "project-util"] +required-features = ["full", "project-util"] [features] default = ["rustls"] diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs index 8871fe98..4188067f 100644 --- a/ethers-solc/tests/project.rs +++ b/ethers-solc/tests/project.rs @@ -550,6 +550,57 @@ contract Contract { ); } +#[test] +fn can_flatten_multiline() { + let project = TempProject::dapptools().unwrap(); + + let f = project + .add_source( + "A", + r#" +pragma solidity ^0.8.10; +import "./C.sol"; +import { + IllegalArgument, + IllegalState +} from "./Errors.sol"; +contract A { } +"#, + ) + .unwrap(); + + project + .add_source( + "Errors", + r#" +pragma solidity ^0.8.10; +error IllegalArgument(); +error IllegalState(); +"#, + ) + .unwrap(); + + project + .add_source( + "C", + r#" +pragma solidity ^0.8.10; +contract C { } +"#, + ) + .unwrap(); + + let result = project.flatten(&f).unwrap(); + assert_eq!( + result.trim(), + r#"pragma solidity ^0.8.10; +contract C { } +error IllegalArgument(); +error IllegalState(); +contract A { }"# + ); +} + #[test] fn can_detect_type_error() { let project = TempProject::::dapptools().unwrap();