test: Fix tests.
This commit is contained in:
parent
08e561ae70
commit
db518ef68a
@ -15,8 +15,10 @@
|
||||
|
||||
pub mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
extern fn foo() {}
|
||||
|
||||
static x: *u8 = foo;
|
||||
static x: extern "C" fn() = foo;
|
||||
static y: *libc::c_void = x as *libc::c_void;
|
||||
static a: &'static int = &10;
|
||||
static b: *int = a as *int;
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
extern mod cci_const;
|
||||
use cci_const::bar;
|
||||
static foo: *u8 = bar;
|
||||
static foo: extern "C" fn() = bar;
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(foo, cci_const::bar);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
extern fn foopy() {}
|
||||
|
||||
static f: *u8 = foopy;
|
||||
static f: extern "C" fn() = foopy;
|
||||
static s: S = S { f: foopy };
|
||||
|
||||
struct S {
|
||||
|
@ -10,8 +10,10 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,10 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,10 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,10 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,10 @@ extern fn g() {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
// extern functions are *u8 types
|
||||
let a: *u8 = f;
|
||||
let b: *u8 = f;
|
||||
let c: *u8 = g;
|
||||
// extern functions are extern function types
|
||||
let a: extern "C" fn() = f;
|
||||
let b: extern "C" fn() = f;
|
||||
let c: extern "C" fn() = g;
|
||||
|
||||
assert_eq!(a, b);
|
||||
assert!(a != c);
|
||||
|
@ -10,8 +10,10 @@
|
||||
|
||||
mod rustrt {
|
||||
pub extern {
|
||||
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t)
|
||||
-> libc::uintptr_t;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,16 +10,14 @@
|
||||
|
||||
extern mod std;
|
||||
|
||||
use core::num::Float::{
|
||||
NaN, infinity, neg_infinity
|
||||
};
|
||||
use core::num::Float;
|
||||
|
||||
pub fn main() {
|
||||
let nan = NaN::<float>();
|
||||
let nan = Float::NaN::<float>();
|
||||
assert!((nan).is_NaN());
|
||||
|
||||
let inf = infinity::<float>();
|
||||
assert_eq!(-inf, neg_infinity::<float>());
|
||||
let inf = Float::infinity::<float>();
|
||||
assert_eq!(-inf, Float::neg_infinity::<float>());
|
||||
|
||||
assert!( nan != nan);
|
||||
assert!( nan != -nan);
|
||||
|
@ -1,7 +1,8 @@
|
||||
use core::unstable::run_in_bare_thread;
|
||||
|
||||
extern {
|
||||
pub fn rust_dbg_call(cb: *u8,
|
||||
pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t)
|
||||
-> libc::uintptr_t,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,10 @@
|
||||
|
||||
extern mod static_methods_crate;
|
||||
use static_methods_crate::read;
|
||||
use readMaybeRenamed = static_methods_crate::read::readMaybe;
|
||||
|
||||
pub fn main() {
|
||||
let result: int = read(~"5");
|
||||
assert_eq!(result, 5);
|
||||
assert_eq!(readMaybeRenamed(~"false"), Some(false));
|
||||
assert_eq!(readMaybeRenamed(~"foo"), None::<bool>);
|
||||
assert_eq!(read::readMaybe(~"false"), Some(false));
|
||||
assert_eq!(read::readMaybe(~"foo"), None::<bool>);
|
||||
}
|
||||
|
@ -13,13 +13,13 @@
|
||||
extern mod std;
|
||||
|
||||
use core::cmp::{Eq, Ord};
|
||||
use core::num::NumCast::from;
|
||||
use core::num::NumCast;
|
||||
|
||||
pub trait NumExt: Num + NumCast + Eq + Ord {}
|
||||
|
||||
pub trait FloatExt: NumExt + ApproxEq<Self> {}
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > from(1) }
|
||||
fn greater_than_one_float<T:FloatExt>(n: &T) -> bool { *n > from(1) }
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > NumCast::from(1) }
|
||||
fn greater_than_one_float<T:FloatExt>(n: &T) -> bool { *n > NumCast::from(1) }
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
// Extending Num and using inherited static methods
|
||||
|
||||
use core::num::NumCast::from;
|
||||
use core::num::NumCast;
|
||||
|
||||
trait Num {
|
||||
fn from_int(i: int) -> Self;
|
||||
@ -22,7 +22,7 @@ trait Num {
|
||||
pub trait NumExt: Num + NumCast { }
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool {
|
||||
n.gt(&from(1))
|
||||
n.gt(&NumCast::from(1))
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -9,12 +9,12 @@
|
||||
// except according to those terms.
|
||||
|
||||
use core::cmp::Ord;
|
||||
use core::num::NumCast::from;
|
||||
use core::num::NumCast;
|
||||
|
||||
pub trait NumExt: Num + NumCast + Ord { }
|
||||
|
||||
fn greater_than_one<T:NumExt>(n: &T) -> bool {
|
||||
*n > from(1)
|
||||
*n > NumCast::from(1)
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -15,7 +15,6 @@
|
||||
extern mod std;
|
||||
|
||||
use core::cmp::{Eq, Ord};
|
||||
use core::num::NumCast::from;
|
||||
|
||||
pub trait TypeExt {}
|
||||
|
||||
|
@ -9,13 +9,15 @@
|
||||
// except according to those terms.
|
||||
|
||||
use core::cmp::{Eq, Ord};
|
||||
use core::num::NumCast::from;
|
||||
use core::num::NumCast;
|
||||
|
||||
pub trait NumExt: Eq + Ord + Num + NumCast {}
|
||||
|
||||
impl NumExt for f32 {}
|
||||
|
||||
fn num_eq_one<T:NumExt>(n: T) { io::println(fmt!("%?", n == from(1))) }
|
||||
fn num_eq_one<T:NumExt>(n: T) {
|
||||
io::println(fmt!("%?", n == NumCast::from(1)))
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
num_eq_one(1f32); // you need to actually use the function to trigger the ICE
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use core::cmp::{Eq, Ord};
|
||||
use core::num::NumCast::from;
|
||||
use core::num::NumCast;
|
||||
|
||||
pub trait NumExt: Eq + Num + NumCast {}
|
||||
|
||||
@ -17,7 +17,7 @@ impl NumExt for f32 {}
|
||||
impl NumExt for int {}
|
||||
|
||||
fn num_eq_one<T:NumExt>() -> T {
|
||||
from(1)
|
||||
NumCast::from(1)
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
Loading…
Reference in New Issue
Block a user