auto merge of #8165 : graydon/rust/2013-07-31-new-codegen-tests, r=brson
r? @pcwalton or someone
This commit is contained in:
commit
7daea7c9c1
@ -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.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -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.
|
||||
|
||||
#[no_mangle]
|
||||
fn test(x: &[int]) -> int {
|
||||
let mut y = 0;
|
||||
|
@ -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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t foo(size_t x) {
|
||||
|
@ -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.
|
||||
|
||||
fn foo(x: int) -> int {
|
||||
x * x
|
||||
}
|
||||
|
@ -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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C"
|
||||
|
@ -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.
|
||||
|
||||
#[no_mangle]
|
||||
fn test(x: int, y: int) -> int {
|
||||
match x {
|
||||
|
@ -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.
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct slice {
|
||||
|
@ -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.
|
||||
|
||||
#[no_mangle]
|
||||
fn test() {
|
||||
let _x = "hello";
|
||||
|
27
src/test/codegen/static-method-call-multi.cc
Normal file
27
src/test/codegen/static-method-call-multi.cc
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Struct {
|
||||
size_t field;
|
||||
size_t method(size_t x) {
|
||||
return this->field + x;
|
||||
}
|
||||
};
|
||||
|
||||
extern "C"
|
||||
size_t test(Struct &a,
|
||||
Struct &b,
|
||||
Struct &c,
|
||||
Struct &d,
|
||||
Struct &e) {
|
||||
return a.method(b.method(c.method(d.method(e.method(1)))));
|
||||
}
|
28
src/test/codegen/static-method-call-multi.rs
Normal file
28
src/test/codegen/static-method-call-multi.rs
Normal file
@ -0,0 +1,28 @@
|
||||
// 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.
|
||||
|
||||
struct Struct {
|
||||
field: int
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
fn method(&self, x: int) -> int {
|
||||
self.field + x
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn test(a: &Struct,
|
||||
b: &Struct,
|
||||
c: &Struct,
|
||||
d: &Struct,
|
||||
e: &Struct) -> int {
|
||||
a.method(b.method(c.method(d.method(e.method(1)))))
|
||||
}
|
23
src/test/codegen/static-method-call.cc
Normal file
23
src/test/codegen/static-method-call.cc
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Struct {
|
||||
size_t field;
|
||||
size_t method() {
|
||||
return this->field;
|
||||
}
|
||||
};
|
||||
|
||||
extern "C"
|
||||
size_t test(Struct &s) {
|
||||
return s.method();
|
||||
}
|
24
src/test/codegen/static-method-call.rs
Normal file
24
src/test/codegen/static-method-call.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.
|
||||
|
||||
struct Struct {
|
||||
field: int
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
fn method(&self) -> int {
|
||||
self.field
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn test(s: &Struct) -> int {
|
||||
s.method()
|
||||
}
|
25
src/test/codegen/virtual-method-call-struct-return.cc
Normal file
25
src/test/codegen/virtual-method-call-struct-return.cc
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Stuff {
|
||||
size_t a;
|
||||
double b;
|
||||
};
|
||||
|
||||
struct Struct {
|
||||
virtual Stuff method() = 0;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
size_t test(Struct &s) {
|
||||
return s.method().a;
|
||||
}
|
23
src/test/codegen/virtual-method-call-struct-return.rs
Normal file
23
src/test/codegen/virtual-method-call-struct-return.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
struct Stuff {
|
||||
a: int,
|
||||
b: f64
|
||||
}
|
||||
|
||||
trait Trait {
|
||||
fn method(&self) -> Stuff;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn test(t: &Trait) -> int {
|
||||
t.method().a
|
||||
}
|
20
src/test/codegen/virtual-method-call.cc
Normal file
20
src/test/codegen/virtual-method-call.cc
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Struct {
|
||||
virtual size_t method() = 0;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
size_t test(Struct &s) {
|
||||
return s.method();
|
||||
}
|
18
src/test/codegen/virtual-method-call.rs
Normal file
18
src/test/codegen/virtual-method-call.rs
Normal file
@ -0,0 +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.
|
||||
|
||||
trait Trait {
|
||||
fn method(&self) -> int;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn test(t: &Trait) -> int {
|
||||
t.method()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user