forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: fix compileFunction throws range error for negative numbers
PR-URL: nodejs#49855 Fixes: nodejs#49848 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
1 parent
86d8b58
commit c8ed93a
Showing
2 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const { compileFunction } = require('node:vm'); | ||
|
||
const min = -2147483648; | ||
const max = 2147483647; | ||
|
||
compileFunction('', [], { lineOffset: min, columnOffset: min }); | ||
compileFunction('', [], { lineOffset: max, columnOffset: max }); | ||
|
||
assert.throws( | ||
() => { | ||
compileFunction('', [], { lineOffset: min - 1, columnOffset: max }); | ||
}, | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
name: 'RangeError', | ||
message: /The value of "options\.lineOffset" is out of range/, | ||
} | ||
); | ||
|
||
assert.throws( | ||
() => { | ||
compileFunction('', [], { lineOffset: min, columnOffset: min - 1 }); | ||
}, | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
name: 'RangeError', | ||
message: /The value of "options\.columnOffset" is out of range/, | ||
} | ||
); |