Browse Source

Fix hanging test262 bug by setting the length on String objects (#728)

Co-authored-by: Halid Odat <halidodat@gmail.com>
pull/739/head
Jason Williams 4 years ago committed by GitHub
parent
commit
2a17e24d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      boa/src/exec/tests.rs
  2. 8
      boa/src/value/mod.rs

9
boa/src/exec/tests.rs

@ -33,6 +33,15 @@ fn property_accessor_member_expression_bracket_notation_on_string_literal() {
assert_eq!(&exec(scenario), "\"function\"");
}
#[test]
fn length_correct_value_on_string_literal() {
let scenario = r#"
'hello'.length;
"#;
assert_eq!(&exec(scenario), "5");
}
#[test]
fn property_accessor_member_expression_dot_notation_on_function() {
let scenario = r#"

8
boa/src/value/mod.rs

@ -713,10 +713,10 @@ impl Value {
.expect("String was not initialized")
.get_field(PROTOTYPE);
Ok(GcObject::new(Object::with_prototype(
proto,
ObjectData::String(string.clone()),
)))
let mut obj = Object::with_prototype(proto, ObjectData::String(string.clone()));
// Make sure the correct length is set on our new string object
obj.set("length".into(), string.chars().count().into());
Ok(GcObject::new(obj))
}
Value::Symbol(ref symbol) => {
let proto = ctx

Loading…
Cancel
Save