summaryrefslogtreecommitdiff
path: root/test/parallel/test-file-validate-mode-flag.js
blob: bb9871ae318d5f316f40a9f52d89e48378c908ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';

// Checks for crash regression: https://github.com/nodejs/node/issues/37430

const common = require('../common');
const assert = require('assert');
const {
  open,
  openSync,
  promises: {
    open: openPromise,
  },
} = require('fs');

// These should throw, not crash.
const invalid = 4_294_967_296;

assert.throws(() => open(__filename, invalid, common.mustNotCall()), {
  code: 'ERR_OUT_OF_RANGE'
});

assert.throws(() => open(__filename, 0, invalid, common.mustNotCall()), {
  code: 'ERR_OUT_OF_RANGE'
});

assert.throws(() => openSync(__filename, invalid), {
  code: 'ERR_OUT_OF_RANGE'
});

assert.throws(() => openSync(__filename, 0, invalid), {
  code: 'ERR_OUT_OF_RANGE'
});

assert.rejects(openPromise(__filename, invalid), {
  code: 'ERR_OUT_OF_RANGE'
});

assert.rejects(openPromise(__filename, 0, invalid), {
  code: 'ERR_OUT_OF_RANGE'
});