summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhiting Zhu <zzhu@mozilla.com>2017-08-04 10:17:53 -0700
committerZhiting Zhu <zzhu@mozilla.com>2017-08-09 15:19:00 -0700
commita529e92870c8710d10f870dd09c824091d91f856 (patch)
tree2bee94954105669bc4c0ef854fddb2cea7767231
parentb0fea0e2f1d026ee2d95ac2e8403e4afed7a3ee8 (diff)
Class related tests for derive Hash
-rw-r--r--tests/expectations/tests/class.rs11
-rw-r--r--tests/expectations/tests/class_nested.rs14
-rw-r--r--tests/expectations/tests/class_no_members.rs6
-rw-r--r--tests/expectations/tests/class_static.rs2
-rw-r--r--tests/expectations/tests/class_static_const.rs2
-rw-r--r--tests/expectations/tests/class_use_as.rs4
-rw-r--r--tests/expectations/tests/class_with_dtor.rs4
-rw-r--r--tests/expectations/tests/class_with_inner_struct.rs23
-rw-r--r--tests/expectations/tests/class_with_typedef.rs4
-rw-r--r--tests/headers/class.hpp2
-rw-r--r--tests/headers/class_nested.hpp1
-rw-r--r--tests/headers/class_no_members.hpp1
-rw-r--r--tests/headers/class_static.hpp1
-rw-r--r--tests/headers/class_static_const.hpp1
-rw-r--r--tests/headers/class_use_as.hpp1
-rw-r--r--tests/headers/class_with_dtor.hpp1
-rw-r--r--tests/headers/class_with_inner_struct.hpp1
-rw-r--r--tests/headers/class_with_typedef.hpp1
18 files changed, 48 insertions, 32 deletions
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index 26e6a62c..b628ab11 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -61,6 +61,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt.write_str("__BindgenUnionField")
}
}
+impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+}
#[repr(C)]
#[derive(Copy)]
pub struct C {
@@ -165,7 +168,7 @@ impl Default for C_with_zero_length_array_and_incomplete_array {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Default)]
+#[derive(Debug, Default, Hash)]
pub struct WithDtor {
pub b: ::std::os::raw::c_int,
}
@@ -200,7 +203,7 @@ impl Default for IncompleteArrayNonCopiable {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct Union {
pub d: __BindgenUnionField<f32>,
pub i: __BindgenUnionField<::std::os::raw::c_int>,
@@ -227,7 +230,7 @@ impl Clone for Union {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct WithUnion {
pub data: Union,
}
@@ -247,7 +250,7 @@ impl Clone for WithUnion {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct RealAbstractionWithTonsOfMethods {
pub _address: u8,
}
diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs
index 11e2f939..4172d467 100644
--- a/tests/expectations/tests/class_nested.rs
+++ b/tests/expectations/tests/class_nested.rs
@@ -5,12 +5,12 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A {
pub member_a: ::std::os::raw::c_int,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A_B {
pub member_b: ::std::os::raw::c_int,
}
@@ -30,7 +30,7 @@ impl Clone for A_B {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A_C {
pub baz: ::std::os::raw::c_int,
}
@@ -50,7 +50,7 @@ impl Clone for A_C {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Copy, Clone, Hash)]
pub struct A_D<T> {
pub foo: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
@@ -93,7 +93,7 @@ extern "C" {
pub static mut baz: A_D<::std::os::raw::c_int>;
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct D {
pub member: A_B,
}
@@ -113,13 +113,13 @@ impl Clone for D {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Copy, Clone, Hash)]
pub struct Templated<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
#[repr(C)]
-#[derive(Debug, Copy, Clone)]
+#[derive(Debug, Copy, Clone, Hash)]
pub struct Templated_Templated_inner<T> {
pub member_ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs
index 41b97a9c..e78964fe 100644
--- a/tests/expectations/tests/class_no_members.rs
+++ b/tests/expectations/tests/class_no_members.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct whatever {
pub _address: u8,
}
@@ -20,7 +20,7 @@ impl Clone for whatever {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct whatever_child {
pub _address: u8,
}
@@ -35,7 +35,7 @@ impl Clone for whatever_child {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct whatever_child_with_member {
pub m_member: ::std::os::raw::c_int,
}
diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs
index b48fd052..97dcbf79 100644
--- a/tests/expectations/tests/class_static.rs
+++ b/tests/expectations/tests/class_static.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct MyClass {
pub _address: u8,
}
diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs
index b8e91bd3..a599ed89 100644
--- a/tests/expectations/tests/class_static_const.rs
+++ b/tests/expectations/tests/class_static_const.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A {
pub _address: u8,
}
diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs
index 15cc61f6..a8d26d29 100644
--- a/tests/expectations/tests/class_use_as.rs
+++ b/tests/expectations/tests/class_use_as.rs
@@ -6,7 +6,7 @@
/// <div rustbindgen="true" replaces="whatever"></div>
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct whatever {
pub replacement: ::std::os::raw::c_int,
}
@@ -26,7 +26,7 @@ impl Clone for whatever {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct container {
pub c: whatever,
}
diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs
index cf36f119..8686c41c 100644
--- a/tests/expectations/tests/class_with_dtor.rs
+++ b/tests/expectations/tests/class_with_dtor.rs
@@ -5,7 +5,7 @@
#[repr(C)]
-#[derive(Debug)]
+#[derive(Debug, Hash)]
pub struct HandleWithDtor<T> {
pub ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
@@ -15,7 +15,7 @@ impl <T> Default for HandleWithDtor<T> {
}
pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>;
#[repr(C)]
-#[derive(Debug)]
+#[derive(Debug, Hash)]
pub struct WithoutDtor {
pub shouldBeWithDtor: HandleValue,
}
diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs
index f4b03b4e..4ccafab4 100644
--- a/tests/expectations/tests/class_with_inner_struct.rs
+++ b/tests/expectations/tests/class_with_inner_struct.rs
@@ -28,15 +28,18 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt.write_str("__BindgenUnionField")
}
}
+impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A {
pub c: ::std::os::raw::c_uint,
pub named_union: A__bindgen_ty_1,
pub __bindgen_anon_1: A__bindgen_ty_2,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -62,7 +65,7 @@ impl Clone for A_Segment {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A__bindgen_ty_1 {
pub f: __BindgenUnionField<::std::os::raw::c_int>,
pub bindgen_union_field: u32,
@@ -83,7 +86,7 @@ impl Clone for A__bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct A__bindgen_ty_2 {
pub d: __BindgenUnionField<::std::os::raw::c_int>,
pub bindgen_union_field: u32,
@@ -123,12 +126,12 @@ impl Clone for A {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct B {
pub d: ::std::os::raw::c_uint,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct B_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
@@ -176,13 +179,13 @@ pub enum StepSyntax {
FunctionalWithEndKeyword = 3,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct C {
pub d: ::std::os::raw::c_uint,
pub __bindgen_anon_1: C__bindgen_ty_1,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct C__bindgen_ty_1 {
pub mFunc: __BindgenUnionField<C__bindgen_ty_1__bindgen_ty_1>,
pub __bindgen_anon_1: __BindgenUnionField<C__bindgen_ty_1__bindgen_ty_2>,
@@ -234,7 +237,7 @@ impl Clone for C__bindgen_ty_1__bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct C__bindgen_ty_1__bindgen_ty_2 {
pub mStepSyntax: StepSyntax,
pub mSteps: ::std::os::raw::c_uint,
@@ -283,7 +286,7 @@ impl Clone for C__bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct C_Segment {
pub begin: ::std::os::raw::c_int,
pub end: ::std::os::raw::c_int,
diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs
index 9dba8675..f41aa228 100644
--- a/tests/expectations/tests/class_with_typedef.rs
+++ b/tests/expectations/tests/class_with_typedef.rs
@@ -6,7 +6,7 @@
pub type AnotherInt = ::std::os::raw::c_int;
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct C {
pub c: C_MyInt,
pub ptr: *mut C_MyInt,
@@ -85,7 +85,7 @@ impl C {
}
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct D {
pub _base: C,
pub ptr: *mut C_MyInt,
diff --git a/tests/headers/class.hpp b/tests/headers/class.hpp
index 1de16471..3e183cdf 100644
--- a/tests/headers/class.hpp
+++ b/tests/headers/class.hpp
@@ -1,3 +1,5 @@
+// bindgen-flags: --with-derive-hash
+//
class C {
int a;
// More than rust limits (32)
diff --git a/tests/headers/class_nested.hpp b/tests/headers/class_nested.hpp
index 208bc4be..e01fc947 100644
--- a/tests/headers/class_nested.hpp
+++ b/tests/headers/class_nested.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
class A {
public:
int member_a;
diff --git a/tests/headers/class_no_members.hpp b/tests/headers/class_no_members.hpp
index a4483558..03f916a9 100644
--- a/tests/headers/class_no_members.hpp
+++ b/tests/headers/class_no_members.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
// bindgen-flags: -- -std=c++11
class whatever {
diff --git a/tests/headers/class_static.hpp b/tests/headers/class_static.hpp
index 21ab2321..1e38e5a5 100644
--- a/tests/headers/class_static.hpp
+++ b/tests/headers/class_static.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
class MyClass {
public:
static const int* example;
diff --git a/tests/headers/class_static_const.hpp b/tests/headers/class_static_const.hpp
index 150afe8b..92599183 100644
--- a/tests/headers/class_static_const.hpp
+++ b/tests/headers/class_static_const.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
using int32_t = int;
typedef unsigned int uint32_t;
diff --git a/tests/headers/class_use_as.hpp b/tests/headers/class_use_as.hpp
index a4e36ded..6924255d 100644
--- a/tests/headers/class_use_as.hpp
+++ b/tests/headers/class_use_as.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
/**
* <div rustbindgen="true" replaces="whatever"></div>
diff --git a/tests/headers/class_with_dtor.hpp b/tests/headers/class_with_dtor.hpp
index b9bf74e1..9cc2bad4 100644
--- a/tests/headers/class_with_dtor.hpp
+++ b/tests/headers/class_with_dtor.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
template <typename T>
diff --git a/tests/headers/class_with_inner_struct.hpp b/tests/headers/class_with_inner_struct.hpp
index ec729fe6..781a01db 100644
--- a/tests/headers/class_with_inner_struct.hpp
+++ b/tests/headers/class_with_inner_struct.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
// bindgen-flags: -- -std=c++11
class A {
diff --git a/tests/headers/class_with_typedef.hpp b/tests/headers/class_with_typedef.hpp
index 8707cffe..7abb6f77 100644
--- a/tests/headers/class_with_typedef.hpp
+++ b/tests/headers/class_with_typedef.hpp
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
typedef int AnotherInt;
class C {