ronantakizawa/codereview-bench huggingface dataset:
Repository: denoland/deno
File: tests/integration/lsp_tests.rs (Rust)

Code before:
  let temp = context.temp_dir();
  let temp_dir = temp.path();
  let source = source_file(
    temp_dir.join("index.ts"),
    r#"
      const foo = [1];
      foo.augmented();
    "#,
  );

  let deno_json = json!({
    "imports": {
      "@denotest/augments-global": "npm:@denotest/augments-global@1"
    },
    "compilerOptions": { "types": ["@denotest/augments-global"] },
  });

  temp.write("deno.json", deno_json.to_string());

  client.initialize_default();

  for node_modules_dir in ["none", "auto", "manual"] {
    let mut deno_json = deno_json.clone();
    deno_json["nodeModulesDir"] = json!(node_modules_dir);
    temp.write("deno.json", deno_json.to_string());
    deno_install(&context);
    client.did_change_watched_files(json!({
      "changes": [{
        "uri": temp.url().join("deno.json").unwrap(),
        "type": 2,
      }],
    }));

    let diagnostics = client.did_open_file(&source);
    eprintln!("{:#?}", diagnostics.all());
    assert_eq!(diagnostics.all().len(), 0);
    client.did_close_file(&source);
  }
}

#[test]
fn type_reference_import_meta() {
  let context = TestContextBuilder::for_npm().use_temp_cwd().build();
  let mut client = context.new_lsp_command().build();
  let temp = context.temp_dir();
  let temp_dir = temp.path();
  let source = source_file(
    temp_dir.join("index.ts"),
    r#"
      const test = import.meta.env.TEST;
      const bar = import.meta.bar;

Review comment (suggestion):
```suggestion
    context.run_deno("install");
```

Code after:

  let deno_json = json!({
    "imports": {
      "@denotest/augments-global": "npm:@denotest/augments-global@1"
    },
    "compilerOptions": { "types": ["@denotest/augments-global"] },
  });

  temp.write("deno.json", deno_json.to_string());

  client.initialize_default();

  for node_modules_dir in ["none", "auto", "manual"] {
    let mut deno_json = deno_json.clone();
    deno_json["nodeModulesDir"] = json!(node_modules_dir);
    temp.write("deno.json", deno_json.to_string());
    context.run_deno("install");
    client.did_change_watched_files(json!({
      "changes": [{
        "uri": temp.url().join("deno.json").unwrap(),
        "type": 2,
      }],
    }));

    let diagnostics = client.did_open_file(&source);
    eprintln!("{:#?}", diagnostics.all());
    assert_eq!(diagnostics.all().len(), 0);
    client.did_close_file(&source);
  }
}

#[test]
fn type_reference_import_meta() {
  let context = TestContextBuilder::for_npm().use_temp_cwd().build();
  let mut client = context.new_lsp_command().build();
  let temp = context.temp_dir();
  let temp_dir = temp.path();
  let source = source_file(
    temp_dir.join("index.ts"),
    r#"
      const test = import.meta.env.TEST;
      const bar = import.meta.bar;
      console.log(test, bar);
    "#,
  );
  /*
    tests type reference w/ bare specifier, type reference in an npm package,
    and augmentation of `ImportMeta` (this combination modeled after the vanilla vite template,
    which uses `vite/client`)

    @denotest/augments-global/import-meta:
Repository: denoland/deno
File: ext/net/ops.rs (Rust)

Code before:
  Tls(#[from] deno_tls::TlsError),
  #[class("InvalidData")]
  #[error("Error creating TLS certificate: Deno.listenTls requires a key")]
  ListenTlsRequiresKey,
  #[class(inherit)]
  #[error("{0}")]
  RootCertStore(deno_error::JsErrorBox),
  #[class(generic)]
  #[error("{0}")]
  Reunite(tokio::net::tcp::ReuniteError),
}

pub(crate) fn accept_err(e: std::io::Error) -> NetError {
  if let std::io::ErrorKind::Interrupted = e.kind() {
    NetError::ListenerClosed
  } else {
    NetError::Io(e)
  }
}

#[op2(async)]
#[serde]
pub async fn op_net_accept_tcp(
  state: Rc<RefCell<OpState>>,
  #[smi] rid: ResourceId,
) -> Result<(ResourceId, IpAddr, IpAddr, Fd), NetError> {
  let resource = state
    .borrow()
    .resource_table
    .get::<NetworkListenerResource<TcpListener>>(rid)
    .map_err(|_| NetError::ListenerClosed)?;
  let listener = RcRef::map(&resource, |r| &r.listener)
    .try_borrow_mut()
    .ok_or_else(|| NetError::AcceptTaskOngoing)?;
  let cancel = RcRef::map(resource, |r| &r.cancel);
  let (tcp_stream, _socket_addr) = listener
    .accept()
    .try_or_cancel(cancel)
    .await
    .map_err(accept_err)?;
  let fd = tcp_stream.as_fd();
  let fd_raw = fd.as_raw_fd() as u32;
  let local_addr = tcp_stream.local_addr()?;
  let remote_addr = tcp_stream.peer_addr()?;

  let mut state = state.borrow_mut();
  let rid = state
    .resource_table
    .add(TcpStreamResource::new(tcp_stream.into_split()));
  Ok((
    rid,

Review comment (suggestion):
If Fd is not available on windows, maybe it's better to do:

```suggestion
) -> Result<(ResourceId, IpAddr, IpAddr, Option<Fd>), NetError> {
```

Code after:
  #[error("Error creating TLS certificate: Deno.listenTls requires a key")]
  ListenTlsRequiresKey,
  #[class(inherit)]
  #[error("{0}")]
  RootCertStore(deno_error::JsErrorBox),
  #[class(generic)]
  #[error("{0}")]
  Reunite(tokio::net::tcp::ReuniteError),
}

pub(crate) fn accept_err(e: std::io::Error) -> NetError {
  if let std::io::ErrorKind::Interrupted = e.kind() {
    NetError::ListenerClosed
  } else {
    NetError::Io(e)
  }
}

#[op2(async)]
#[serde]
pub async fn op_net_accept_tcp(
  state: Rc<RefCell<OpState>>,
  #[smi] rid: ResourceId,
) -> Result<(ResourceId, IpAddr, IpAddr, Option<Fd>), NetError> {
  let resource = state
    .borrow()
    .resource_table
    .get::<NetworkListenerResource<TcpListener>>(rid)
    .map_err(|_| NetError::ListenerClosed)?;
  let listener = RcRef::map(&resource, |r| &r.listener)
    .try_borrow_mut()
    .ok_or_else(|| NetError::AcceptTaskOngoing)?;
  let cancel = RcRef::map(resource, |r| &r.cancel);
  let (tcp_stream, _socket_addr) = listener
    .accept()
    .try_or_cancel(cancel)
    .await
    .map_err(accept_err)?;
  let mut _fd_raw: Option<Fd> = None;
  #[cfg(not(windows))]
  {
    use std::os::fd::AsFd;
    use std::os::fd::AsRawFd;
    let fd = tcp_stream.as_fd();
    _fd_raw = Some(fd.as_raw_fd() as u32);
  }
  let local_addr = tcp_stream.local_addr()?;
  let remote_addr = tcp_stream.peer_addr()?;

  let mut state = state.borrow_mut();
  let rid = state
Repository: denoland/deno
File: resolvers/node/package_json.rs (Rust)

Code before:
use crate::errors::PackageJsonLoadError;

pub trait NodePackageJsonCache:
  deno_package_json::PackageJsonCache
  + crate::sync::MaybeSend
  + crate::sync::MaybeSync
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache;
}

impl<T> NodePackageJsonCache for T
where
  T: deno_package_json::PackageJsonCache
    + crate::sync::MaybeSend
    + crate::sync::MaybeSync,
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache {
    self
  }
}

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<dyn NodePackageJsonCache>;

thread_local! {
  static CACHE: RefCell<HashMap<PathBuf, PackageJsonRc>> = RefCell::new(HashMap::new());
}

#[derive(Debug)]
pub struct PackageJsonThreadLocalCache;

impl PackageJsonThreadLocalCache {
  pub fn clear() {
    CACHE.with(|cache| cache.borrow_mut().clear());
  }
}

impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache {
  fn get(&self, path: &Path) -> Option<PackageJsonRc> {
    CACHE.with(|cache| cache.borrow().get(path).cloned())
  }

  fn set(&self, path: PathBuf, package_json: PackageJsonRc) {
    CACHE.with(|cache| cache.borrow_mut().insert(path, package_json));
  }
}


Review comment (bug):
I shouldn't have added Debug to PackageJsonCache in deno_package_json and instead just done this with Debug.

Code after:
use crate::errors::PackageJsonLoadError;

pub trait NodePackageJsonCache:
  deno_package_json::PackageJsonCache
  + std::fmt::Debug
  + crate::sync::MaybeSend
  + crate::sync::MaybeSync
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache;
}

impl<T> NodePackageJsonCache for T
where
  T: deno_package_json::PackageJsonCache
    + std::fmt::Debug
    + crate::sync::MaybeSend
    + crate::sync::MaybeSync,
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache {
    self
  }
}

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<dyn NodePackageJsonCache>;

thread_local! {
  static CACHE: RefCell<HashMap<PathBuf, PackageJsonRc>> = RefCell::new(HashMap::new());
}

#[derive(Debug)]
pub struct PackageJsonThreadLocalCache;

impl PackageJsonThreadLocalCache {
  pub fn clear() {
    CACHE.with(|cache| cache.borrow_mut().clear());
  }
}

impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache {
  fn get(&self, path: &Path) -> Option<PackageJsonRc> {
    CACHE.with(|cache| cache.borrow().get(path).cloned())
  }

  fn set(&self, path: PathBuf, package_json: PackageJsonRc) {
    CACHE.with(|cache| cache.borrow_mut().insert(path, package_json));
  }
Repository: denoland/deno
File: resolvers/node/package_json.rs (Rust)

Code before:

use deno_package_json::PackageJson;
use deno_package_json::PackageJsonRc;
use sys_traits::FsRead;
use url::Url;

use crate::errors::ClosestPkgJsonError;
use crate::errors::PackageJsonLoadError;

pub trait NodePackageJsonCache:
  deno_package_json::PackageJsonCache
  + crate::sync::MaybeSend
  + crate::sync::MaybeSync
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache;
}

impl<T> NodePackageJsonCache for T
where
  T: deno_package_json::PackageJsonCache
    + crate::sync::MaybeSend
    + crate::sync::MaybeSync,
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache {
    self
  }
}

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<dyn NodePackageJsonCache>;

thread_local! {
  static CACHE: RefCell<HashMap<PathBuf, PackageJsonRc>> = RefCell::new(HashMap::new());
}

#[derive(Debug)]
pub struct PackageJsonThreadLocalCache;

impl PackageJsonThreadLocalCache {
  pub fn clear() {
    CACHE.with(|cache| cache.borrow_mut().clear());
  }
}

impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache {
  fn get(&self, path: &Path) -> Option<PackageJsonRc> {
    CACHE.with(|cache| cache.borrow().get(path).cloned())

Review comment (performance):
Error was:
```
  --> V:\deno\resolvers\node\package_json.rs:20:7
   |
19 |   dyn deno_package_json::PackageJsonCache
   |       ----------------------------------- first non-auto trait
20 |     + crate::sync::MaybeSend
   |       ^^^^^^^^^^^^^^^^^^^^^^ additional non-auto trait
```

Code after:

use deno_package_json::PackageJson;
use deno_package_json::PackageJsonRc;
use sys_traits::FsRead;
use url::Url;

use crate::errors::ClosestPkgJsonError;
use crate::errors::PackageJsonLoadError;

pub trait NodePackageJsonCache:
  deno_package_json::PackageJsonCache
  + std::fmt::Debug
  + crate::sync::MaybeSend
  + crate::sync::MaybeSync
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache;
}

impl<T> NodePackageJsonCache for T
where
  T: deno_package_json::PackageJsonCache
    + std::fmt::Debug
    + crate::sync::MaybeSend
    + crate::sync::MaybeSync,
{
  fn as_deno_package_json_cache(
    &self,
  ) -> &dyn deno_package_json::PackageJsonCache {
    self
  }
}

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<dyn NodePackageJsonCache>;

thread_local! {
  static CACHE: RefCell<HashMap<PathBuf, PackageJsonRc>> = RefCell::new(HashMap::new());
}

#[derive(Debug)]
pub struct PackageJsonThreadLocalCache;

impl PackageJsonThreadLocalCache {
  pub fn clear() {
    CACHE.with(|cache| cache.borrow_mut().clear());
  }
}

impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache {
Repository: denoland/deno
File: cli/lsp/tsc.rs (Rust)

Code before:
  state: &mut OpState,
  args: ResolveArgs,
) -> Result<Vec<Option<(String, Option<String>)>>, deno_core::url::ParseError> {
  let state = state.borrow_mut::<State>();
  let mark = state.performance.mark_with_args("tsc.op.op_resolve", &args);
  let referrer = state.specifier_map.normalize(&args.base)?;
  NodeResolutionThreadLocalCache::clear();
  let specifiers = state
    .state_snapshot
    .documents
    .resolve(&args.specifiers, &referrer, state.last_scope.as_ref())
    .into_iter()
    .map(|o| {
      o.map(|(s, mt)| {
        (
          state.specifier_map.denormalize(&s),
          if matches!(mt, MediaType::Unknown) {
            None
          } else {
            Some(mt.as_ts_extension().to_string())
          },
        )
      })
    })
    .collect();
  NodeResolutionThreadLocalCache::clear();
  state.performance.measure(mark);
  Ok(specifiers)
}

#[op2(fast)]
fn op_respond(
  state: &mut OpState,
  #[string] response: String,
  #[string] error: String,
) {
  let state = state.borrow_mut::<State>();
  state.performance.measure(state.mark.take().unwrap());
  state.last_scope = None;
  let response = if !error.is_empty() {
    Err(anyhow!("tsc error: {error}"))
  } else {
    Ok(response)
  };

  let was_sent = state.response_tx.take().unwrap().send(response).is_ok();
  // Don't print the send error if the token is cancelled, it's expected
  // to fail in that case and this commonly occurs.
  if !was_sent && !state.token.is_cancelled() {
    lsp_warn!("Unable to send result to client.");
  }

Review comment (suggestion):
We should improve this to be smarter. Right now I just have it clearing before and after each op_resolve.

Code after:
  state.last_id += 1;
  state.last_scope.clone_from(&scope);
  let mark = state
    .performance
    .mark_with_args(format!("tsc.host.{}", request.method()), &request);
  state.mark = Some(mark);

  Some(TscRequestArray {
    request,
    scope: scope.map(|s| s.into()),
    id: Smi(id),
    change: change.into(),
  })
  .into()
}

#[inline]
#[allow(clippy::type_complexity)]
fn op_resolve_inner(
  state: &mut OpState,
  args: ResolveArgs,
) -> Result<Vec<Option<(String, Option<String>)>>, deno_core::url::ParseError> {
  let state = state.borrow_mut::<State>();
  let mark = state.performance.mark_with_args("tsc.op.op_resolve", &args);
  let referrer = state.specifier_map.normalize(&args.base)?;
  let specifiers = state
    .state_snapshot
    .documents
    .resolve(&args.specifiers, &referrer, state.last_scope.as_ref())
    .into_iter()
    .map(|o| {
      o.map(|(s, mt)| {
        (
          state.specifier_map.denormalize(&s),
          if matches!(mt, MediaType::Unknown) {
            None
          } else {
            Some(mt.as_ts_extension().to_string())
          },
        )
      })
    })
    .collect();
  state.performance.measure(mark);
  Ok(specifiers)
}

#[op2(fast)]
fn op_respond(
  state: &mut OpState,
  #[string] response: String,
Repository: denoland/deno
File: ext/node/polyfills/path/common.ts (TypeScript)

Code before:

import { primordials } from "ext:core/mod.js";
const {
  StringPrototypeSubstring,
  StringPrototypeLastIndexOf,
  StringPrototypeSplit,
  ArrayPrototypeSlice,
  StringPrototypeEndsWith,
  ArrayPrototypeJoin,
  ArrayFrom,
} = primordials;
import { SEP } from "ext:deno_node/path/separator.ts";

/** Determines the common path from a set of paths, using an optional separator,
 * which defaults to the OS default separator.
 *
 * ```ts
 *       const p = common([
 *         "./deno/std/path/mod.ts",
 *         "./deno/std/fs/mod.ts",
 *       ]);
 *       console.log(p); // "./deno/std/"
 * ```
 */
export function common(paths: string[], sep = SEP): string {
  const [first = "", ...remaining] = ArrayFrom(paths);
  if (first === "" || remaining.length === 0) {
    return StringPrototypeSubstring(
      first,
      0,
      StringPrototypeLastIndexOf(first, sep) + 1,
    );
  }
  const parts = StringPrototypeSplit(first, sep);

  let endOfPrefix = parts.length;
  for (const path of remaining) {
    const compare = StringPrototypeSplit(path, sep);
    for (let i = 0; i < endOfPrefix; i++) {
      if (compare[i] !== parts[i]) {
        endOfPrefix = i;
      }
    }

    if (endOfPrefix === 0) {
      return "";
    }
  }
  const prefix = ArrayPrototypeJoin(
    ArrayPrototypeSlice(parts, 0, endOfPrefix),
    sep,

Review comment (suggestion):
Please use `SafeArrayIterator` from primordials.

```suggestion
  const [first = "", ...remaining] = new SafeArrayIterator(paths);
```


Code after:

import { primordials } from "ext:core/mod.js";
const {
  StringPrototypeSubstring,
  StringPrototypeLastIndexOf,
  StringPrototypeSplit,
  ArrayPrototypeSlice,
  StringPrototypeEndsWith,
  ArrayPrototypeJoin,
  SafeArrayIterator,
} = primordials;
import { SEP } from "ext:deno_node/path/separator.ts";

/** Determines the common path from a set of paths, using an optional separator,
 * which defaults to the OS default separator.
 *
 * ```ts
 *       const p = common([
 *         "./deno/std/path/mod.ts",
 *         "./deno/std/fs/mod.ts",
 *       ]);
 *       console.log(p); // "./deno/std/"
 * ```
 */
export function common(paths: string[], sep = SEP): string {
  const [first = "", ...remaining] = new SafeArrayIterator(paths);
  if (first === "" || remaining.length === 0) {
    return StringPrototypeSubstring(
      first,
      0,
      StringPrototypeLastIndexOf(first, sep) + 1,
    );
  }
  const parts = StringPrototypeSplit(first, sep);

  let endOfPrefix = parts.length;
  for (const path of new SafeArrayIterator(remaining)) {
    const compare = StringPrototypeSplit(path, sep);
    for (let i = 0; i < endOfPrefix; i++) {
      if (compare[i] !== parts[i]) {
        endOfPrefix = i;
      }
    }

    if (endOfPrefix === 0) {
      return "";
    }
  }
  const prefix = ArrayPrototypeJoin(
    ArrayPrototypeSlice(parts, 0, endOfPrefix),
    sep,
Repository: denoland/deno
File: ext/node/polyfills/path/common.ts (TypeScript)

Code before:
 *         "./deno/std/path/mod.ts",
 *         "./deno/std/fs/mod.ts",
 *       ]);
 *       console.log(p); // "./deno/std/"
 * ```
 */
export function common(paths: string[], sep = SEP): string {
  const [first = "", ...remaining] = paths;
  if (first === "" || remaining.length === 0) {
    return first.substring(0, first.lastIndexOf(sep) + 1);
  }
  const parts = first.split(sep);

  let endOfPrefix = parts.length;
  for (const path of remaining) {
    const compare = path.split(sep);
    for (let i = 0; i < endOfPrefix; i++) {
      if (compare[i] !== parts[i]) {
        endOfPrefix = i;
      }
    }

    if (endOfPrefix === 0) {
      return "";
    }
  }
  const prefix = parts.slice(0, endOfPrefix).join(sep);
  return prefix.endsWith(sep) ? prefix : `${prefix}${sep}`;
}


Review comment (suggestion):
```js
for (let i = 0; i < remaining.length; ++i) {
  const path = remaining[i];
```

Code after:
import { SEP } from "ext:deno_node/path/separator.ts";

/** Determines the common path from a set of paths, using an optional separator,
 * which defaults to the OS default separator.
 *
 * ```ts
 *       const p = common([
 *         "./deno/std/path/mod.ts",
 *         "./deno/std/fs/mod.ts",
 *       ]);
 *       console.log(p); // "./deno/std/"
 * ```
 */
export function common(paths: string[], sep = SEP): string {
  const [first = "", ...remaining] = new SafeArrayIterator(paths);
  if (first === "" || remaining.length === 0) {
    return StringPrototypeSubstring(
      first,
      0,
      StringPrototypeLastIndexOf(first, sep) + 1,
    );
  }
  const parts = StringPrototypeSplit(first, sep);

  let endOfPrefix = parts.length;
  for (const path of new SafeArrayIterator(remaining)) {
    const compare = StringPrototypeSplit(path, sep);
    for (let i = 0; i < endOfPrefix; i++) {
      if (compare[i] !== parts[i]) {
        endOfPrefix = i;
      }
    }

    if (endOfPrefix === 0) {
      return "";
    }
  }
  const prefix = ArrayPrototypeJoin(
    ArrayPrototypeSlice(parts, 0, endOfPrefix),
    sep,
  );
  return StringPrototypeEndsWith(prefix, sep) ? prefix : `${prefix}${sep}`;
}
Repository: denoland/deno
File: tests/unit_node/sqlite_test.ts (TypeScript)

Code before:
    { key: 2, value: "world", __proto__: null },
  ]);
});

Deno.test("[node/sqlite] exec should execute batch statements", () => {
  const db = new DatabaseSync(":memory:");
  db.exec(`CREATE TABLE one(id int PRIMARY KEY) STRICT;
CREATE TABLE two(id int PRIMARY KEY) STRICT;`);

  const table = db.prepare(
    `SELECT name FROM sqlite_master WHERE type='table'`,
  ).all();
  assertEquals(table.length, 2);

  db.close();
});

Deno.test("[node/sqlite] StatementSync#iterate", () => {
  const db = new DatabaseSync(":memory:");
  const stmt = db.prepare("SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3");

  const result = [];
  // @ts-ignore: types are not up to date
  for (const row of stmt.iterate()) {
    result.push(row);
  }

  assertEquals(result, stmt.all());
  db.close();
});


Review comment (bug):
Won't it crash/error if you try to iterate again? Can you add a test for that?

Code after:
    { key: 2, value: "world", __proto__: null },
  ]);
});

Deno.test("[node/sqlite] exec should execute batch statements", () => {
  const db = new DatabaseSync(":memory:");
  db.exec(`CREATE TABLE one(id int PRIMARY KEY) STRICT;
CREATE TABLE two(id int PRIMARY KEY) STRICT;`);

  const table = db.prepare(
    `SELECT name FROM sqlite_master WHERE type='table'`,
  ).all();
  assertEquals(table.length, 2);

  db.close();
});

Deno.test("[node/sqlite] StatementSync#iterate", () => {
  const db = new DatabaseSync(":memory:");
  const stmt = db.prepare("SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3");
  // @ts-ignore: types are not up to date
  const iter = stmt.iterate();

  const result = [];
  for (const row of iter) {
    result.push(row);
  }

  assertEquals(result, stmt.all());

  const { done, value } = iter.next();
  assertEquals(done, true);
  assertEquals(value, undefined);

  db.close();
});