0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

core: enable --harmony-change-array-by-copy V8 flag (#16429)

Enables [Change Array by copy
proposal](https://github.com/tc39/proposal-change-array-by-copy) via a
V8 flag.
This commit is contained in:
Bartek Iwańczuk 2022-10-26 16:54:22 +02:00 committed by GitHub
parent 678ac5757b
commit a57faa8a0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -203,6 +203,7 @@ fn v8_init(
// This flag prevents "unresolved external reference" panic during
// build, which started happening in V8 10.6
" --noexperimental-async-stack-tagging-api",
" --harmony-change-array-by-copy",
);
if predictable {
@ -3906,4 +3907,23 @@ Deno.core.opAsync('op_async_serialize_object_with_numbers_as_keys', {
let scope = &mut realm.handle_scope(runtime.v8_isolate());
assert_eq!(ret, serde_v8::to_v8(scope, "Test").unwrap());
}
#[test]
fn test_array_by_copy() {
// Verify that "array by copy" proposal is enabled (https://github.com/tc39/proposal-change-array-by-copy)
let mut runtime = JsRuntime::new(Default::default());
assert!(runtime
.execute_script(
"test_array_by_copy.js",
"const a = [1, 2, 3];
const b = a.toReversed();
if (!(a[0] === 1 && a[1] === 2 && a[2] === 3)) {
throw new Error('Expected a to be intact');
}
if (!(b[0] === 3 && b[1] === 2 && b[2] === 1)) {
throw new Error('Expected b to be reversed');
}",
)
.is_ok());
}
}