Browse Source

Change StringGetOwnProperty to produce the same strings that the lexer produces (#1460)

pull/1451/head
raskad 3 years ago committed by GitHub
parent
commit
e9093b39aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      boa/src/builtins/string/tests.rs
  2. 8
      boa/src/object/internal_methods.rs

2
boa/src/builtins/string/tests.rs

@ -1132,7 +1132,7 @@ fn string_get_property() {
assert_eq!(forward(&mut context, "'abc'[2]"), "\"c\"");
assert_eq!(forward(&mut context, "'abc'[3]"), "undefined");
assert_eq!(forward(&mut context, "'abc'['foo']"), "undefined");
assert_eq!(forward(&mut context, "'😀'[0]"), "\"\\ud83d\"");
assert_eq!(forward(&mut context, "'😀'[0]"), "\"<EFBFBD>\"");
}
#[test]

8
boa/src/object/internal_methods.rs

@ -620,10 +620,10 @@ impl GcObject {
return None;
}
let result_str = string.encode_utf16().nth(pos).map(|utf16_val| {
char::from_u32(u32::from(utf16_val))
.map_or_else(|| Value::from(format!("\\u{:x}", utf16_val)), Value::from)
})?;
let result_str = string
.encode_utf16()
.nth(pos)
.map(|utf16_val| Value::from(String::from_utf16_lossy(&[utf16_val])))?;
let desc = PropertyDescriptor::builder()
.value(result_str)

Loading…
Cancel
Save