FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ClearScript/ClearScriptTest/V8SharedObjectTest.cs at master · ClearFoundry/ClearScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ClearFoundry
/
ClearScript
Public
Notifications
You must be signed in to change notification settings
Fork
167
Star
2k
Code
Issues
18
Pull requests
6
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
ClearScript
/
ClearScriptTest
/
V8SharedObjectTest.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
184 lines (162 loc) · 8.95 KB
Breadcrumbs
ClearScript
/
ClearScriptTest
/
V8SharedObjectTest.cs
Copy path
File metadata and controls
184 lines (162 loc) · 8.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using
System
;
using
System
.
Diagnostics
.
CodeAnalysis
;
using
System
.
Linq
;
using
Microsoft
.
ClearScript
.
JavaScript
;
using
Microsoft
.
ClearScript
.
V8
;
using
Microsoft
.
VisualStudio
.
TestTools
.
UnitTesting
;
namespace
Microsoft
.
ClearScript
.
Test
{
[
TestClass
]
[
SuppressMessage
(
"Microsoft.Design"
,
"CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable"
,
Justification
=
"Test classes use TestCleanupAttribute for deterministic teardown."
)
]
public
class
V8SharedObjectTest
:
ClearScriptTest
{
#region setup / teardown
private
V8ScriptEngine
engine
;
private
V8ScriptEngine
otherEngine
;
[
TestInitialize
]
public
void
TestInitialize
(
)
{
BaseTestInitialize
(
)
;
otherEngine
=
new
V8ScriptEngine
(
)
;
otherEngine
.
Execute
(
@"
arrayBuffer = new SharedArrayBuffer(1024);
array = new Uint8Array(arrayBuffer);
for (let index = 0; index < 1024; ++index) {
array[index] = index & 0xFF;
}
"
)
;
engine
=
new
V8ScriptEngine
(
V8ScriptEngineFlags
.
EnableDebugging
)
;
engine
.
Script
.
arrayBuffer
=
otherEngine
.
Script
.
arrayBuffer
;
}
[
TestCleanup
]
public
void
TestCleanup
(
)
{
otherEngine
.
Dispose
(
)
;
engine
.
Dispose
(
)
;
BaseTestCleanup
(
)
;
}
#endregion
#region test methods
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_ArrayBuffer
(
)
{
Assert
.
AreEqual
(
"[object SharedArrayBuffer]"
,
engine
.
ExecuteCommand
(
"arrayBuffer"
)
)
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"arrayBuffer instanceof SharedArrayBuffer"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
IArrayBuffer
)
engine
.
Script
.
arrayBuffer
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_DataView
(
)
{
otherEngine
.
Execute
(
"dataView = new DataView(arrayBuffer)"
)
;
engine
.
Script
.
dataView
=
otherEngine
.
Script
.
dataView
;
Assert
.
AreEqual
(
"[object DataView]"
,
engine
.
ExecuteCommand
(
"dataView"
)
)
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"dataView instanceof DataView"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
IDataView
)
engine
.
Script
.
dataView
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Uint8Array
(
)
{
otherEngine
.
Execute
(
"array = new Uint8Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Uint8Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
byte
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Uint8ClampedArray
(
)
{
otherEngine
.
Execute
(
"array = new Uint8ClampedArray(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Uint8ClampedArray"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
byte
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Int8Array
(
)
{
otherEngine
.
Execute
(
"array = new Int8Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Int8Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
sbyte
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Uint16Array
(
)
{
otherEngine
.
Execute
(
"array = new Uint16Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Uint16Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
ushort
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
char
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Int16Array
(
)
{
otherEngine
.
Execute
(
"array = new Int16Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Int16Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
short
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Uint32Array
(
)
{
otherEngine
.
Execute
(
"array = new Uint32Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Uint32Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
uint
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Int32Array
(
)
{
otherEngine
.
Execute
(
"array = new Int32Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Int32Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
int
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_BigUint64Array
(
)
{
otherEngine
.
Execute
(
"array = new BigUint64Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof BigUint64Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
ulong
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_BigInt64Array
(
)
{
otherEngine
.
Execute
(
"array = new BigInt64Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof BigInt64Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
long
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Float32Array
(
)
{
otherEngine
.
Execute
(
"array = new Float32Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Float32Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
float
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
[
TestMethod
,
TestCategory
(
"V8SharedObject"
)
]
public
void
V8SharedObject_Float64Array
(
)
{
otherEngine
.
Execute
(
"array = new Float64Array(arrayBuffer)"
)
;
engine
.
Script
.
array
=
otherEngine
.
Script
.
array
;
Assert
.
IsTrue
(
Convert
.
ToBoolean
(
engine
.
Evaluate
(
"array instanceof Float64Array"
)
)
)
;
var
testValues
=
Enumerable
.
Range
(
0
,
1024
)
.
Select
(
index
=>
Convert
.
ToByte
(
index
&
0xFF
)
)
.
ToArray
(
)
;
Assert
.
IsTrue
(
testValues
.
SequenceEqual
(
(
(
ITypedArray
<
double
>
)
engine
.
Script
.
array
)
.
GetBytes
(
)
)
)
;
}
#endregion
}
}
Back
|
FazBrowse Home
|
New Git URL