test: add multiline flatten test (#1101)

This commit is contained in:
Matthias Seitz 2022-04-03 17:05:31 +02:00 committed by GitHub
parent 5bbc6c34ab
commit 5eb5baea68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 2 deletions

View File

@ -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"]

View File

@ -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::<ConfigurableArtifacts>::dapptools().unwrap();