about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2013-07-31 15:01:54 -0700
committerGraydon Hoare <graydon@mozilla.com>2013-07-31 15:02:22 -0700
commit8261f2c37c7181fb4a40e8f8d9eaebb96deea9bb (patch)
tree94272963248357500cd912bb079e1121824cda6b
parent66a0b5870d7c1c436b197d744fba5ced2e5f6462 (diff)
downloadrust-8261f2c37c7181fb4a40e8f8d9eaebb96deea9bb.tar.gz
rust-8261f2c37c7181fb4a40e8f8d9eaebb96deea9bb.zip
test: add more codegen tests, add copyright headers to all.
-rw-r--r--src/test/codegen/iterate-over-array.cc10
-rw-r--r--src/test/codegen/iterate-over-array.rs10
-rw-r--r--src/test/codegen/scalar-function-call.cc10
-rw-r--r--src/test/codegen/scalar-function-call.rs10
-rw-r--r--src/test/codegen/small-dense-int-switch.cc10
-rw-r--r--src/test/codegen/small-dense-int-switch.rs10
-rw-r--r--src/test/codegen/stack-alloc-string-slice.cc10
-rw-r--r--src/test/codegen/stack-alloc-string-slice.rs10
-rw-r--r--src/test/codegen/static-method-call-multi.cc27
-rw-r--r--src/test/codegen/static-method-call-multi.rs28
-rw-r--r--src/test/codegen/static-method-call.cc23
-rw-r--r--src/test/codegen/static-method-call.rs24
-rw-r--r--src/test/codegen/virtual-method-call-struct-return.cc25
-rw-r--r--src/test/codegen/virtual-method-call-struct-return.rs23
-rw-r--r--src/test/codegen/virtual-method-call.cc20
-rw-r--r--src/test/codegen/virtual-method-call.rs18
16 files changed, 268 insertions, 0 deletions
diff --git a/src/test/codegen/iterate-over-array.cc b/src/test/codegen/iterate-over-array.cc
index 7eca21b13d7..9261bddb747 100644
--- a/src/test/codegen/iterate-over-array.cc
+++ b/src/test/codegen/iterate-over-array.cc
@@ -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>
 
diff --git a/src/test/codegen/iterate-over-array.rs b/src/test/codegen/iterate-over-array.rs
index cf54e6eafba..e3bd7f55216 100644
--- a/src/test/codegen/iterate-over-array.rs
+++ b/src/test/codegen/iterate-over-array.rs
@@ -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;
diff --git a/src/test/codegen/scalar-function-call.cc b/src/test/codegen/scalar-function-call.cc
index 91ed882f68a..ce3173ce464 100644
--- a/src/test/codegen/scalar-function-call.cc
+++ b/src/test/codegen/scalar-function-call.cc
@@ -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) {
diff --git a/src/test/codegen/scalar-function-call.rs b/src/test/codegen/scalar-function-call.rs
index 7e4a566749b..e3631b73c02 100644
--- a/src/test/codegen/scalar-function-call.rs
+++ b/src/test/codegen/scalar-function-call.rs
@@ -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
 }
diff --git a/src/test/codegen/small-dense-int-switch.cc b/src/test/codegen/small-dense-int-switch.cc
index 87bc5bf852e..db93829c62b 100644
--- a/src/test/codegen/small-dense-int-switch.cc
+++ b/src/test/codegen/small-dense-int-switch.cc
@@ -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"
diff --git a/src/test/codegen/small-dense-int-switch.rs b/src/test/codegen/small-dense-int-switch.rs
index 6840dc7411b..c6bab3da958 100644
--- a/src/test/codegen/small-dense-int-switch.rs
+++ b/src/test/codegen/small-dense-int-switch.rs
@@ -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 {
diff --git a/src/test/codegen/stack-alloc-string-slice.cc b/src/test/codegen/stack-alloc-string-slice.cc
index 01eae9b16bb..a81f76eee0b 100644
--- a/src/test/codegen/stack-alloc-string-slice.cc
+++ b/src/test/codegen/stack-alloc-string-slice.cc
@@ -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 {
diff --git a/src/test/codegen/stack-alloc-string-slice.rs b/src/test/codegen/stack-alloc-string-slice.rs
index e7cd84f63f2..b776f5a46a7 100644
--- a/src/test/codegen/stack-alloc-string-slice.rs
+++ b/src/test/codegen/stack-alloc-string-slice.rs
@@ -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";
diff --git a/src/test/codegen/static-method-call-multi.cc b/src/test/codegen/static-method-call-multi.cc
new file mode 100644
index 00000000000..6c03e32b98c
--- /dev/null
+++ b/src/test/codegen/static-method-call-multi.cc
@@ -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)))));
+}
diff --git a/src/test/codegen/static-method-call-multi.rs b/src/test/codegen/static-method-call-multi.rs
new file mode 100644
index 00000000000..9cb011a49f8
--- /dev/null
+++ b/src/test/codegen/static-method-call-multi.rs
@@ -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)))))
+}
diff --git a/src/test/codegen/static-method-call.cc b/src/test/codegen/static-method-call.cc
new file mode 100644
index 00000000000..36cfa4f4d84
--- /dev/null
+++ b/src/test/codegen/static-method-call.cc
@@ -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();
+}
diff --git a/src/test/codegen/static-method-call.rs b/src/test/codegen/static-method-call.rs
new file mode 100644
index 00000000000..a1cf6d1dda7
--- /dev/null
+++ b/src/test/codegen/static-method-call.rs
@@ -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()
+}
diff --git a/src/test/codegen/virtual-method-call-struct-return.cc b/src/test/codegen/virtual-method-call-struct-return.cc
new file mode 100644
index 00000000000..345f21c5647
--- /dev/null
+++ b/src/test/codegen/virtual-method-call-struct-return.cc
@@ -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;
+}
diff --git a/src/test/codegen/virtual-method-call-struct-return.rs b/src/test/codegen/virtual-method-call-struct-return.rs
new file mode 100644
index 00000000000..86d737118d6
--- /dev/null
+++ b/src/test/codegen/virtual-method-call-struct-return.rs
@@ -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
+}
diff --git a/src/test/codegen/virtual-method-call.cc b/src/test/codegen/virtual-method-call.cc
new file mode 100644
index 00000000000..9fcafdf6594
--- /dev/null
+++ b/src/test/codegen/virtual-method-call.cc
@@ -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();
+}
diff --git a/src/test/codegen/virtual-method-call.rs b/src/test/codegen/virtual-method-call.rs
new file mode 100644
index 00000000000..66dd41984a7
--- /dev/null
+++ b/src/test/codegen/virtual-method-call.rs
@@ -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()
+}