summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/runtime.rs20
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());
+ }
}