mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-24 15:19:31 -05:00
fix: property_attribute
operator (#1067)
property_attribute previously had an addition operator overload which doesn't make much sense in comparison to the corresponding V8 enumeration. This changes that to a bitor overload. Signed-off-by: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
parent
dbf19c8545
commit
780eb7946b
2 changed files with 12 additions and 6 deletions
|
@ -52,12 +52,12 @@ impl Default for PropertyAttribute {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::ops::Add for PropertyAttribute {
|
||||
impl std::ops::BitOr for PropertyAttribute {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, Self(rhs): Self) -> Self {
|
||||
fn bitor(self, Self(rhs): Self) -> Self {
|
||||
let Self(lhs) = self;
|
||||
Self(lhs + rhs)
|
||||
Self(lhs | rhs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,15 @@ fn test_attr() {
|
|||
assert!(DONT_DELETE.is_dont_delete());
|
||||
|
||||
assert_eq!(NONE, Default::default());
|
||||
assert_eq!(READ_ONLY, NONE + READ_ONLY);
|
||||
assert_eq!(READ_ONLY, NONE | READ_ONLY);
|
||||
|
||||
let attr = READ_ONLY + DONT_ENUM;
|
||||
let attr = READ_ONLY | DONT_ENUM;
|
||||
assert!(!attr.is_none());
|
||||
assert!(attr.is_read_only());
|
||||
assert!(attr.is_dont_enum());
|
||||
assert!(!attr.is_dont_delete());
|
||||
|
||||
let attr = READ_ONLY | READ_ONLY | DONT_ENUM;
|
||||
assert!(!attr.is_none());
|
||||
assert!(attr.is_read_only());
|
||||
assert!(attr.is_dont_enum());
|
||||
|
|
|
@ -1391,7 +1391,7 @@ fn object_template() {
|
|||
let object_templ = v8::ObjectTemplate::new(scope);
|
||||
let function_templ = v8::FunctionTemplate::new(scope, fortytwo_callback);
|
||||
let name = v8::String::new(scope, "f").unwrap();
|
||||
let attr = v8::READ_ONLY + v8::DONT_ENUM + v8::DONT_DELETE;
|
||||
let attr = v8::READ_ONLY | v8::DONT_ENUM | v8::DONT_DELETE;
|
||||
object_templ.set_internal_field_count(1);
|
||||
object_templ.set_with_attr(name.into(), function_templ.into(), attr);
|
||||
let context = v8::Context::new(scope);
|
||||
|
|
Loading…
Reference in a new issue