mirror of https://github.com/boa-dev/boa.git
Haled Odat
2 years ago
committed by
GitHub
5 changed files with 219 additions and 6 deletions
@ -0,0 +1,109 @@
|
||||
use crate::{object::shape::slot::SlotAttributes, property::PropertyKey, JsObject, JsSymbol}; |
||||
|
||||
use super::{SharedShape, TransitionKey}; |
||||
|
||||
#[test] |
||||
fn test_prune_property_on_counter_limit() { |
||||
let shape = SharedShape::root(); |
||||
|
||||
for i in 0..255 { |
||||
assert_eq!( |
||||
shape.forward_transitions().property_transitions_count(), |
||||
(i, i as u8) |
||||
); |
||||
|
||||
shape.insert_property_transition(TransitionKey { |
||||
property_key: PropertyKey::Symbol(JsSymbol::new(None).unwrap()), |
||||
attributes: SlotAttributes::all(), |
||||
}); |
||||
} |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().property_transitions_count(), |
||||
(255, 255) |
||||
); |
||||
|
||||
boa_gc::force_collect(); |
||||
|
||||
{ |
||||
shape.insert_property_transition(TransitionKey { |
||||
property_key: PropertyKey::Symbol(JsSymbol::new(None).unwrap()), |
||||
attributes: SlotAttributes::all(), |
||||
}); |
||||
} |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().property_transitions_count(), |
||||
(1, 0) |
||||
); |
||||
|
||||
{ |
||||
shape.insert_property_transition(TransitionKey { |
||||
property_key: PropertyKey::Symbol(JsSymbol::new(None).unwrap()), |
||||
attributes: SlotAttributes::all(), |
||||
}); |
||||
} |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().property_transitions_count(), |
||||
(2, 1) |
||||
); |
||||
|
||||
boa_gc::force_collect(); |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().property_transitions_count(), |
||||
(2, 1) |
||||
); |
||||
} |
||||
|
||||
#[test] |
||||
fn test_prune_prototype_on_counter_limit() { |
||||
let shape = SharedShape::root(); |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(0, 0) |
||||
); |
||||
|
||||
for i in 0..255 { |
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(i, i as u8) |
||||
); |
||||
|
||||
shape.change_prototype_transition(Some(JsObject::with_null_proto())); |
||||
} |
||||
|
||||
boa_gc::force_collect(); |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(255, 255) |
||||
); |
||||
|
||||
{ |
||||
shape.change_prototype_transition(Some(JsObject::with_null_proto())); |
||||
} |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(1, 0) |
||||
); |
||||
|
||||
{ |
||||
shape.change_prototype_transition(Some(JsObject::with_null_proto())); |
||||
} |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(2, 1) |
||||
); |
||||
|
||||
boa_gc::force_collect(); |
||||
|
||||
assert_eq!( |
||||
shape.forward_transitions().prototype_transitions_count(), |
||||
(2, 1) |
||||
); |
||||
} |
Loading…
Reference in new issue