|
1 | 1 | // Flags: --experimental-ffi |
2 | 2 | 'use strict'; |
3 | 3 | const common = require('../common'); |
| 4 | +const { spawnSyncAndAssert } = require('../common/child_process'); |
4 | 5 | const assert = require('node:assert'); |
5 | 6 | const { spawnSync } = require('node:child_process'); |
6 | 7 | const { test } = require('node:test'); |
@@ -32,17 +33,16 @@ test('ffi builtin is unavailable when disabled', () => { |
32 | 33 | }); |
33 | 34 |
|
34 | 35 | test('ffi builtin is listed', () => { |
35 | | - const { stdout, stderr, status, signal } = spawnSync(process.execPath, [ |
36 | | - '-p', |
37 | | - 'require("node:module").builtinModules.includes("node:ffi")', |
38 | | - ], { |
39 | | - encoding: 'utf8', |
40 | | - }); |
41 | | - |
42 | | - assert.strictEqual(stdout.trim(), 'true'); |
43 | | - assert.strictEqual(stderr, ''); |
44 | | - assert.strictEqual(status, 0); |
45 | | - assert.strictEqual(signal, null); |
| 36 | + for (const [flag, stdout] of Object.entries({ |
| 37 | + '--experimental-ffi': 'true\n', |
| 38 | + '--no-experimental-ffi': 'false\n', |
| 39 | + })) { |
| 40 | + spawnSyncAndAssert(process.execPath, [ |
| 41 | + flag, |
| 42 | + '-p', |
| 43 | + 'require("node:module").builtinModules.includes("node:ffi")', |
| 44 | + ], { stdout }); |
| 45 | + } |
46 | 46 | }); |
47 | 47 |
|
48 | 48 | test('ffi can be imported from ESM', () => { |
|
0 commit comments