diff options
author | Zhiting Zhu <zzhu@mozilla.com> | 2017-08-10 16:53:12 -0700 |
---|---|---|
committer | Zhiting Zhu <zzhu@mozilla.com> | 2017-08-14 10:19:14 -0700 |
commit | 802e2ad08cb20811671f6eb9757f9956bf172da6 (patch) | |
tree | f15b836d8e81b9ef5e3633dffc00bf0608efe2d0 | |
parent | ea4cf0344aadb55660314a92cd090412b1eafcf0 (diff) |
Opaque related tests for derive PartialEq
24 files changed, 59 insertions, 56 deletions
diff --git a/tests/expectations/tests/issue-801-opaque-sloppiness.rs b/tests/expectations/tests/issue-801-opaque-sloppiness.rs index cd2c4fac..b1462ca9 100644 --- a/tests/expectations/tests/issue-801-opaque-sloppiness.rs +++ b/tests/expectations/tests/issue-801-opaque-sloppiness.rs @@ -10,7 +10,7 @@ pub struct A { _unused: [u8; 0], } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct B { pub _bindgen_opaque_blob: u8, } @@ -29,7 +29,7 @@ extern "C" { pub static mut B_a: A; } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct C { pub b: B, } diff --git a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs index 2826ec5d..debfd32e 100644 --- a/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs +++ b/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Pupper { pub _address: u8, } @@ -20,7 +20,7 @@ impl Clone for Pupper { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Doggo { pub _address: u8, } @@ -35,7 +35,7 @@ impl Clone for Doggo { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct SuchWow { pub _address: u8, } @@ -50,7 +50,7 @@ impl Clone for SuchWow { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Opaque { pub _bindgen_opaque_blob: u8, } @@ -89,7 +89,7 @@ extern "C" { pub static mut Opaque_MAJESTIC_AF: Doggo; } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Whitelisted { pub some_member: Opaque, } diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index e052b4d5..587fafe3 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -84,7 +84,7 @@ pub union jsval_layout { _bindgen_union_align: u64, } #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, pub __bindgen_align: [u64; 0usize], diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs index 536d8c59..fd71f862 100644 --- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -31,6 +31,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> { impl <T> ::std::hash::Hash for __BindgenUnionField<T> { fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { } } +impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> { + fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true } +} pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327; pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328; @@ -99,7 +102,7 @@ pub enum JSWhyMagic { JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct jsval_layout { pub asBits: __BindgenUnionField<u64>, pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_1>, @@ -111,7 +114,7 @@ pub struct jsval_layout { pub bindgen_union_field: u64, } #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, pub __bindgen_align: [u64; 0usize], @@ -217,12 +220,12 @@ impl jsval_layout__bindgen_ty_1 { } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct jsval_layout__bindgen_ty_2 { pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { pub i32: __BindgenUnionField<i32>, pub u32: __BindgenUnionField<u32>, @@ -329,7 +332,7 @@ impl Clone for jsval_layout { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Value { pub data: jsval_layout, } diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs index 8c098c8f..848babe4 100644 --- a/tests/expectations/tests/opaque-template-inst-member-2.rs +++ b/tests/expectations/tests/opaque-template-inst-member-2.rs @@ -5,14 +5,14 @@ /// This is like `opaque-template-inst-member.hpp` except exercising the cases -/// where we are OK to derive Debug/Hash. +/// where we are OK to derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] pub struct OpaqueTemplate { } -/// Should derive Debug/Hash. +/// Should derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct ContainsOpaqueTemplate { pub mBlah: u32, pub mBaz: ::std::os::raw::c_int, @@ -39,9 +39,9 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() { impl Clone for ContainsOpaqueTemplate { fn clone(&self) -> Self { *self } } -/// Should also derive Debug/Hash. +/// Should also derive Debug/Hash/PartialEq. #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq)] pub struct InheritsOpaqueTemplate { pub _base: u8, pub wow: *mut ::std::os::raw::c_char, diff --git a/tests/expectations/tests/opaque-template-inst-member.rs b/tests/expectations/tests/opaque-template-inst-member.rs index 11c3cc84..bab28917 100644 --- a/tests/expectations/tests/opaque-template-inst-member.rs +++ b/tests/expectations/tests/opaque-template-inst-member.rs @@ -5,11 +5,11 @@ #[repr(C)] -#[derive(Default, Copy, Clone, Hash)] +#[derive(Default, Copy, Clone, Hash, PartialEq)] pub struct OpaqueTemplate { } -/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive -/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash. +/// This should not end up deriving Debug/Hash/PartialEq because its `mBlah` field cannot derive +/// Debug/Hash/PartialEq because the instantiation's definition cannot derive Debug/Hash/PartialEq. #[repr(C)] pub struct ContainsOpaqueTemplate { pub mBlah: [u32; 101usize], @@ -37,7 +37,7 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() { impl Default for ContainsOpaqueTemplate { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/// This shold not end up deriving Debug/Hash either, for similar reasons, although +/// This shold not end up deriving Debug/Hash/PartialEq either, for similar reasons, although /// we're exercising base member edges now. #[repr(C)] pub struct InheritsOpaqueTemplate { diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs index 396edbd6..6fc0f840 100644 --- a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs +++ b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs @@ -12,7 +12,7 @@ pub mod root { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] - #[derive(Debug, Copy, Clone, Hash)] + #[derive(Debug, Copy, Clone, Hash, PartialEq)] pub struct Template<T> { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, @@ -21,7 +21,7 @@ pub mod root { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash)] + #[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Foo { pub c: ::std::os::raw::c_char, } @@ -41,7 +41,7 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash)] + #[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Bar { pub i: ::std::os::raw::c_int, } @@ -61,7 +61,7 @@ pub mod root { fn clone(&self) -> Self { *self } } #[repr(C)] - #[derive(Debug, Copy, Hash)] + #[derive(Debug, Copy, Hash, PartialEq)] pub struct ContainsInstantiation { pub not_opaque: root::zoidberg::Template<root::zoidberg::Foo>, } @@ -89,7 +89,7 @@ pub mod root { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] - #[derive(Debug, Default, Copy, Hash)] + #[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct ContainsOpaqueInstantiation { pub opaque: u32, } diff --git a/tests/expectations/tests/opaque-template-instantiation.rs b/tests/expectations/tests/opaque-template-instantiation.rs index aafe702f..89f42e53 100644 --- a/tests/expectations/tests/opaque-template-instantiation.rs +++ b/tests/expectations/tests/opaque-template-instantiation.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Copy, Clone, Hash)] +#[derive(Debug, Copy, Clone, Hash, PartialEq)] pub struct Template<T> { pub member: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>, @@ -14,7 +14,7 @@ impl <T> Default for Template<T> { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq)] pub struct ContainsInstantiation { pub not_opaque: Template<::std::os::raw::c_char>, } @@ -39,7 +39,7 @@ impl Default for ContainsInstantiation { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct ContainsOpaqueInstantiation { pub opaque: u32, } diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index 5113ccf3..a5e0dc2b 100644 --- a/tests/expectations/tests/opaque-tracing.rs +++ b/tests/expectations/tests/opaque-tracing.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct Container { pub _bindgen_opaque_blob: [u32; 2usize], } diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index db85246a..29da8da4 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -6,7 +6,7 @@ /// <div rustbindgen opaque> #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct opaque { pub _bindgen_opaque_blob: u32, } @@ -21,7 +21,7 @@ impl Clone for opaque { fn clone(&self) -> Self { *self } } #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct container { pub contained: opaque, } diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 2e566dc4..7988a261 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -6,7 +6,7 @@ /// <div rustbindgen opaque></div> #[repr(C)] -#[derive(Debug, Default, Copy, Hash)] +#[derive(Debug, Default, Copy, Hash, PartialEq)] pub struct OtherOpaque { pub _bindgen_opaque_blob: u32, } @@ -22,11 +22,11 @@ impl Clone for OtherOpaque { } /// <div rustbindgen opaque></div> #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] pub struct Opaque { } #[repr(C)] -#[derive(Debug, Copy, Hash)] +#[derive(Debug, Copy, Hash, PartialEq)] pub struct WithOpaquePtr { pub whatever: *mut u8, pub other: u32, diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 53cf6f64..09717396 100644 --- a/tests/expectations/tests/opaque_typedef.rs +++ b/tests/expectations/tests/opaque_typedef.rs @@ -5,7 +5,7 @@ #[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] pub struct RandomTemplate { pub _address: u8, } diff --git a/tests/headers/issue-801-opaque-sloppiness.hpp b/tests/headers/issue-801-opaque-sloppiness.hpp index 275be023..72d234fb 100644 --- a/tests/headers/issue-801-opaque-sloppiness.hpp +++ b/tests/headers/issue-801-opaque-sloppiness.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type "B" --whitelist-type "C" --with-derive-hash +// bindgen-flags: --opaque-type "B" --whitelist-type "C" --with-derive-hash --with-derive-partialeq class A; diff --git a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp index f2133427..e66ccc5e 100644 --- a/tests/headers/issue-807-opaque-types-methods-being-generated.hpp +++ b/tests/headers/issue-807-opaque-types-methods-being-generated.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque --with-derive-hash -- -std=c++11 +// bindgen-flags: --whitelist-type Whitelisted --opaque-type Opaque --with-derive-hash --with-derive-partialeq -- -std=c++11 // These types are not explicitly whitelisted, but are reachable through the // opaque type. diff --git a/tests/headers/jsval_layout_opaque.hpp b/tests/headers/jsval_layout_opaque.hpp index 4a4f367b..6a730e8e 100644 --- a/tests/headers/jsval_layout_opaque.hpp +++ b/tests/headers/jsval_layout_opaque.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq // bindgen-flags: -- -std=c++11 /** diff --git a/tests/headers/jsval_layout_opaque_1_0.hpp b/tests/headers/jsval_layout_opaque_1_0.hpp index edb84cb7..dd598274 100644 --- a/tests/headers/jsval_layout_opaque_1_0.hpp +++ b/tests/headers/jsval_layout_opaque_1_0.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --rust-target 1.0 --with-derive-hash +// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq // bindgen-flags: -- -std=c++11 /** diff --git a/tests/headers/opaque-template-inst-member-2.hpp b/tests/headers/opaque-template-inst-member-2.hpp index 9d31fa31..09a4ea05 100644 --- a/tests/headers/opaque-template-inst-member-2.hpp +++ b/tests/headers/opaque-template-inst-member-2.hpp @@ -1,20 +1,20 @@ -// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash +// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq /// This is like `opaque-template-inst-member.hpp` except exercising the cases -/// where we are OK to derive Debug/Hash. +/// where we are OK to derive Debug/Hash/PartialEq. template<typename T> class OpaqueTemplate { T mData; }; -/// Should derive Debug/Hash. +/// Should derive Debug/Hash/PartialEq. class ContainsOpaqueTemplate { OpaqueTemplate<int> mBlah; int mBaz; }; -/// Should also derive Debug/Hash. +/// Should also derive Debug/Hash/PartialEq. class InheritsOpaqueTemplate : public OpaqueTemplate<bool> { char* wow; }; diff --git a/tests/headers/opaque-template-inst-member.hpp b/tests/headers/opaque-template-inst-member.hpp index d5954144..2586850f 100644 --- a/tests/headers/opaque-template-inst-member.hpp +++ b/tests/headers/opaque-template-inst-member.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash +// bindgen-flags: --opaque-type 'OpaqueTemplate' --with-derive-hash --with-derive-partialeq template<typename T> class OpaqueTemplate { @@ -6,14 +6,14 @@ class OpaqueTemplate { bool mCannotDebug[400]; }; -/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive -/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash. +/// This should not end up deriving Debug/Hash/PartialEq because its `mBlah` field cannot derive +/// Debug/Hash/PartialEq because the instantiation's definition cannot derive Debug/Hash/PartialEq. class ContainsOpaqueTemplate { OpaqueTemplate<int> mBlah; int mBaz; }; -/// This shold not end up deriving Debug/Hash either, for similar reasons, although +/// This shold not end up deriving Debug/Hash/PartialEq either, for similar reasons, although /// we're exercising base member edges now. class InheritsOpaqueTemplate : public OpaqueTemplate<bool> { char* wow; diff --git a/tests/headers/opaque-template-instantiation-namespaced.hpp b/tests/headers/opaque-template-instantiation-namespaced.hpp index 85513fdf..0c78fc7d 100644 --- a/tests/headers/opaque-template-instantiation-namespaced.hpp +++ b/tests/headers/opaque-template-instantiation-namespaced.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces --opaque-type 'zoidberg::Template<zoidberg::Bar>' --with-derive-hash -- -std=c++14 +// bindgen-flags: --enable-cxx-namespaces --opaque-type 'zoidberg::Template<zoidberg::Bar>' --with-derive-hash --with-derive-partialeq -- -std=c++14 namespace zoidberg { diff --git a/tests/headers/opaque-template-instantiation.hpp b/tests/headers/opaque-template-instantiation.hpp index fe29948d..f0c860f0 100644 --- a/tests/headers/opaque-template-instantiation.hpp +++ b/tests/headers/opaque-template-instantiation.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type 'Template<int>' --with-derive-hash -- -std=c++14 +// bindgen-flags: --opaque-type 'Template<int>' --with-derive-hash --with-derive-partialeq -- -std=c++14 template <typename T> class Template { diff --git a/tests/headers/opaque-tracing.hpp b/tests/headers/opaque-tracing.hpp index 42ef3ccf..5ea72947 100644 --- a/tests/headers/opaque-tracing.hpp +++ b/tests/headers/opaque-tracing.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash +// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash --with-derive-partialeq class Container; diff --git a/tests/headers/opaque_in_struct.hpp b/tests/headers/opaque_in_struct.hpp index 771b80bc..2de2de3e 100644 --- a/tests/headers/opaque_in_struct.hpp +++ b/tests/headers/opaque_in_struct.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq /** <div rustbindgen opaque> */ diff --git a/tests/headers/opaque_pointer.hpp b/tests/headers/opaque_pointer.hpp index cc99df99..40475b8b 100644 --- a/tests/headers/opaque_pointer.hpp +++ b/tests/headers/opaque_pointer.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash +// bindgen-flags: --with-derive-hash --with-derive-partialeq /** * <div rustbindgen opaque></div> diff --git a/tests/headers/opaque_typedef.hpp b/tests/headers/opaque_typedef.hpp index f39f2fce..80586778 100644 --- a/tests/headers/opaque_typedef.hpp +++ b/tests/headers/opaque_typedef.hpp @@ -1,4 +1,4 @@ -// bindgen-flags: --with-derive-hash -- -std=c++11 +// bindgen-flags: --with-derive-hash --with-derive-partialeq -- -std=c++11 template<typename T> class RandomTemplate; |