1
1
//-------------------------------------------------------------------------------------------------------
2
- // Copyright (C) Microsoft. All rights reserved.
2
+ // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3
+ // Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
3
4
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4
5
//-------------------------------------------------------------------------------------------------------
5
6
@@ -13,6 +14,24 @@ var tests = [
13
14
assert . isTrue ( Array . prototype . hasOwnProperty ( Symbol . unscopables ) , "Array should have Array.prototype[@@unscopables] property" ) ;
14
15
}
15
16
} ,
17
+ {
18
+ name : "Check if all excepted properties exist in Array.prototype[@@unscopables] and have corresponding values" ,
19
+ body : function ( )
20
+ {
21
+
22
+ const unscopables = Array . prototype [ Symbol . unscopables ] ;
23
+
24
+ const list = [ "copyWithin" , "entries" , "fill" , "find" , "findIndex" , "flat" , "flatMap" , "includes" , "keys" , "values" ] ;
25
+ const length = list . length ;
26
+
27
+ for ( let index = 0 ; index < length ; index ++ )
28
+ {
29
+ const propName = list [ index ] ;
30
+ assert . areEqual ( unscopables [ propName ] , true , `Array.prototype[@@unscopables].${ propName } should equal true` ) ;
31
+ }
32
+
33
+ }
34
+ } ,
16
35
{
17
36
name : "Global scope test on Arrays" ,
18
37
body : function ( )
@@ -26,6 +45,8 @@ var tests = [
26
45
var includes = globalScope ;
27
46
var keys = globalScope ;
28
47
var values = globalScope ;
48
+ var flat = globalScope ;
49
+ var flatMap = globalScope ;
29
50
with ( [ ] )
30
51
{
31
52
assert . areEqual ( globalScope , find , "find property is not brought into scope by the with statement" ) ;
@@ -36,6 +57,8 @@ var tests = [
36
57
assert . areEqual ( globalScope , includes , "includes property is not brought into scope by the with statement" ) ;
37
58
assert . areEqual ( globalScope , keys , "keys property is not brought into scope by the with statement" ) ;
38
59
assert . areEqual ( globalScope , values , "values property is not brought into scope by the with statement" ) ;
60
+ assert . areEqual ( globalScope , flat , "flat property is not brought into scope by the with statement" ) ;
61
+ assert . areEqual ( globalScope , flatMap , "flatMap property is not brought into scope by the with statement" ) ;
39
62
}
40
63
}
41
64
} ,
@@ -53,6 +76,8 @@ var tests = [
53
76
var keys = globalScope ;
54
77
var values = globalScope ;
55
78
var slice = globalScope ;
79
+ var flat = globalScope ;
80
+ var flatMap = globalScope ;
56
81
var a = [ ] ;
57
82
a [ Symbol . unscopables ] [ "slice" ] = true ;
58
83
with ( a )
@@ -66,6 +91,8 @@ var tests = [
66
91
assert . areEqual ( globalScope , keys , "keys property is not brought into scope by the with statement" ) ;
67
92
assert . areEqual ( globalScope , values , "values property is not brought into scope by the with statement" ) ;
68
93
assert . areEqual ( globalScope , slice , "slice property is not brought into scope by the with statement" ) ;
94
+ assert . areEqual ( globalScope , flat , "flat property is not brought into scope by the with statement" ) ;
95
+ assert . areEqual ( globalScope , flatMap , "flatMap property is not brought into scope by the with statement" ) ;
69
96
}
70
97
}
71
98
} ,
@@ -236,6 +263,8 @@ var tests = [
236
263
var includes = globalScope ;
237
264
var keys = globalScope ;
238
265
var values = globalScope ;
266
+ var flat = globalScope ;
267
+ var flatMap = globalScope ;
239
268
with ( [ ] )
240
269
{
241
270
function foo ( )
@@ -254,6 +283,8 @@ var tests = [
254
283
assert . areEqual ( globalScope , includes , "includes property is not brought into scope by the with statement" ) ;
255
284
assert . areEqual ( globalScope , keys , "keys property is not brought into scope by the with statement" ) ;
256
285
assert . areEqual ( globalScope , values , "values property is not brought into scope by the with statement" ) ;
286
+ assert . areEqual ( globalScope , flat , "flat property is not brought into scope by the with statement" ) ;
287
+ assert . areEqual ( globalScope , flatMap , "flatMap property is not brought into scope by the with statement" ) ;
257
288
}
258
289
}
259
290
}
0 commit comments