forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_region_borrowck.rs
More file actions
61 lines (59 loc) · 2 KB
/
Copy pathcode_region_borrowck.rs
File metadata and controls
61 lines (59 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use common::InputDb;
use driver::DriverDataBase;
use std::path::PathBuf;
use url::Url;
#[test]
fn code_region_fixture_has_no_semantic_borrow_diagnostics() {
let mut db = DriverDataBase::default();
let fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/code_region.fe");
let file_url = Url::from_file_path(&fixture).expect("fixture path should be absolute");
let content = std::fs::read_to_string(&fixture).expect("fixture should load");
db.workspace()
.touch(&mut db, file_url.clone(), Some(content));
let file = db
.workspace()
.get(&db, &file_url)
.expect("file should be loaded");
let top_mod = db.top_mod(file);
let diags = db.mir_diagnostics_for_top_mod(top_mod);
assert!(
diags
.iter()
.all(|diag| !diag.message.contains("move conflict")),
"{diags:#?}"
);
assert!(
diags
.iter()
.all(|diag| !diag.message.contains("internal borrow checking error")),
"{diags:#?}"
);
}
#[test]
fn erc20_low_level_fixture_has_no_semantic_borrow_diagnostics() {
let mut db = DriverDataBase::default();
let fixture =
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/erc20_low_level.fe");
let file_url = Url::from_file_path(&fixture).expect("fixture path should be absolute");
let content = std::fs::read_to_string(&fixture).expect("fixture should load");
db.workspace()
.touch(&mut db, file_url.clone(), Some(content));
let file = db
.workspace()
.get(&db, &file_url)
.expect("file should be loaded");
let top_mod = db.top_mod(file);
let diags = db.mir_diagnostics_for_top_mod(top_mod);
assert!(
diags
.iter()
.all(|diag| !diag.message.contains("move conflict")),
"{diags:#?}"
);
assert!(
diags
.iter()
.all(|diag| !diag.message.contains("internal borrow checking error")),
"{diags:#?}"
);
}