aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-08-09 06:53:37 -0700
committerMichael Bebenita <[email protected]>2010-08-09 06:53:37 -0700
commitd647c163fd936c853d76f59ab2c656d554068ab3 (patch)
treec5092621db603321d235ea2bef6ba85e8c2424dd /src/test
parentAdd Or to the AUTHORS file. (diff)
downloadrust-d647c163fd936c853d76f59ab2c656d554068ab3.tar.xz
rust-d647c163fd936c853d76f59ab2c656d554068ab3.zip
Updated/added test cases.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/arith-0.rs5
-rw-r--r--src/test/run-pass/arith-1.rs22
-rw-r--r--src/test/run-pass/arith-2.rs5
-rw-r--r--src/test/run-pass/basic-1.rs25
-rw-r--r--src/test/run-pass/basic-2.rs26
-rw-r--r--src/test/run-pass/task-comm-0.rs2
-rw-r--r--src/test/run-pass/task-comm-2.rs8
-rw-r--r--src/test/run-pass/task-comm-3.rs19
-rw-r--r--src/test/run-pass/task-comm-6.rs6
-rw-r--r--src/test/run-pass/task-comm.rs18
10 files changed, 112 insertions, 24 deletions
diff --git a/src/test/run-pass/arith-0.rs b/src/test/run-pass/arith-0.rs
new file mode 100644
index 00000000..7587b005
--- /dev/null
+++ b/src/test/run-pass/arith-0.rs
@@ -0,0 +1,5 @@
+fn main() -> () {
+ let int a = 10;
+ log a;
+ check (a * (a - 1) == 90);
+} \ No newline at end of file
diff --git a/src/test/run-pass/arith-1.rs b/src/test/run-pass/arith-1.rs
new file mode 100644
index 00000000..bac6a055
--- /dev/null
+++ b/src/test/run-pass/arith-1.rs
@@ -0,0 +1,22 @@
+fn main() -> () {
+ let int i32_a = 10;
+ check(i32_a == 10);
+ check(i32_a - 10 == 0);
+ check(i32_a / 10 == 1);
+ check(i32_a - 20 == -10);
+ check(i32_a << 10 == 10240);
+ check(i32_a << 16 == 655360);
+ check(i32_a * 16 == 160);
+ check(i32_a * i32_a * i32_a == 1000);
+ check(i32_a * i32_a * i32_a * i32_a == 10000);
+ check(((i32_a * i32_a) / i32_a) * i32_a == 100);
+ check(i32_a * (i32_a - 1) << 2 + i32_a == 368640);
+
+ let int i32_b = 0x10101010;
+ check(i32_b + 1 - 1 == i32_b);
+ check(i32_b << 1 == i32_b << 1);
+ check(i32_b >> 1 == i32_b >> 1);
+ check((i32_b & (i32_b << 1)) == 0);
+ log ((i32_b | (i32_b << 1)));
+ check((i32_b | (i32_b << 1)) == 0x30303030);
+} \ No newline at end of file
diff --git a/src/test/run-pass/arith-2.rs b/src/test/run-pass/arith-2.rs
new file mode 100644
index 00000000..33a740c8
--- /dev/null
+++ b/src/test/run-pass/arith-2.rs
@@ -0,0 +1,5 @@
+fn main() -> () {
+ let int i32_c = 0x10101010;
+ check (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
+ i32_c + (((i32_c * 2) / 3) * 2) + (i32_c - (7 % 3)));
+} \ No newline at end of file
diff --git a/src/test/run-pass/basic-1.rs b/src/test/run-pass/basic-1.rs
new file mode 100644
index 00000000..bdd7ee25
--- /dev/null
+++ b/src/test/run-pass/basic-1.rs
@@ -0,0 +1,25 @@
+// -*- rust -*-
+
+io fn a(chan[int] c) {
+ c <| 10;
+}
+
+io fn main() {
+ let port[int] p = port();
+ spawn a(chan(p));
+ spawn b(chan(p));
+ let int n = 0;
+ n <- p;
+ n <- p;
+// log "Finished.";
+}
+
+io fn b(chan[int] c) {
+// log "task b0";
+// log "task b1";
+// log "task b2";
+// log "task b3";
+// log "task b4";
+// log "task b5";
+ c <| 10;
+} \ No newline at end of file
diff --git a/src/test/run-pass/basic-2.rs b/src/test/run-pass/basic-2.rs
new file mode 100644
index 00000000..975a0d4b
--- /dev/null
+++ b/src/test/run-pass/basic-2.rs
@@ -0,0 +1,26 @@
+// -*- rust -*-
+
+io fn a(chan[int] c) {
+ log "task a0";
+ log "task a1";
+ c <| 10;
+}
+
+io fn main() {
+ let port[int] p = port();
+ spawn a(chan(p));
+ spawn b(chan(p));
+ let int n = 0;
+ n <- p;
+ n <- p;
+ log "Finished.";
+}
+
+io fn b(chan[int] c) {
+ log "task b0";
+ log "task b1";
+ log "task b2";
+ log "task b2";
+ log "task b3";
+ c <| 10;
+}
diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs
index 5992ba5c..28294422 100644
--- a/src/test/run-pass/task-comm-0.rs
+++ b/src/test/run-pass/task-comm-0.rs
@@ -15,5 +15,5 @@ io fn test05() {
let int value <- po;
value <- po;
value <- po;
- log value;
+ check(value == 30);
}
diff --git a/src/test/run-pass/task-comm-2.rs b/src/test/run-pass/task-comm-2.rs
index 9c85da34..864d49de 100644
--- a/src/test/run-pass/task-comm-2.rs
+++ b/src/test/run-pass/task-comm-2.rs
@@ -1,8 +1,8 @@
fn main() -> () {
- log "===== THREADS =====";
+ log "===== SPAWNING and JOINING TASKS =====";
+ test00(false);
+ log "===== SPAWNING and JOINING THREAD TASKS =====";
test00(true);
- log "====== TASKS ======";
- // test00(false);
}
fn start(int task_number) {
@@ -15,7 +15,7 @@ fn start(int task_number) {
}
fn test00(bool create_threads) {
- let int number_of_tasks = 0;
+ let int number_of_tasks = 8;
let int i = 0;
let vec[task] tasks = vec();
diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs
index 6dd620cc..9a3f9e16 100644
--- a/src/test/run-pass/task-comm-3.rs
+++ b/src/test/run-pass/task-comm-3.rs
@@ -1,6 +1,8 @@
io fn main() -> () {
- log "===== THREADS =====";
+ log "===== WITHOUT THREADS =====";
test00(false);
+ log "====== WITH THREADS ======";
+ test00(true);
}
io fn test00_start(chan[int] ch, int message, int count) {
@@ -15,8 +17,9 @@ io fn test00_start(chan[int] ch, int message, int count) {
}
io fn test00(bool is_multithreaded) {
- let int number_of_tasks = 1;
- let int number_of_messages = 0;
+ let int number_of_tasks = 16;
+ let int number_of_messages = 4;
+
log "Creating tasks";
let port[int] po = port();
@@ -27,13 +30,13 @@ io fn test00(bool is_multithreaded) {
// Create and spawn tasks...
let vec[task] tasks = vec();
while (i < number_of_tasks) {
- i = i + 1;
if (is_multithreaded) {
tasks += vec(
spawn thread test00_start(ch, i, number_of_messages));
} else {
tasks += vec(spawn test00_start(ch, i, number_of_messages));
}
+ i = i + 1;
}
// Read from spawned tasks...
@@ -53,7 +56,7 @@ io fn test00(bool is_multithreaded) {
}
log "Completed: Final number is: ";
- check (sum + 1 == number_of_messages *
- (number_of_tasks * number_of_tasks + number_of_tasks) / 2);
- log sum;
-} \ No newline at end of file
+ // check (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
+ // number_of_messages));
+ check (sum == 480);
+}
diff --git a/src/test/run-pass/task-comm-6.rs b/src/test/run-pass/task-comm-6.rs
index c579a98c..2774c0ba 100644
--- a/src/test/run-pass/task-comm-6.rs
+++ b/src/test/run-pass/task-comm-6.rs
@@ -31,6 +31,8 @@ io fn test00() {
r <- p; sum += r;
i += 1;
}
-
- check (sum == 4 * ((number_of_messages * (number_of_messages - 1)) / 2));
+
+ check (sum == 1998000);
+ // check (sum == 4 * ((number_of_messages *
+ // (number_of_messages - 1)) / 2));
} \ No newline at end of file
diff --git a/src/test/run-pass/task-comm.rs b/src/test/run-pass/task-comm.rs
index ef71c6e1..3c5d3216 100644
--- a/src/test/run-pass/task-comm.rs
+++ b/src/test/run-pass/task-comm.rs
@@ -1,11 +1,11 @@
-fn main() -> () {
- // test00(true);
+io fn main() -> () {
+ test00(true);
// test01();
- // test02();
- // test03();
- // test04();
- // test05();
+ test02();
+ test03();
+ test04();
+ test05();
test06();
}
@@ -22,7 +22,7 @@ io fn test00_start(chan[int] ch, int message, int count) {
io fn test00(bool is_multithreaded) {
let int number_of_tasks = 1;
- let int number_of_messages = 64;
+ let int number_of_messages = 4;
log "Creating tasks";
let port[int] po = port();
@@ -103,7 +103,7 @@ fn test04_start() {
fn test04() {
log "Spawning lots of tasks.";
- let int i = 64;
+ let int i = 4;
while (i > 0) {
i = i - 1;
spawn thread test04_start();
@@ -139,7 +139,7 @@ fn test06_start(int task_number) {
}
fn test06() {
- let int number_of_tasks = 32;
+ let int number_of_tasks = 4;
log "Creating tasks";
let int i = 0;