summaryrefslogtreecommitdiff
path: root/core/runtime/tests.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-06-22 23:37:56 +0200
committerGitHub <noreply@github.com>2023-06-22 23:37:56 +0200
commitdda0f1c343bfb3196ce6a7c7e8c2acccfd5c2e5b (patch)
tree10fc273a620949ccf63826363499f8f39056896d /core/runtime/tests.rs
parentb319fa7f4965af3d3d576ea528248a31c96a4053 (diff)
refactor(serde_v8): split ZeroCopyBuf into JsBuffer and ToJsBuffer (#19566)
`ZeroCopyBuf` was convenient to use, but sometimes it did hide details that some copies were necessary in certain cases. Also it made it way to easy for the caller to pass around and convert into different values. This commit splits `ZeroCopyBuf` into `JsBuffer` (an array buffer coming from V8) and `ToJsBuffer` (a Rust buffer that will be converted into a V8 array buffer). As a result some magical conversions were removed (they were never used) limiting the API surface and preparing for changes in #19534.
Diffstat (limited to 'core/runtime/tests.rs')
-rw-r--r--core/runtime/tests.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/runtime/tests.rs b/core/runtime/tests.rs
index 857290b80..d2283365e 100644
--- a/core/runtime/tests.rs
+++ b/core/runtime/tests.rs
@@ -18,7 +18,7 @@ use crate::modules::ModuleType;
use crate::modules::ResolutionKind;
use crate::modules::SymbolicModule;
use crate::Extension;
-use crate::ZeroCopyBuf;
+use crate::JsBuffer;
use crate::*;
use anyhow::Error;
use deno_ops::op;
@@ -55,7 +55,7 @@ struct TestState {
async fn op_test(
rc_op_state: Rc<RefCell<OpState>>,
control: u8,
- buf: Option<ZeroCopyBuf>,
+ buf: Option<JsBuffer>,
) -> Result<u8, AnyError> {
#![allow(clippy::await_holding_refcell_ref)] // False positive.
let op_state_ = rc_op_state.borrow();
@@ -1977,15 +1977,15 @@ fn js_realm_init_snapshot() {
#[test]
fn js_realm_sync_ops() {
- // Test that returning a ZeroCopyBuf and throwing an exception from a sync
+ // Test that returning a RustToV8Buf and throwing an exception from a sync
// op result in objects with prototypes from the right realm. Note that we
// don't test the result of returning structs, because they will be
// serialized to objects with null prototype.
#[op]
- fn op_test(fail: bool) -> Result<ZeroCopyBuf, Error> {
+ fn op_test(fail: bool) -> Result<ToJsBuffer, Error> {
if !fail {
- Ok(ZeroCopyBuf::empty())
+ Ok(ToJsBuffer::empty())
} else {
Err(crate::error::type_error("Test"))
}
@@ -2025,15 +2025,15 @@ fn js_realm_sync_ops() {
#[tokio::test]
async fn js_realm_async_ops() {
- // Test that returning a ZeroCopyBuf and throwing an exception from a async
+ // Test that returning a RustToV8Buf and throwing an exception from a async
// op result in objects with prototypes from the right realm. Note that we
// don't test the result of returning structs, because they will be
// serialized to objects with null prototype.
#[op]
- async fn op_test(fail: bool) -> Result<ZeroCopyBuf, Error> {
+ async fn op_test(fail: bool) -> Result<ToJsBuffer, Error> {
if !fail {
- Ok(ZeroCopyBuf::empty())
+ Ok(ToJsBuffer::empty())
} else {
Err(crate::error::type_error("Test"))
}