) => void;
14 | reject: (reason?: any) => void;
15 | };
16 | }
17 |
18 | interface ArrayBuffer {
19 | transfer(size: number): ArrayBuffer;
20 | }
21 |
22 | interface SharedArrayBuffer {
23 | transfer(size: number): SharedArrayBuffer;
24 | }
25 |
26 | namespace Deno {
27 | export function refTimer(id: number): void;
28 | export function unrefTimer(id: number): void;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/testing/checkin/mod.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2018-2025 the Deno authors. MIT license.
2 |
3 | pub(super) mod runner;
4 |
--------------------------------------------------------------------------------
/testing/checkin/runner/extensions.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2018-2025 the Deno authors. MIT license.
2 |
3 | use crate::checkin::runner::Output;
4 | use crate::checkin::runner::TestData;
5 | use crate::checkin::runner::ops;
6 | use crate::checkin::runner::ops_async;
7 | use crate::checkin::runner::ops_buffer;
8 | use crate::checkin::runner::ops_error;
9 | use crate::checkin::runner::ops_io;
10 | use crate::checkin::runner::ops_worker;
11 |
12 | pub trait SomeType {}
13 |
14 | impl SomeType for () {}
15 |
16 | deno_core::extension!(
17 | checkin_runtime,
18 | parameters = [P: SomeType],
19 | ops = [
20 | ops::op_log_debug,
21 | ops::op_log_info,
22 | ops::op_stats_capture,
23 | ops::op_stats_diff,
24 | ops::op_stats_dump,
25 | ops::op_stats_delete,
26 | ops::op_nop_generic,
27 | ops_io::op_pipe_create,
28 | ops_io::op_file_open,
29 | ops_io::op_path_to_url,
30 | ops_async::op_task_submit,
31 | ops_async::op_async_yield,
32 | ops_async::op_async_barrier_create,
33 | ops_async::op_async_barrier_await,
34 | ops_async::op_async_spin_on_state,
35 | ops_async::op_async_make_cppgc_resource,
36 | ops_async::op_async_get_cppgc_resource,
37 | ops_async::op_async_never_resolves,
38 | ops_async::op_async_fake,
39 | ops_async::op_async_promise_id,
40 | ops_error::op_async_throw_error_eager,
41 | ops_error::op_async_throw_error_lazy,
42 | ops_error::op_async_throw_error_deferred,
43 | ops_error::op_error_custom_sync,
44 | ops_error::op_error_custom_with_code_sync,
45 | ops_buffer::op_v8slice_store,
46 | ops_buffer::op_v8slice_clone,
47 | ops_worker::op_worker_spawn,
48 | ops_worker::op_worker_send,
49 | ops_worker::op_worker_recv,
50 | ops_worker::op_worker_parent,
51 | ops_worker::op_worker_await_close,
52 | ops_worker::op_worker_terminate,
53 | ],
54 | objects = [
55 | ops::DOMPointReadOnly,
56 | ops::DOMPoint,
57 | ops::TestObjectWrap,
58 | ops::TestEnumWrap
59 | ],
60 | esm_entry_point = "ext:checkin_runtime/__init.js",
61 | esm = [
62 | dir "checkin/runtime",
63 | "__init.js",
64 | "checkin:async" = "async.ts",
65 | "checkin:console" = "console.ts",
66 | "checkin:object" = "object.ts",
67 | "checkin:error" = "error.ts",
68 | "checkin:timers" = "timers.ts",
69 | "checkin:worker" = "worker.ts",
70 | "checkin:throw" = "throw.ts",
71 | ],
72 | state = |state| {
73 | state.put(TestData::default());
74 | state.put(Output::default());
75 | }
76 | );
77 |
--------------------------------------------------------------------------------
/testing/checkin/runner/ops_async.rs:
--------------------------------------------------------------------------------
1 | // Copyright 2018-2025 the Deno authors. MIT license.
2 |
3 | use super::Output;
4 | use super::TestData;
5 | use deno_core::GarbageCollected;
6 | use deno_core::OpState;
7 | use deno_core::V8TaskSpawner;
8 | use deno_core::op2;
9 | use deno_core::v8;
10 | use deno_error::JsErrorBox;
11 | use std::cell::RefCell;
12 | use std::future::Future;
13 | use std::future::poll_fn;
14 | use std::rc::Rc;
15 |
16 | #[op2]
17 | pub fn op_task_submit(
18 | state: &mut OpState,
19 | #[global] f: v8::Global,
20 | ) {
21 | state.borrow_mut::().spawn(move |scope| {
22 | let f = v8::Local::new(scope, f);
23 | let recv = v8::undefined(scope);
24 | f.call(scope, recv.into(), &[]);
25 | });
26 | }
27 |
28 | #[op2(async)]
29 | pub async fn op_async_yield() {
30 | tokio::task::yield_now().await
31 | }
32 |
33 | #[op2(fast)]
34 | pub fn op_async_barrier_create(
35 | #[state] test_data: &mut TestData,
36 | #[string] name: String,
37 | count: u32,
38 | ) {
39 | let barrier = Rc::new(tokio::sync::Barrier::new(count as _));
40 | test_data.insert(name, barrier);
41 | }
42 |
43 | #[op2(async)]
44 | pub fn op_async_barrier_await(
45 | #[state] test_data: &TestData,
46 | #[string] name: String,
47 | ) -> impl Future