2015-10-06 11:26:13 +08:00
|
|
|
'use strict';
|
|
|
|
// Flags: --expose-gc
|
|
|
|
|
2015-10-07 11:54:23 +08:00
|
|
|
require('../../common');
|
2015-10-06 11:26:13 +08:00
|
|
|
var binding = require('./build/Release/binding');
|
2015-10-13 04:08:13 +08:00
|
|
|
|
2016-03-17 09:56:15 +08:00
|
|
|
function check(size, alignment, offset) {
|
|
|
|
var buf = binding.alloc(size, alignment, offset);
|
2015-10-13 04:08:13 +08:00
|
|
|
var slice = buf.slice(size >>> 1);
|
|
|
|
|
|
|
|
buf = null;
|
|
|
|
binding.check(slice);
|
|
|
|
slice = null;
|
2016-04-21 14:05:44 +08:00
|
|
|
global.gc();
|
|
|
|
global.gc();
|
|
|
|
global.gc();
|
2015-10-13 04:08:13 +08:00
|
|
|
}
|
|
|
|
|
2016-03-17 09:56:15 +08:00
|
|
|
check(64, 1, 0);
|
|
|
|
|
|
|
|
// Buffers can have weird sizes.
|
|
|
|
check(97, 1, 0);
|
|
|
|
|
|
|
|
// Buffers can be unaligned
|
2016-05-09 14:04:17 +08:00
|
|
|
check(64, 8, 0);
|
2016-03-17 09:56:15 +08:00
|
|
|
check(64, 16, 0);
|
2016-05-09 14:04:17 +08:00
|
|
|
check(64, 8, 1);
|
2016-03-17 09:56:15 +08:00
|
|
|
check(64, 16, 1);
|
2016-05-09 14:04:17 +08:00
|
|
|
check(97, 8, 1);
|
2016-03-17 09:56:15 +08:00
|
|
|
check(97, 16, 1);
|
2016-05-09 14:04:17 +08:00
|
|
|
check(97, 8, 3);
|
2016-03-17 09:56:15 +08:00
|
|
|
check(97, 16, 3);
|
2015-10-13 04:08:13 +08:00
|
|
|
|
|
|
|
// Empty ArrayBuffer does not allocate data, worth checking
|
2016-03-17 09:56:15 +08:00
|
|
|
check(0, 1, 0);
|