aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-fail/task-comm-14.rs26
-rw-r--r--src/test/run-pass/task-comm-12.rs23
-rw-r--r--src/test/run-pass/task-comm-13-thread.rs18
-rw-r--r--src/test/run-pass/task-comm-13.rs18
-rw-r--r--src/test/run-pass/task-comm-15.rs14
5 files changed, 99 insertions, 0 deletions
diff --git a/src/test/run-fail/task-comm-14.rs b/src/test/run-fail/task-comm-14.rs
new file mode 100644
index 00000000..f5fa27ac
--- /dev/null
+++ b/src/test/run-fail/task-comm-14.rs
@@ -0,0 +1,26 @@
+io fn main() {
+ let port[int] po = port();
+
+ // Spawn 10 tasks each sending us back one int.
+ let int i = 10;
+ while (i > 0) {
+ log i;
+ spawn "child" child(i, chan(po));
+ i = i - 1;
+ }
+
+ i = 10;
+ let int value = 0;
+ while (i > 0) {
+ log i;
+ value <- po;
+ i = i - 1;
+ }
+
+ log "main thread exiting";
+}
+
+io fn child(int x, chan[int] ch) {
+ log x;
+ ch <| x;
+}
diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs
new file mode 100644
index 00000000..ab7c25e8
--- /dev/null
+++ b/src/test/run-pass/task-comm-12.rs
@@ -0,0 +1,23 @@
+use std;
+import std._task;
+
+fn main() -> () {
+ test00();
+}
+
+fn start(int task_number) {
+ log "Started / Finished Task.";
+}
+
+fn test00() {
+ let int i = 0;
+ let task t = spawn thread start(i);
+
+ // Sleep long enough for the task to finish.
+ _task.sleep(10000u);
+
+ // Try joining tasks that have already finished.
+ join t;
+
+ log "Joined Task.";
+} \ No newline at end of file
diff --git a/src/test/run-pass/task-comm-13-thread.rs b/src/test/run-pass/task-comm-13-thread.rs
new file mode 100644
index 00000000..0dab20ed
--- /dev/null
+++ b/src/test/run-pass/task-comm-13-thread.rs
@@ -0,0 +1,18 @@
+use std;
+import std._task;
+
+io fn start(chan[int] c, int start, int number_of_messages) {
+ let int i = 0;
+ while (i < number_of_messages) {
+ c <| start + i;
+ i += 1;
+ }
+}
+
+fn main() -> () {
+ log "Check that we don't deadlock.";
+ let port[int] p = port();
+ let task a = spawn thread "start" start(chan(p), 0, 10);
+ join a;
+ log "Joined Task";
+} \ No newline at end of file
diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs
new file mode 100644
index 00000000..97bdcb6a
--- /dev/null
+++ b/src/test/run-pass/task-comm-13.rs
@@ -0,0 +1,18 @@
+use std;
+import std._task;
+
+io fn start(chan[int] c, int start, int number_of_messages) {
+ let int i = 0;
+ while (i < number_of_messages) {
+ c <| start + i;
+ i += 1;
+ }
+}
+
+fn main() -> () {
+ log "Check that we don't deadlock.";
+ let port[int] p = port();
+ let task a = spawn "start" start(chan(p), 0, 10);
+ join a;
+ log "Joined Task";
+} \ No newline at end of file
diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs
new file mode 100644
index 00000000..8d748f59
--- /dev/null
+++ b/src/test/run-pass/task-comm-15.rs
@@ -0,0 +1,14 @@
+io fn start(chan[int] c, int n) {
+ let int i = n;
+
+ while(i > 0) {
+ c <| 0;
+ i = i - 1;
+ }
+}
+
+io fn main() {
+ let port[int] p = port();
+ auto child = spawn thread "child" start(chan(p), 10);
+ auto c <- p;
+} \ No newline at end of file