diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-10-26 16:54:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 16:54:22 +0200 |
commit | a57faa8a0a1bbe895859146b1baee1b991e7ad99 (patch) | |
tree | 2a01ba7dd1aa41c11cc0c890c810be441c17afeb /core/runtime.rs | |
parent | 678ac5757b8283a2bb7bd0158f3c5273ea1e7eec (diff) |
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.
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 848c19af0..516d519a3 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -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()); + } } |