Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,77 @@
|
||||
use super::linked;
|
||||
|
||||
#[test]
|
||||
fn groups_require_local_affine_handles_and_zero_output_tasks() {
|
||||
let prefix = "work() () {}\nvalue() (answer: Int) { answer = 1 }\n";
|
||||
for body in [
|
||||
"pool = group(2)\n run(pool, work())\n run(pool, work())\n wait(pool)",
|
||||
"wait(group(1))\n stop(group(2))",
|
||||
"pool = group(1)\n wait(pool)\n pool = group(2)\n stop(pool)",
|
||||
] {
|
||||
assert!(
|
||||
linked(&format!("{prefix}main() () {{ {body} }}")).is_ok(),
|
||||
"{body}"
|
||||
);
|
||||
}
|
||||
for body in [
|
||||
"pool = group(2)",
|
||||
"pool = group(2)\n alias = pool\n wait(pool)",
|
||||
"pool = group(2)\n values = [pool]\n wait(pool)",
|
||||
"pool = group(2)\n wait(pool)\n wait(pool)",
|
||||
"pool = group(2)\n wait(pool)\n run(pool, work())",
|
||||
"pool = group(2)\n pool = group(1)\n wait(pool)",
|
||||
] {
|
||||
assert_eq!(
|
||||
linked(&format!("{prefix}main() () {{ {body} }}"))
|
||||
.unwrap_err()
|
||||
.code,
|
||||
"C013",
|
||||
"{body}"
|
||||
);
|
||||
}
|
||||
for body in [
|
||||
"run(group(1), work())",
|
||||
"pool = group(1)\n run(pool, value())\n wait(pool)",
|
||||
] {
|
||||
assert_eq!(
|
||||
linked(&format!("{prefix}main() () {{ {body} }}"))
|
||||
.unwrap_err()
|
||||
.code,
|
||||
"C005"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_wait_discharges_inputs_but_stop_does_not() {
|
||||
let prefix = "type Result { Done\n error Failed(message: Text) }\nhandle(value: Result) () recover(\"handles input\") {}\n";
|
||||
let body = "pool = group(2)\n run(pool, handle(Result.Failed(\"first\")))\n run(pool, handle(Result.Failed(\"second\")))";
|
||||
assert!(linked(&format!("{prefix}main() () {{ {body}\n wait(pool) }}")).is_ok());
|
||||
assert_eq!(
|
||||
linked(&format!("{prefix}main() () {{ {body}\n stop(pool) }}"))
|
||||
.unwrap_err()
|
||||
.code,
|
||||
"C012"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_arguments_keep_ownership_and_transferability_rules() {
|
||||
let prefix =
|
||||
"work(value: Int) () {}\nduration() (value: Int) { dever.task.sleep(0)\n value = 1 }\n";
|
||||
assert!(
|
||||
linked(&format!(
|
||||
"{prefix}main() () {{ pool = group(1)\n run(pool, work(duration()))\n wait(pool) }}"
|
||||
))
|
||||
.is_ok()
|
||||
);
|
||||
assert_eq!(
|
||||
linked(&format!(
|
||||
"{prefix}main() () {{ pool = group(1)\n run(pool, work(length([wait(pool)]))) }}"
|
||||
))
|
||||
.unwrap_err()
|
||||
.code,
|
||||
"C013"
|
||||
);
|
||||
assert_eq!(linked("work(values: List<Stream<Int>>) () {}\nmain() () { pool = group(1)\n run(pool, work([]))\n wait(pool) }").unwrap_err().code, "C013");
|
||||
}
|
||||
Reference in new issue
Block a user