Skip to content

Commit

Permalink
core: enable --harmony-change-array-by-copy V8 flag (denoland#16429)
Browse files Browse the repository at this point in the history
Enables [Change Array by copy
proposal](https://github.com/tc39/proposal-change-array-by-copy) via a
V8 flag.
  • Loading branch information
bartlomieju authored Oct 26, 2022
1 parent 678ac57 commit a57faa8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
}

0 comments on commit a57faa8

Please sign in to comment.