about summary refs log tree commit diff
path: root/src/test/run-pass/rt-circular-buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-pass/rt-circular-buffer.rs')
-rw-r--r--src/test/run-pass/rt-circular-buffer.rs69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/test/run-pass/rt-circular-buffer.rs b/src/test/run-pass/rt-circular-buffer.rs
index 2490b4a45ec..11b67593bd6 100644
--- a/src/test/run-pass/rt-circular-buffer.rs
+++ b/src/test/run-pass/rt-circular-buffer.rs
@@ -1,5 +1,3 @@
-
-
 // -*- rust -*-
 
 // Regression tests for circular_buffer when using a unit
@@ -7,7 +5,9 @@
 use std;
 import std::option;
 import std::uint;
-
+import std::comm;
+import std::comm::mk_port;
+import std::comm::send;
 
 // A 12-byte unit to send over the channel
 type record = {val1: u32, val2: u32, val3: u32};
@@ -18,50 +18,52 @@ type record = {val1: u32, val2: u32, val3: u32};
 // power of two so needs to be rounded up. Don't trigger any
 // assertions.
 fn test_init() {
-    let myport: port[record] = port();
-    let mychan = chan(myport);
+    let myport = mk_port[record]();
+    let mychan = myport.mk_chan();
     let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-    mychan <| val;
+    send(mychan, val);
 }
 
 
 // Dump lots of items into the channel so it has to grow.
 // Don't trigger any assertions.
 fn test_grow() {
-    let myport: port[record] = port();
-    let mychan = chan(myport);
-    let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-    for each i: uint in uint::range(0u, 100u) { mychan <| val; }
+    let myport: comm::_port[record] = comm::mk_port();
+    let mychan = myport.mk_chan();
+    for each i: uint  in uint::range(0u, 100u) {
+        let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
+        comm::send(mychan, val);
+    }
 }
 
 
 // Don't allow the buffer to shrink below it's original size
 fn test_shrink1() {
-    let myport: port[i8] = port();
-    let mychan = chan(myport);
-    mychan <| 0i8;
-    let x;
-    myport |> x;
+    let myport = comm::mk_port[i8]();
+    let mychan = myport.mk_chan();
+    send(mychan, 0i8);
+    let x = myport.recv();
 }
 
 fn test_shrink2() {
-    let myport: port[record] = port();
-    let mychan = chan(myport);
-    let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
-    for each i: uint in uint::range(0u, 100u) { mychan <| val; }
-    for each i: uint in uint::range(0u, 100u) { let x; myport |> x; }
+    let myport = mk_port[record]();
+    let mychan = myport.mk_chan();
+    for each i: uint  in uint::range(0u, 100u) {
+        let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
+        send(mychan, val);
+    }
+    for each i: uint  in uint::range(0u, 100u) { let x = myport.recv(); }
 }
 
 
 // Test rotating the buffer when the unit size is not a power of two
 fn test_rotate() {
-    let myport: port[record] = port();
-    let mychan = chan(myport);
-    for each i: uint in uint::range(0u, 100u) {
+    let myport = mk_port[record]();
+    let mychan = myport.mk_chan();
+    for each i: uint  in uint::range(0u, 100u) {
         let val = {val1: i as u32, val2: i as u32, val3: i as u32};
-        mychan <| val;
-        let x;
-        myport |> x;
+        send(mychan, val);
+        let x = myport.recv();
         assert (x.val1 == i as u32);
         assert (x.val2 == i as u32);
         assert (x.val3 == i as u32);
@@ -72,17 +74,16 @@ fn test_rotate() {
 // Test rotating and growing the buffer when
 // the unit size is not a power of two
 fn test_rotate_grow() {
-    let myport: port[record] = port();
-    let mychan = chan(myport);
-    for each j: uint in uint::range(0u, 10u) {
-        for each i: uint in uint::range(0u, 10u) {
+    let myport = mk_port[record]();
+    let mychan = myport.mk_chan();
+    for each j: uint  in uint::range(0u, 10u) {
+        for each i: uint  in uint::range(0u, 10u) {
             let val: record =
                 {val1: i as u32, val2: i as u32, val3: i as u32};
-            mychan <| val;
+            send(mychan, val);
         }
-        for each i: uint in uint::range(0u, 10u) {
-            let x;
-            myport |> x;
+        for each i: uint  in uint::range(0u, 10u) {
+            let x = myport.recv();
             assert (x.val1 == i as u32);
             assert (x.val2 == i as u32);
             assert (x.val3 == i as u32);