20 lines
648 B
JavaScript
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)
|
|
})
|