summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs30
-rw-r--r--tests/expectations/tests/issue-662-part-2.rs23
-rw-r--r--tests/headers/issue-662-cannot-find-T-in-this-scope.hpp7
-rw-r--r--tests/headers/issue-662-part-2.hpp11
-rwxr-xr-xtests/test-one.sh6
5 files changed, 74 insertions, 3 deletions
diff --git a/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs b/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs
new file mode 100644
index 00000000..0c16b235
--- /dev/null
+++ b/tests/expectations/tests/issue-662-cannot-find-T-in-this-scope.rs
@@ -0,0 +1,30 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RefPtr<T> {
+ pub a: T,
+}
+impl <T> Default for RefPtr<T> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsMainThreadPtrHolder<T> {
+ pub a: T,
+}
+impl <T> Default for nsMainThreadPtrHolder<T> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsMainThreadPtrHandle<T> {
+ pub mPtr: RefPtr<nsMainThreadPtrHolder<T>>,
+}
+impl <T> Default for nsMainThreadPtrHandle<T> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/expectations/tests/issue-662-part-2.rs b/tests/expectations/tests/issue-662-part-2.rs
new file mode 100644
index 00000000..fa80c5fe
--- /dev/null
+++ b/tests/expectations/tests/issue-662-part-2.rs
@@ -0,0 +1,23 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T);
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsMainThreadPtrHolder<T> {
+ pub a: T,
+}
+impl <T> Default for nsMainThreadPtrHolder<T> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsMainThreadPtrHandle<U> {
+ pub mPtr: RefPtr<nsMainThreadPtrHolder<U>>,
+}
+impl <U> Default for nsMainThreadPtrHandle<U> {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/headers/issue-662-cannot-find-T-in-this-scope.hpp b/tests/headers/issue-662-cannot-find-T-in-this-scope.hpp
new file mode 100644
index 00000000..6b3f928b
--- /dev/null
+++ b/tests/headers/issue-662-cannot-find-T-in-this-scope.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: -- --std=c++14
+
+template <class T> class RefPtr { T a; };
+template <class T> class nsMainThreadPtrHolder { T a; };
+template <class T> class nsMainThreadPtrHandle {
+ RefPtr<nsMainThreadPtrHolder<T>> mPtr;
+};
diff --git a/tests/headers/issue-662-part-2.hpp b/tests/headers/issue-662-part-2.hpp
new file mode 100644
index 00000000..84edb397
--- /dev/null
+++ b/tests/headers/issue-662-part-2.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: --blacklist-type RefPtr --raw-line '#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T);' -- --std=c++14
+
+// This is pretty much the same as the other issue 662 test case, but this time
+// we blacklist RefPtr to exercise the instantiation-of-a-blacklisted-template
+// path in the template analysis.
+
+template <class> class RefPtr {};
+template <class T> class nsMainThreadPtrHolder { T a; };
+template <class U> class nsMainThreadPtrHandle {
+ RefPtr<nsMainThreadPtrHolder<U>> mPtr;
+};
diff --git a/tests/test-one.sh b/tests/test-one.sh
index c7f9b2ae..cbb89eaf 100755
--- a/tests/test-one.sh
+++ b/tests/test-one.sh
@@ -18,8 +18,8 @@ export RUST_BACKTRACE=1
# Grab the first match
TEST=$(find ./tests/headers -type f -iname "*$1*" | head -n 1)
-BINDINGS=$(mktemp -t bindings_XXXXXX.rs)
-TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXX)
+BINDINGS=$(mktemp -t bindings.rs.XXXXXX)
+TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX)
FLAGS="$(grep "// bindgen-flags: " "$TEST")"
FLAGS="${FLAGS/\/\/ bindgen\-flags:/}"
@@ -41,7 +41,7 @@ echo "=== Generated bindings =================================================="
cat "$BINDINGS"
echo "=== Building bindings ==================================================="
-rustc --test -o "$TEST_BINDINGS_BINARY" "$BINDINGS"
+rustc --test -o "$TEST_BINDINGS_BINARY" "$BINDINGS" --crate-name bindgen_test_one
echo "=== Testing bindings ===================================================="
"$TEST_BINDINGS_BINARY"