Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,53 @@
|
||||
use super::{Directory, fixture};
|
||||
use dever::compiler::{build, project::Project};
|
||||
|
||||
#[test]
|
||||
fn async_stream_consumers_keep_values_and_close_all_aliases() {
|
||||
let directory = Directory::new();
|
||||
let project = Project::load(&fixture().with_file_name("async-stream.dever")).unwrap();
|
||||
let program = project.check().unwrap();
|
||||
for (entry, expected) in [
|
||||
("verify", "true\n"),
|
||||
("cleanup", "true\n"),
|
||||
("creation", "AsyncStream\n"),
|
||||
] {
|
||||
let binary =
|
||||
build::build(&program, &project.sources, entry, &directory.0.join(entry)).unwrap();
|
||||
let result = std::process::Command::new(binary).output().unwrap();
|
||||
assert!(
|
||||
result.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&result.stderr)
|
||||
);
|
||||
assert_eq!(result.stdout, expected.as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_tick_period_keeps_its_official_library_location() {
|
||||
let directory = Directory::new();
|
||||
let project = Project::load(&fixture().with_file_name("async-stream.dever")).unwrap();
|
||||
let program = project.check().unwrap();
|
||||
let binary = build::build(
|
||||
&program,
|
||||
&project.sources,
|
||||
"invalid",
|
||||
&directory.0.join("invalid"),
|
||||
)
|
||||
.unwrap();
|
||||
let result = std::process::Command::new(binary).output().unwrap();
|
||||
assert!(!result.status.success());
|
||||
let error = String::from_utf8(result.stderr).unwrap();
|
||||
assert!(error.contains("tick period must be positive"), "{error}");
|
||||
let source = project
|
||||
.sources
|
||||
.iter()
|
||||
.find(|source| source.path.ends_with("lib/dever/task.dever"))
|
||||
.unwrap();
|
||||
let (line, column) =
|
||||
source.position(source.text.find("dever.system.taskTicks(millis)").unwrap());
|
||||
assert!(
|
||||
error.contains(&format!("{}:{line}:{column}:", source.path.display())),
|
||||
"{error}"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user