|
@ -1,6 +1,10 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
const common = require('../../common'); |
|
|
const common = require('../../common'); |
|
|
|
|
|
const skipMessage = 'intensive toString tests due to memory confinements'; |
|
|
|
|
|
if (!common.enoughTestMem) |
|
|
|
|
|
common.skip(skipMessage); |
|
|
|
|
|
|
|
|
const binding = require(`./build/${common.buildType}/binding`); |
|
|
const binding = require(`./build/${common.buildType}/binding`); |
|
|
const assert = require('assert'); |
|
|
const assert = require('assert'); |
|
|
|
|
|
|
|
@ -8,12 +12,6 @@ const assert = require('assert'); |
|
|
// v8::String::kMaxLength defined in v8.h
|
|
|
// v8::String::kMaxLength defined in v8.h
|
|
|
const kStringMaxLength = process.binding('buffer').kStringMaxLength; |
|
|
const kStringMaxLength = process.binding('buffer').kStringMaxLength; |
|
|
|
|
|
|
|
|
const skipMessage = 'intensive toString tests due to memory confinements'; |
|
|
|
|
|
if (!common.enoughTestMem) { |
|
|
|
|
|
common.skip(skipMessage); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let buf; |
|
|
let buf; |
|
|
try { |
|
|
try { |
|
|
buf = Buffer.allocUnsafe(kStringMaxLength); |
|
|
buf = Buffer.allocUnsafe(kStringMaxLength); |
|
@ -21,14 +19,11 @@ try { |
|
|
// If the exception is not due to memory confinement then rethrow it.
|
|
|
// If the exception is not due to memory confinement then rethrow it.
|
|
|
if (e.message !== 'Array buffer allocation failed') throw (e); |
|
|
if (e.message !== 'Array buffer allocation failed') throw (e); |
|
|
common.skip(skipMessage); |
|
|
common.skip(skipMessage); |
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Ensure we have enough memory available for future allocations to succeed.
|
|
|
// Ensure we have enough memory available for future allocations to succeed.
|
|
|
if (!binding.ensureAllocation(2 * kStringMaxLength)) { |
|
|
if (!binding.ensureAllocation(2 * kStringMaxLength)) |
|
|
common.skip(skipMessage); |
|
|
common.skip(skipMessage); |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const maxString = buf.toString('latin1'); |
|
|
const maxString = buf.toString('latin1'); |
|
|
assert.strictEqual(maxString.length, kStringMaxLength); |
|
|
assert.strictEqual(maxString.length, kStringMaxLength); |
|
|