Skip to content

Commit 82ff085

Browse files
committed
---
yaml --- r: 455 b: refs/heads/master c: d647c16 h: refs/heads/master i: 453: 77407e8 451: 6499582 447: 0c0acc5 v: v3
1 parent d52b68c commit 82ff085

File tree

11 files changed

+113
-25
lines changed

11 files changed

+113
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: bd7835effa42a37ddf647e9cbf132d601de4700d
2+
refs/heads/master: d647c163fd936c853d76f59ab2c656d554068ab3

trunk/src/test/run-pass/arith-0.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() -> () {
2+
let int a = 10;
3+
log a;
4+
check (a * (a - 1) == 90);
5+
}

trunk/src/test/run-pass/arith-1.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn main() -> () {
2+
let int i32_a = 10;
3+
check(i32_a == 10);
4+
check(i32_a - 10 == 0);
5+
check(i32_a / 10 == 1);
6+
check(i32_a - 20 == -10);
7+
check(i32_a << 10 == 10240);
8+
check(i32_a << 16 == 655360);
9+
check(i32_a * 16 == 160);
10+
check(i32_a * i32_a * i32_a == 1000);
11+
check(i32_a * i32_a * i32_a * i32_a == 10000);
12+
check(((i32_a * i32_a) / i32_a) * i32_a == 100);
13+
check(i32_a * (i32_a - 1) << 2 + i32_a == 368640);
14+
15+
let int i32_b = 0x10101010;
16+
check(i32_b + 1 - 1 == i32_b);
17+
check(i32_b << 1 == i32_b << 1);
18+
check(i32_b >> 1 == i32_b >> 1);
19+
check((i32_b & (i32_b << 1)) == 0);
20+
log ((i32_b | (i32_b << 1)));
21+
check((i32_b | (i32_b << 1)) == 0x30303030);
22+
}

trunk/src/test/run-pass/arith-2.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() -> () {
2+
let int i32_c = 0x10101010;
3+
check (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
4+
i32_c + (((i32_c * 2) / 3) * 2) + (i32_c - (7 % 3)));
5+
}

trunk/src/test/run-pass/basic-1.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// -*- rust -*-
2+
3+
io fn a(chan[int] c) {
4+
c <| 10;
5+
}
6+
7+
io fn main() {
8+
let port[int] p = port();
9+
spawn a(chan(p));
10+
spawn b(chan(p));
11+
let int n = 0;
12+
n <- p;
13+
n <- p;
14+
// log "Finished.";
15+
}
16+
17+
io fn b(chan[int] c) {
18+
// log "task b0";
19+
// log "task b1";
20+
// log "task b2";
21+
// log "task b3";
22+
// log "task b4";
23+
// log "task b5";
24+
c <| 10;
25+
}

trunk/src/test/run-pass/basic-2.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// -*- rust -*-
2+
3+
io fn a(chan[int] c) {
4+
log "task a0";
5+
log "task a1";
6+
c <| 10;
7+
}
8+
9+
io fn main() {
10+
let port[int] p = port();
11+
spawn a(chan(p));
12+
spawn b(chan(p));
13+
let int n = 0;
14+
n <- p;
15+
n <- p;
16+
log "Finished.";
17+
}
18+
19+
io fn b(chan[int] c) {
20+
log "task b0";
21+
log "task b1";
22+
log "task b2";
23+
log "task b2";
24+
log "task b3";
25+
c <| 10;
26+
}

trunk/src/test/run-pass/task-comm-0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ io fn test05() {
1515
let int value <- po;
1616
value <- po;
1717
value <- po;
18-
log value;
18+
check(value == 30);
1919
}

trunk/src/test/run-pass/task-comm-2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fn main() -> () {
2-
log "===== THREADS =====";
2+
log "===== SPAWNING and JOINING TASKS =====";
3+
test00(false);
4+
log "===== SPAWNING and JOINING THREAD TASKS =====";
35
test00(true);
4-
log "====== TASKS ======";
5-
// test00(false);
66
}
77

88
fn start(int task_number) {
@@ -15,7 +15,7 @@ fn start(int task_number) {
1515
}
1616

1717
fn test00(bool create_threads) {
18-
let int number_of_tasks = 0;
18+
let int number_of_tasks = 8;
1919

2020
let int i = 0;
2121
let vec[task] tasks = vec();

trunk/src/test/run-pass/task-comm-3.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
io fn main() -> () {
2-
log "===== THREADS =====";
2+
log "===== WITHOUT THREADS =====";
33
test00(false);
4+
log "====== WITH THREADS ======";
5+
test00(true);
46
}
57

68
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) {
1517
}
1618

1719
io fn test00(bool is_multithreaded) {
18-
let int number_of_tasks = 1;
19-
let int number_of_messages = 0;
20+
let int number_of_tasks = 16;
21+
let int number_of_messages = 4;
22+
2023
log "Creating tasks";
2124

2225
let port[int] po = port();
@@ -27,13 +30,13 @@ io fn test00(bool is_multithreaded) {
2730
// Create and spawn tasks...
2831
let vec[task] tasks = vec();
2932
while (i < number_of_tasks) {
30-
i = i + 1;
3133
if (is_multithreaded) {
3234
tasks += vec(
3335
spawn thread test00_start(ch, i, number_of_messages));
3436
} else {
3537
tasks += vec(spawn test00_start(ch, i, number_of_messages));
3638
}
39+
i = i + 1;
3740
}
3841

3942
// Read from spawned tasks...
@@ -53,7 +56,7 @@ io fn test00(bool is_multithreaded) {
5356
}
5457

5558
log "Completed: Final number is: ";
56-
check (sum + 1 == number_of_messages *
57-
(number_of_tasks * number_of_tasks + number_of_tasks) / 2);
58-
log sum;
59-
}
59+
// check (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
60+
// number_of_messages));
61+
check (sum == 480);
62+
}

trunk/src/test/run-pass/task-comm-6.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ io fn test00() {
3131
r <- p; sum += r;
3232
i += 1;
3333
}
34-
35-
check (sum == 4 * ((number_of_messages * (number_of_messages - 1)) / 2));
34+
35+
check (sum == 1998000);
36+
// check (sum == 4 * ((number_of_messages *
37+
// (number_of_messages - 1)) / 2));
3638
}

trunk/src/test/run-pass/task-comm.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
fn main() -> () {
3-
// test00(true);
2+
io fn main() -> () {
3+
test00(true);
44
// test01();
5-
// test02();
6-
// test03();
7-
// test04();
8-
// test05();
5+
test02();
6+
test03();
7+
test04();
8+
test05();
99
test06();
1010
}
1111

@@ -22,7 +22,7 @@ io fn test00_start(chan[int] ch, int message, int count) {
2222

2323
io fn test00(bool is_multithreaded) {
2424
let int number_of_tasks = 1;
25-
let int number_of_messages = 64;
25+
let int number_of_messages = 4;
2626
log "Creating tasks";
2727

2828
let port[int] po = port();
@@ -103,7 +103,7 @@ fn test04_start() {
103103

104104
fn test04() {
105105
log "Spawning lots of tasks.";
106-
let int i = 64;
106+
let int i = 4;
107107
while (i > 0) {
108108
i = i - 1;
109109
spawn thread test04_start();
@@ -139,7 +139,7 @@ fn test06_start(int task_number) {
139139
}
140140

141141
fn test06() {
142-
let int number_of_tasks = 32;
142+
let int number_of_tasks = 4;
143143
log "Creating tasks";
144144

145145
let int i = 0;

0 commit comments

Comments
 (0)