Skip to content
Permalink
Browse files

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: #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>
  • Loading branch information...
Trott authored and addaleax committed Jan 2, 2019
1 parent 2014eba commit 379260e4bd89f2f523e4ca1bed8b36feb210005f
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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');

0 comments on commit 379260e

Please sign in to comment.
You can’t perform that action at this time.