Files
bare-operating-system/packages/bare-os-coreutils/test/posix-test-bracket-argv.test.mjs
T
2026-04-26 16:24:57 -04:00

20 lines
648 B
JavaScript

/**
* /bin/test when argv0 is `[` must drop the closing `]` (POSIX).
*/
import test from 'brittle'
import { evalTest, run } from '../src/test.js'
test('evalTest three-arg int via bracket-normalized argv', async (t) => {
const ctx = { vfs: { env: {} }, exitCode: 0 }
t.ok(await evalTest(ctx, ['1', '-eq', '1']))
t.absent(await evalTest(ctx, ['1', '-eq', '1', ']']))
})
test('run accepts [ … ] argv shape', async (t) => {
const ctx = { vfs: { env: {} }, exitCode: 0, console: { error() {} } }
await run(ctx, ['[', '1', '-eq', '1', ']'])
t.is(ctx.exitCode, 0)
await run(ctx, ['[', '1', '-eq', '2', ']'])
t.is(ctx.exitCode, 1)
})