0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -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:
Darshan Sen 2022-09-13 18:18:53 +05:30 committed by GitHub
parent dbf19c8545
commit 780eb7946b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -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());

View file

@ -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);