test: Fix a bunch of run-pass tests. rs=bustage

This commit is contained in:
Patrick Walton 2012-12-28 17:17:05 -08:00
parent 4e07a6385d
commit f67c37263e
22 changed files with 135 additions and 160 deletions

View File

@ -8,13 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[legacy_exports];
export foo;
use core::oldcomm::*;
fn foo<T: Owned Copy>(x: T) -> Port<T> {
pub fn foo<T: Owned Copy>(x: T) -> Port<T> {
let p = Port();
let c = Chan(&p);
do task::spawn() |copy c, copy x| {

View File

@ -14,15 +14,13 @@ use to_str::*;
use to_str::ToStr;
mod kitty {
#[legacy_exports];
pub struct cat {
priv mut meows : uint,
mut how_hungry : int,
name : ~str,
}
struct cat {
priv mut meows : uint,
mut how_hungry : int,
name : ~str,
}
impl cat : ToStr {
pub impl cat : ToStr {
pure fn to_str() -> ~str { copy self.name }
}
@ -37,7 +35,7 @@ struct cat {
}
impl cat {
pub impl cat {
fn speak() { self.meow(); }
fn eat() -> bool {
@ -52,14 +50,14 @@ struct cat {
}
}
}
fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
cat {
meows: in_x,
how_hungry: in_y,
name: in_name
}
}
}
}

View File

@ -10,17 +10,15 @@
#[link(name = "req")];
#[crate_type = "lib"];
#[legacy_exports];
extern mod std;
use dvec::*;
use dvec::DVec;
use core::dvec::*;
use std::map::HashMap;
type header_map = HashMap<~str, @DVec<@~str>>;
pub type header_map = HashMap<~str, @DVec<@~str>>;
// the unused ty param is necessary so this gets monomorphized
fn request<T: Copy>(req: header_map) {
pub fn request<T: Copy>(req: header_map) {
let _x = copy *(copy *req.get(~"METHOD"))[0u];
}

View File

@ -12,10 +12,8 @@
vers = "0.1")];
#[crate_type = "lib"];
#[legacy_exports];
export read, readMaybe;
trait read {
pub trait read {
static fn readMaybe(s: ~str) -> Option<self>;
}
@ -35,7 +33,7 @@ impl bool: read {
}
}
fn read<T: read Copy>(s: ~str) -> T {
pub fn read<T: read Copy>(s: ~str) -> T {
match read::readMaybe(s) {
Some(x) => x,
_ => fail ~"read failed!"

View File

@ -16,7 +16,7 @@ pub mod num {
}
pub mod float {
impl float: num::Num2 {
impl float: ::num::Num2 {
#[inline]
static pure fn from_int2(n: int) -> float { return n as float; }
}

View File

@ -5,7 +5,7 @@ pub mod num {
}
pub mod float {
impl float: num::Num2 {
impl float: ::num::Num2 {
static pure fn from_int2(n: int) -> float { return n as float; }
}
}
}

View File

@ -13,12 +13,8 @@
Could probably be more minimal.
*/
#[legacy_exports];
use libc::size_t;
export port;
export recv;
use core::libc::size_t;
/**
@ -28,12 +24,12 @@ export recv;
* transmitted. If a port value is copied, both copies refer to the same
* port. Ports may be associated with multiple `chan`s.
*/
enum port<T: Owned> {
pub enum port<T: Owned> {
port_t(@port_ptr<T>)
}
/// Constructs a port
fn port<T: Owned>() -> port<T> {
pub fn port<T: Owned>() -> port<T> {
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>() as size_t)))
}
@ -74,11 +70,11 @@ fn port_ptr<T: Owned>(po: *rust_port) -> port_ptr<T> {
* Receive from a port. If no data is available on the port then the
* task will block until data becomes available.
*/
fn recv<T: Owned>(p: port<T>) -> T { recv_((**p).po) }
pub fn recv<T: Owned>(p: port<T>) -> T { recv_((**p).po) }
/// Receive on a raw port pointer
fn recv_<T: Owned>(p: *rust_port) -> T {
pub fn recv_<T: Owned>(p: *rust_port) -> T {
let yield = 0;
let yieldp = ptr::addr_of(&yield);
let mut res;

View File

@ -26,12 +26,12 @@ use std::serialize::{Encodable, Decodable};
use std::prettyprint;
use std::time;
fn test_prettyprint<A: Encodable<prettyprint::Encoder>>(
fn test_prettyprint<A: Encodable<prettyprint::Serializer>>(
a: &A,
expected: &~str
) {
let s = do io::with_str_writer |w| {
a.encode(&prettyprint::Encoder(w))
a.encode(&prettyprint::Serializer(w))
};
debug!("s == %?", s);
assert s == *expected;

View File

@ -18,7 +18,7 @@
extern mod cci_capture_clause;
use oldcomm::recv;
use core::oldcomm::recv;
fn main() {
cci_capture_clause::foo(()).recv()

View File

@ -9,8 +9,7 @@
// except according to those terms.
// xfail-fast
use to_str::*;
use to_str::ToStr;
use core::to_str::*;
struct cat {
priv mut meows : uint,

View File

@ -9,17 +9,11 @@
// except according to those terms.
mod foo {
#[legacy_exports];
export x;
fn x() { bar::x(); }
pub fn x() { bar::x(); }
}
mod bar {
#[legacy_exports];
export x;
fn x() { debug!("x"); }
pub fn x() { debug!("x"); }
}
fn main() { foo::x(); }

View File

@ -28,14 +28,12 @@ use oldcomm::recv;
fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
mod map_reduce {
#[legacy_exports];
export putter;
export mapper;
export map_reduce;
use std::map;
use std::map::HashMap;
type putter = fn@(~str, ~str);
pub type putter = fn@(~str, ~str);
type mapper = extern fn(~str, putter);
pub type mapper = extern fn(~str, putter);
enum ctrl_proto { find_reducer(~[u8], Chan<int>), mapper_done, }
@ -70,7 +68,7 @@ mod map_reduce {
send(ctrl, mapper_done);
}
fn map_reduce(inputs: ~[~str]) {
pub fn map_reduce(inputs: ~[~str]) {
let ctrl = Port();
// This task becomes the master control task. It spawns others

View File

@ -12,7 +12,7 @@
extern mod std;
use vec::*;
use core::vec::*;
fn main() {
let mut v = from_elem(0u, 0);

View File

@ -21,26 +21,24 @@ extern mod rusti {
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
mod m {
#[legacy_exports];
#[cfg(target_arch = "x86")]
fn main() {
assert rusti::pref_align_of::<u64>() == 8u;
assert rusti::min_align_of::<u64>() == 4u;
pub fn main() {
assert ::rusti::pref_align_of::<u64>() == 8u;
assert ::rusti::min_align_of::<u64>() == 4u;
}
#[cfg(target_arch = "x86_64")]
fn main() {
assert rusti::pref_align_of::<u64>() == 8u;
assert rusti::min_align_of::<u64>() == 8u;
pub fn main() {
assert ::rusti::pref_align_of::<u64>() == 8u;
assert ::rusti::min_align_of::<u64>() == 8u;
}
}
#[cfg(target_os = "win32")]
mod m {
#[legacy_exports];
#[cfg(target_arch = "x86")]
fn main() {
assert rusti::pref_align_of::<u64>() == 8u;
assert rusti::min_align_of::<u64>() == 8u;
pub fn main() {
assert ::rusti::pref_align_of::<u64>() == 8u;
assert ::rusti::min_align_of::<u64>() == 8u;
}
}

View File

@ -10,8 +10,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use libc::{c_double, c_int};
use f64::*;
use core::cast;
use core::libc::{c_double, c_int};
use core::f64::*;
fn to_c_int(v: &mut int) -> &mut c_int unsafe {
cast::reinterpret_cast(&v)
@ -24,13 +25,12 @@ fn lgamma(n: c_double, value: &mut int) -> c_double {
#[link_name = "m"]
#[abi = "cdecl"]
extern mod m {
#[legacy_exports];
#[cfg(unix)]
#[link_name="lgamma_r"] fn lgamma(n: c_double, sign: &mut c_int)
#[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int)
-> c_double;
#[cfg(windows)]
#[link_name="__lgamma_r"] fn lgamma(n: c_double,
sign: &mut c_int) -> c_double;
#[link_name="__lgamma_r"] pub fn lgamma(n: c_double,
sign: &mut c_int) -> c_double;
}

View File

@ -11,31 +11,30 @@
// except according to those terms.
// tjc: I don't know why
mod pipes {
#[legacy_exports];
use cast::{forget, transmute};
pub mod pipes {
use core::cast::{forget, transmute};
enum state {
pub enum state {
empty,
full,
blocked,
terminated
}
impl state : cmp::Eq {
pub impl state : cmp::Eq {
pure fn eq(&self, other: &state) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) }
}
type packet<T: Owned> = {
pub type packet<T: Owned> = {
mut state: state,
mut blocked_task: Option<task::Task>,
mut payload: Option<T>
};
fn packet<T: Owned>() -> *packet<T> unsafe {
pub fn packet<T: Owned>() -> *packet<T> unsafe {
let p: *packet<T> = cast::transmute(~{
mut state: empty,
mut blocked_task: None::<task::Task>,
@ -46,31 +45,30 @@ mod pipes {
#[abi = "rust-intrinsic"]
mod rusti {
#[legacy_exports];
fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail; }
fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail; }
fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail; }
pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail; }
pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail; }
pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail; }
}
// We should consider moving this to core::unsafe, although I
// suspect graydon would want us to use void pointers instead.
unsafe fn uniquify<T>(+x: *T) -> ~T {
pub unsafe fn uniquify<T>(+x: *T) -> ~T {
unsafe { cast::transmute(move x) }
}
fn swap_state_acq(+dst: &mut state, src: state) -> state {
pub fn swap_state_acq(+dst: &mut state, src: state) -> state {
unsafe {
transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int))
}
}
fn swap_state_rel(+dst: &mut state, src: state) -> state {
pub fn swap_state_rel(+dst: &mut state, src: state) -> state {
unsafe {
transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int))
}
}
fn send<T: Owned>(-p: send_packet<T>, -payload: T) {
pub fn send<T: Owned>(-p: send_packet<T>, -payload: T) {
let p = p.unwrap();
let p = unsafe { uniquify(p) };
assert (*p).payload.is_none();
@ -96,7 +94,7 @@ mod pipes {
}
}
fn recv<T: Owned>(-p: recv_packet<T>) -> Option<T> {
pub fn recv<T: Owned>(-p: recv_packet<T>) -> Option<T> {
let p = p.unwrap();
let p = unsafe { uniquify(p) };
loop {
@ -117,7 +115,7 @@ mod pipes {
}
}
fn sender_terminate<T: Owned>(p: *packet<T>) {
pub fn sender_terminate<T: Owned>(p: *packet<T>) {
let p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty | blocked => {
@ -134,7 +132,7 @@ mod pipes {
}
}
fn receiver_terminate<T: Owned>(p: *packet<T>) {
pub fn receiver_terminate<T: Owned>(p: *packet<T>) {
let p = unsafe { uniquify(p) };
match swap_state_rel(&mut (*p).state, terminated) {
empty => {
@ -151,11 +149,11 @@ mod pipes {
}
}
struct send_packet<T: Owned> {
pub struct send_packet<T: Owned> {
mut p: Option<*packet<T>>,
}
impl<T: Owned> send_packet<T> : Drop {
pub impl<T: Owned> send_packet<T> : Drop {
fn finalize(&self) {
if self.p != None {
let mut p = None;
@ -165,7 +163,7 @@ mod pipes {
}
}
impl<T: Owned> send_packet<T> {
pub impl<T: Owned> send_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
@ -173,17 +171,17 @@ mod pipes {
}
}
fn send_packet<T: Owned>(p: *packet<T>) -> send_packet<T> {
pub fn send_packet<T: Owned>(p: *packet<T>) -> send_packet<T> {
send_packet {
p: Some(p)
}
}
struct recv_packet<T: Owned> {
pub struct recv_packet<T: Owned> {
mut p: Option<*packet<T>>,
}
impl<T: Owned> recv_packet<T> : Drop {
pub impl<T: Owned> recv_packet<T> : Drop {
fn finalize(&self) {
if self.p != None {
let mut p = None;
@ -193,7 +191,7 @@ mod pipes {
}
}
impl<T: Owned> recv_packet<T> {
pub impl<T: Owned> recv_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
@ -201,25 +199,27 @@ mod pipes {
}
}
fn recv_packet<T: Owned>(p: *packet<T>) -> recv_packet<T> {
pub fn recv_packet<T: Owned>(p: *packet<T>) -> recv_packet<T> {
recv_packet {
p: Some(p)
}
}
fn entangle<T: Owned>() -> (send_packet<T>, recv_packet<T>) {
pub fn entangle<T: Owned>() -> (send_packet<T>, recv_packet<T>) {
let p = packet();
(send_packet(p), recv_packet(p))
}
}
mod pingpong {
#[legacy_exports];
enum ping = pipes::send_packet<pong>;
enum pong = pipes::send_packet<ping>;
pub mod pingpong {
use core::cast;
use core::ptr;
fn liberate_ping(-p: ping) -> pipes::send_packet<pong> unsafe {
let addr : *pipes::send_packet<pong> = match &p {
pub enum ping = ::pipes::send_packet<pong>;
pub enum pong = ::pipes::send_packet<ping>;
pub fn liberate_ping(-p: ping) -> ::pipes::send_packet<pong> unsafe {
let addr : *::pipes::send_packet<pong> = match &p {
&ping(ref x) => { cast::transmute(ptr::addr_of(x)) }
};
let liberated_value = move *addr;
@ -227,8 +227,8 @@ mod pingpong {
move liberated_value
}
fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe {
let addr : *pipes::send_packet<ping> = match &p {
pub fn liberate_pong(-p: pong) -> ::pipes::send_packet<ping> unsafe {
let addr : *::pipes::send_packet<ping> = match &p {
&pong(ref x) => { cast::transmute(ptr::addr_of(x)) }
};
let liberated_value = move *addr;
@ -236,24 +236,26 @@ mod pingpong {
move liberated_value
}
fn init() -> (client::ping, server::ping) {
pipes::entangle()
pub fn init() -> (client::ping, server::ping) {
::pipes::entangle()
}
mod client {
#[legacy_exports];
type ping = pipes::send_packet<pingpong::ping>;
type pong = pipes::recv_packet<pingpong::pong>;
pub mod client {
use core::option;
use pingpong;
fn do_ping(-c: ping) -> pong {
let (sp, rp) = pipes::entangle();
pub type ping = ::pipes::send_packet<pingpong::ping>;
pub type pong = ::pipes::recv_packet<pingpong::pong>;
pipes::send(move c, ping(move sp));
pub fn do_ping(-c: ping) -> pong {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, ping(move sp));
move rp
}
fn do_pong(-c: pong) -> (ping, ()) {
let packet = pipes::recv(move c);
pub fn do_pong(-c: pong) -> (ping, ()) {
let packet = ::pipes::recv(move c);
if packet.is_none() {
fail ~"sender closed the connection"
}
@ -261,22 +263,23 @@ mod pingpong {
}
}
mod server {
#[legacy_exports];
type ping = pipes::recv_packet<pingpong::ping>;
type pong = pipes::send_packet<pingpong::pong>;
pub mod server {
use pingpong;
fn do_ping(-c: ping) -> (pong, ()) {
let packet = pipes::recv(move c);
pub type ping = ::pipes::recv_packet<pingpong::ping>;
pub type pong = ::pipes::send_packet<pingpong::pong>;
pub fn do_ping(-c: ping) -> (pong, ()) {
let packet = ::pipes::recv(move c);
if packet.is_none() {
fail ~"sender closed the connection"
}
(liberate_ping(option::unwrap(move packet)), ())
}
fn do_pong(-c: pong) -> ping {
let (sp, rp) = pipes::entangle();
pipes::send(move c, pong(move sp));
pub fn do_pong(-c: pong) -> ping {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pong(move sp));
move rp
}
}

Binary file not shown.

View File

@ -12,7 +12,8 @@
// rustc --test map_to_str.rs && ./map_to_str
extern mod std;
use io::{WriterUtil};
use core::io::{WriterUtil};
use std::map::*;
#[cfg(test)]

View File

@ -13,7 +13,7 @@
// Incorrect struct size computation in the FFI, because of not taking
// the alignment of elements into account.
use libc::*;
use core::libc::*;
struct KEYGEN {
hash_algorithm: [c_uint * 2],

View File

@ -18,8 +18,7 @@
// This was generated initially by the pipe compiler, but it's been
// modified in hopefully straightforward ways.
mod pingpong {
#[legacy_exports];
use pipes::*;
use core::pipes::*;
type packets = {
// This is probably a resolve bug, I forgot to export packet,
@ -42,11 +41,10 @@ mod pingpong {
ptr::addr_of(&(data.ping))
}
}
enum ping = server::pong;
enum pong = client::ping;
mod client {
#[legacy_exports];
fn ping(+pipe: ping) -> pong {
pub enum ping = server::pong;
pub enum pong = client::ping;
pub mod client {
pub fn ping(+pipe: ping) -> pong {
{
let b = pipe.reuse_buffer();
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
@ -56,16 +54,15 @@ mod pingpong {
move c
}
}
type ping = pipes::SendPacketBuffered<pingpong::ping,
pub type ping = pipes::SendPacketBuffered<pingpong::ping,
pingpong::packets>;
type pong = pipes::RecvPacketBuffered<pingpong::pong,
pub type pong = pipes::RecvPacketBuffered<pingpong::pong,
pingpong::packets>;
}
mod server {
#[legacy_exports];
type ping = pipes::RecvPacketBuffered<pingpong::ping,
pub mod server {
pub type ping = pipes::RecvPacketBuffered<pingpong::ping,
pingpong::packets>;
fn pong(+pipe: pong) -> ping {
pub fn pong(+pipe: pong) -> ping {
{
let b = pipe.reuse_buffer();
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
@ -75,17 +72,16 @@ mod pingpong {
move c
}
}
type pong = pipes::SendPacketBuffered<pingpong::pong,
pub type pong = pipes::SendPacketBuffered<pingpong::pong,
pingpong::packets>;
}
}
mod test {
#[legacy_exports];
use pipes::recv;
use pingpong::{ping, pong};
fn client(-chan: pingpong::client::ping) {
pub fn client(-chan: pingpong::client::ping) {
use pingpong::client;
let chan = client::ping(move chan); return;
@ -94,7 +90,7 @@ mod test {
log(error, "Received pong");
}
fn server(-chan: pingpong::server::ping) {
pub fn server(-chan: pingpong::server::ping) {
use pingpong::server;
let ping(chan) = recv(move chan); return;

View File

@ -12,6 +12,7 @@
// An example to make sure the protocol parsing syntax extension works.
use core::option;
proto! pingpong (
ping:send {
@ -24,11 +25,10 @@ proto! pingpong (
)
mod test {
#[legacy_exports];
use pipes::recv;
use core::pipes::recv;
use pingpong::{ping, pong};
fn client(-chan: pingpong::client::ping) {
pub fn client(-chan: pingpong::client::ping) {
use pingpong::client;
let chan = client::ping(move chan);
@ -37,7 +37,7 @@ mod test {
log(error, ~"Received pong");
}
fn server(-chan: pingpong::server::ping) {
pub fn server(-chan: pingpong::server::ping) {
use pingpong::server;
let ping(chan) = recv(move chan);

View File

@ -17,7 +17,7 @@ mod base {
dummy: (),
}
pub impl Foo : base::HasNew<Foo> {
pub impl Foo : ::base::HasNew<Foo> {
static pure fn new() -> Foo {
unsafe { io::println("Foo"); }
Foo { dummy: () }
@ -28,7 +28,7 @@ mod base {
dummy: (),
}
pub impl Bar : base::HasNew<Bar> {
pub impl Bar : ::base::HasNew<Bar> {
static pure fn new() -> Bar {
unsafe { io::println("Bar"); }
Bar { dummy: () }