Repository navigation
Conversation
| if (operator === '-gt') return leftInteger > rightInteger; | ||
| if (operator === '-ge') return leftInteger >= rightInteger; | ||
| if (operator === '-lt') return leftInteger < rightInteger; | ||
| return leftInteger <= rightInteger; |
There was a problem hiding this comment.
Please add the if (operator === '-le' ... part before this. Then for the default case, you should use:
var e = new Exception('Unknown operator: ' + operator);
e.name = 'ShellJSInternalError';
throw e;
There was a problem hiding this comment.
Added the explicit -le branch and defensive ShellJSInternalError in 49af902, using the standard JavaScript Error constructor.
| }); | ||
|
|
||
| test('integer comparison rejects unsafe integers', t => { | ||
| shell.test('9007199254740992', '-gt', '1'); |
There was a problem hiding this comment.
Please leave a comment why this integer is considered unsafe.
There was a problem hiding this comment.
Documented why 2 ** 53 exceeds Number.MAX_SAFE_INTEGER in 49af902.
| ['4', '-le', '3'], | ||
| ]; | ||
|
|
||
| expressions.forEach(expression => { |
There was a problem hiding this comment.
Instead of a for-loop, could we just write out each comparison directly inside this test? Like so:
t.false('2 -eq 3', shell.test('2', '-eq', '3'));
t.falsy(shell.error());
t.false('2 -ne 2', shell.test('2', '-ne', '2'));
t.falsy(shell.error());
// So on and so forth...There was a problem hiding this comment.
Expanded every true and false integer comparison into individual assertions in 49af902. The 30 focused tests pass.
1648d74 to
49af902
Compare
Summary
testFixes #1230
Verification
npx ava test/test.js(30 passed on Node 22, 24, and 26)npx ava --match='!*setuid*' --match='!*setgid*'(634 passed, 6 skipped)npm run lintnpm run check-node-supportnpm run gendocsThe unfiltered suite has two macOS permission-bit failures for setuid/setgid; both reproduce on the unchanged base commit.