test: replace internals with public API

Remove instances where `--expose-internals` is used to gain access to
buffer.kStringMaxLength. The property is availalble without a flag. It
is undocumented but the same as the documented
`buffer.constants.MAX_STRING_LENGTH` so use that. (We even have a test
that confirms that they are the same value.)

PR-URL: https://github.com/nodejs/node/pull/25309
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2019-01-01 20:51:06 -08:00
parent 1f1a373df0
commit 7d453ff212
9 changed files with 10 additions and 27 deletions

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -12,7 +10,7 @@ const assert = require('assert');
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,7 @@
// Flags: --expose-gc --expose-internals
// Flags: --expose-gc
'use strict';
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -12,7 +11,7 @@ const assert = require('assert');
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -12,7 +10,7 @@ const assert = require('assert');
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -12,7 +10,7 @@ const assert = require('assert');
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);
// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
let buf;
try {

View File

@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals
const common = require('../common');
const { internalBinding } = require('internal/test/binding');
if (!common.enoughTestMem)
common.skip('intensive toString tests due to memory confinements');
@ -11,7 +9,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const cp = require('child_process');
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
if (common.isAIX && (Number(cp.execSync('ulimit -f')) * 512) < kStringMaxLength)
common.skip('intensive toString tests due to file size confinements');