forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.js
More file actions
47 lines (43 loc) · 1.81 KB
/
transfer.js
File metadata and controls
47 lines (43 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
if (this.WScript && this.WScript.LoadScriptFile) { // Check for running in ch
this.WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
}
var buf1 = new ArrayBuffer(1<<21);
new Int8Array(buf1)[0] = 42;
new Int8Array(buf1)[1<<21-1] = 43;
var buf2 = ArrayBuffer.transfer(buf1, 1<<22);
print(buf1.byteLength);
print(buf2.byteLength);
print(new Int8Array(buf2)[1<<21-1]);
print(new Int8Array(buf2)[0]);
new Int8Array(buf2)[1<<22-1] = 44;
print(new Int8Array(buf2)[1<<22-1]);
var buf3 = ArrayBuffer.transfer(buf2, 1<<20);
print(buf2.byteLength);
print(buf3.byteLength);
print(new Int8Array(buf3)[1<<21-1]);
print(new Int8Array(buf3)[0]);
var buf4 = ArrayBuffer.transfer(buf3, 80);
print(buf3.byteLength);
print(buf4.byteLength);
print(new Int8Array(buf4)[0]);
var buf5 = ArrayBuffer.transfer(buf4, 0);
print(buf4.byteLength);
print(buf5.byteLength);
var buf6 = ArrayBuffer.transfer(buf5, 1<<21);
print(buf5.byteLength);
print(buf6.byteLength);
var buf7 = ArrayBuffer.transfer(buf6, 0);
print(buf6.byteLength);
print(buf7.byteLength);
// Test the DataView constructor with a detached buffer.
function TestDataViewCostructorDetachedBuffer()
{
var arrayBufferToDetach = new ArrayBuffer(16);
var arrayBufferNew = ArrayBuffer.transfer(arrayBufferToDetach, 0);
var dataView8 = new DataView(arrayBufferToDetach);
}
assert.throws(TestDataViewCostructorDetachedBuffer, TypeError, "", "'this' is not a DataView object");