11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Checks for crash regression: https://github.com/nodejs/node/issues/37430
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst {
81cb0ef41Sopenharmony_ci  open,
91cb0ef41Sopenharmony_ci  openSync,
101cb0ef41Sopenharmony_ci  promises: {
111cb0ef41Sopenharmony_ci    open: openPromise,
121cb0ef41Sopenharmony_ci  },
131cb0ef41Sopenharmony_ci} = require('fs');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// These should throw, not crash.
161cb0ef41Sopenharmony_ciconst invalid = 4_294_967_296;
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciassert.throws(() => open(__filename, invalid, common.mustNotCall()), {
191cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
201cb0ef41Sopenharmony_ci});
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciassert.throws(() => open(__filename, 0, invalid, common.mustNotCall()), {
231cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
241cb0ef41Sopenharmony_ci});
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciassert.throws(() => openSync(__filename, invalid), {
271cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
281cb0ef41Sopenharmony_ci});
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciassert.throws(() => openSync(__filename, 0, invalid), {
311cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
321cb0ef41Sopenharmony_ci});
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciassert.rejects(openPromise(__filename, invalid), {
351cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
361cb0ef41Sopenharmony_ci});
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ciassert.rejects(openPromise(__filename, 0, invalid), {
391cb0ef41Sopenharmony_ci  code: 'ERR_OUT_OF_RANGE'
401cb0ef41Sopenharmony_ci});
41