testsuite: more pub fn main

This commit is contained in:
Tim Chevalier 2013-03-27 09:58:28 -07:00
parent e23fad0e6a
commit fad05591e5
25 changed files with 126 additions and 26 deletions

View file

@ -1,7 +1,17 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Eq)]
struct Point { x : int }
fn main() {
pub fn main() {
assert_eq!(14,14);
assert_eq!(~"abc",~"abc");
assert_eq!(~Point{x:34},~Point{x:34});

View file

@ -10,6 +10,6 @@
static a: *u8 = 0 as *u8;
fn main() {
pub fn main() {
fail_unless!(a == ptr::null());
}

View file

@ -15,7 +15,7 @@
static a: &'static int = &10;
static b: *int = a as *int;
fn main() {
pub fn main() {
fail_unless!(x as *libc::c_void == y);
fail_unless!(a as *int == b);
}

View file

@ -15,6 +15,6 @@
use cci_const::bar;
static foo: *u8 = bar;
fn main() {
pub fn main() {
fail_unless!(foo == cci_const::bar);
}

View file

@ -11,7 +11,7 @@
enum A { A1, A2 }
enum B { B1=0, B2=2 }
fn main () {
pub fn main () {
static c1: int = A2 as int;
static c2: int = B2 as int;
static c3: float = A2 as float;

View file

@ -15,7 +15,7 @@ enum E {
static C: E = S1 { u: 23 };
fn main() {
pub fn main() {
match C {
S0 { _ } => fail!(),
S1 { u } => fail_unless!(u == 23)

View file

@ -11,7 +11,7 @@
// Check that constant expressions can be used for declaring the
// type of a fixed length vector.
fn main() {
pub fn main() {
static FOO: int = 2;
let _v: [int, ..FOO*3];

View file

@ -10,7 +10,7 @@
// Check that constant expressions can be used in vec repeat syntax.
fn main() {
pub fn main() {
static FOO: int = 2;
let _v = [0, ..FOO*3*2/2];

View file

@ -12,7 +12,7 @@
static c: &'static [u8, ..3] = &a;
static b: *u8 = c as *u8;
fn main() {
pub fn main() {
let foo = &a as *u8;
fail_unless!(unsafe { str::raw::from_bytes(a) } == ~"hi\x00");
fail_unless!(unsafe { str::raw::from_buf(foo) } == ~"hi");

View file

@ -1,6 +1,16 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(_: &const [int]) {}
fn main() {
pub fn main() {
let v = [ 1, 2, 3 ];
f(v);
}

View file

@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone)]
enum E {
A,
@ -5,5 +15,5 @@ enum E {
C
}
fn main() {}
pub fn main() {}

View file

@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone)]
struct S<T> {
foo: (),
@ -5,5 +15,5 @@ struct S<T> {
baz: T,
}
fn main() {}
pub fn main() {}

View file

@ -1,5 +1,15 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone)]
struct S((), ());
fn main() {}
pub fn main() {}

View file

@ -30,7 +30,7 @@ fn check_strs(actual: &str, expected: &str) -> bool
return true;
}
fn main()
pub fn main()
{
// fail_unless!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")"));
// fail_unless!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")"));

View file

@ -12,7 +12,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main()
pub fn main()
{
unsafe {
libc::exit(0);

View file

@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
pub fn main() {
let foo = [0, ..2*4];
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
pub fn main() {
let (port, chan) = comm::stream::<&'static str>();
do task::spawn {

View file

@ -18,6 +18,6 @@ struct S<'self> {
fn f<'lt>(_s: &'lt S<'lt>) {}
fn main() {
pub fn main() {
f(& S { v: &42 });
}

View file

@ -1,8 +1,18 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
enum Numbers {
Three
}
fn main() {
pub fn main() {
debug!(1);
info!(2.0);
warn!(Three);

View file

@ -1,8 +1,18 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::io::println;
static FOO: int = 3;
fn main() {
pub fn main() {
println(fmt!("%d", FOO));
}

View file

@ -1,8 +1,18 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::io::println;
static FOO: [int, ..3] = [1, 2, 3];
fn main() {
pub fn main() {
println(fmt!("%d %d %d", FOO[0], FOO[1], FOO[2]));
}

View file

@ -10,7 +10,7 @@
// Why one-tuples? Because macros.
fn main() {
pub fn main() {
match ('c',) {
(x,) => {
fail_unless!(x == 'c');

View file

@ -1,4 +1,14 @@
fn main() {
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let foo = 1;
let bar = 2;
let foobar = foo + bar;

View file

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -18,4 +18,4 @@ pub impl Foo {
fn foo(&'a self) {}
}
fn main() {}
pub fn main() {}

View file

@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test how region-parameterization inference
// interacts with explicit self types.
//
@ -22,7 +32,7 @@ fn get_int<G: Getter>(g: &G) -> int {
*g.get()
}
fn main() {
pub fn main() {
let foo = Foo { field: 22 };
fail_unless!(get_int(&foo) == 22);
}