Repository: denoland/deno
Pull request: fix(ext/node): include `assert.ok` in `node:test`


Changed files:
filename: ext/node/polyfills/testing.ts
patch: @@ -32,6 +32,7 @@ const methodsToCopy = [
   "rejects",
   "strictEqual",
   "throws",
+  "ok",
 ];
 
 /** `assert` object available via t.assert */

filename: tests/node_compat/config.jsonc
patch: @@ -980,6 +980,7 @@
       "test-source-map-enable.js",
       "test-spawn-cmd-named-pipe.js",
       "test-sqlite-transactions.js",
+      "test-sqlite-typed-array-and-data-view.js",
       "test-stdin-from-file-spawn.js",
       "test-stdin-hang.js",
       "test-stdin-pipe-large.js",

filename: tests/node_compat/runner/TODO.md
patch: @@ -1,7 +1,7 @@
 <!-- deno-fmt-ignore-file -->
 # Remaining Node Tests
 
-1174 tests out of 3993 have been ported from Node 23.9.0 (29.40% ported, 71.12% remaining).
+1175 tests out of 3993 have been ported from Node 23.9.0 (29.43% ported, 71.10% remaining).
 
 NOTE: This file should not be manually edited. Please edit `tests/node_compat/config.json` and run `deno task setup` in `tests/node_compat/runner` dir instead.
 
@@ -2056,7 +2056,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
 - [parallel/test-sqlite-named-parameters.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-sqlite-named-parameters.js)
 - [parallel/test-sqlite-session.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-sqlite-session.js)
 - [parallel/test-sqlite-statement-sync.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-sqlite-statement-sync.js)
-- [parallel/test-sqlite-typed-array-and-data-view.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-sqlite-typed-array-and-data-view.js)
 - [parallel/test-sqlite.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-sqlite.js)
 - [parallel/test-stack-size-limit.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-stack-size-limit.js)
 - [parallel/test-startup-empty-regexp-statics.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-startup-empty-regexp-statics.js)

filename: tests/node_compat/test/parallel/test-sqlite-typed-array-and-data-view.js
patch: @@ -0,0 +1,68 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 23.9.0
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+require('../common');
+const tmpdir = require('../common/tmpdir');
+const { join } = require('node:path');
+const { DatabaseSync } = require('node:sqlite');
+const { suite, test } = require('node:test');
+let cnt = 0;
+
+tmpdir.refresh();
+
+function nextDb() {
+  return join(tmpdir.path, `database-${cnt++}.db`);
+}
+
+const arrayBuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]).buffer;
+const TypedArrays = [
+  ['Int8Array', Int8Array],
+  ['Uint8Array', Uint8Array],
+  ['Uint8ClampedArray', Uint8ClampedArray],
+  ['Int16Array', Int16Array],
+  ['Uint16Array', Uint16Array],
+  ['Int32Array', Int32Array],
+  ['Uint32Array', Uint32Array],
+  ['Float32Array', Float32Array],
+  ['Float64Array', Float64Array],
+  ['BigInt64Array', BigInt64Array],
+  ['BigUint64Array', BigUint64Array],
+  ['DataView', DataView],
+];
+
+suite('StatementSync with TypedArray/DataView', () => {
+  for (const [displayName, TypedArray] of TypedArrays) {
+    test(displayName, (t) => {
+      const db = new DatabaseSync(nextDb());
+      t.after(() => { db.close(); });
+      db.exec('CREATE TABLE test (data BLOB)');
+      // insert
+      {
+        const stmt = db.prepare('INSERT INTO test VALUES (?)');
+        stmt.run(new TypedArray(arrayBuffer));
+      }
+      // select all
+      {
+        const stmt = db.prepare('SELECT * FROM test');
+        const row = stmt.get();
+        t.assert.ok(row.data instanceof Uint8Array);
+        t.assert.strictEqual(row.data.length, 8);
+        t.assert.deepStrictEqual(row.data, new Uint8Array(arrayBuffer));
+      }
+      // query
+      {
+        const stmt = db.prepare('SELECT * FROM test WHERE data = ?');
+        const rows = stmt.all(new TypedArray(arrayBuffer));
+        t.assert.strictEqual(rows.length, 1);
+        t.assert.ok(rows[0].data instanceof Uint8Array);
+        t.assert.strictEqual(rows[0].data.length, 8);
+        t.assert.deepStrictEqual(rows[0].data, new Uint8Array(arrayBuffer));
+      }
+    });
+  }
+});