Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
99 lines (81 loc) · 4.79 KB

File metadata and controls

99 lines (81 loc) · 4.79 KB
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
//-------------------------------------------------------------------------------------------------------
// 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 tests = [
{
name : "NullTypeHandler basic functionality and sanity checks",
body : function() {
var objects = [
Object.create({}),
new Boolean(),
Object.create(Promise.prototype),
Function(""),
new Number(),
new String()
];
for (var i = 1; i < objects.length; ++i) {
var o = objects[i];
assert.areEqual(undefined, o[0], "NullTypeHandler object with no properties returns undefined");
assert.isFalse(o.hasOwnProperty('0'), "NullTypeHandler object with no properties returns false for hasOwnProperty");
assert.isFalse(o.propertyIsEnumerable('0'), "NullTypeHandler object with no properties returns false for propertyIsEnumerable");
for (var a in o) {
assert.fail("Enumerating an empty object"); // Unreachable
}
o[0] = "str";
assert.areEqual("str", o[0], "NullTypeHandler object with index property returns property correctly");
assert.areEqual("str", o['0'], "NullTypeHandler object with index property returns property correctly");
assert.isTrue(o.hasOwnProperty('0'), "NullTypeHandler object with index property returns true for hasOwnProperty");
assert.isTrue(o.propertyIsEnumerable('0'), "NullTypeHandler object with index property returns true for propertyIsEnumerable");
delete o[0];
assert.areEqual(undefined, o[0], "NullTypeHandler objectwith deleted property returns undefined");
assert.areEqual(undefined, o['0'], "NullTypeHandler objectwith deleted property returns undefined");
assert.isFalse(o.hasOwnProperty('0'), "NullTypeHandler object with deleted property returns false for hasOwnProperty");
assert.isFalse(o.propertyIsEnumerable('0'), "NullTypeHandler object with deleted property returns false for propertyIsEnumerable");
for (var a in o) {
assert.fail("Enumerating an empty object"); // Unreachable
}
o[0] = "str2";
assert.areEqual("str2", o[0], "NullTypeHandler object with readded index property returns property correctly");
assert.areEqual("str2", o['0'], "NullTypeHandler object with readded index property returns property correctly");
assert.isTrue(o.hasOwnProperty('0'), "NullTypeHandler object with readded index property returns true for hasOwnProperty");
assert.isTrue(o.propertyIsEnumerable('0'), "NullTypeHandler object readded with index property returns true for propertyIsEnumerable");
}
}
},
{
name: "NullTypeHandler enumeration",
body: function () {
var obj1 = Object.create({});
var obj2 = Object.create(null);
var numProperties = 3;
for (var i = 0; i < numProperties; ++i)
{
obj1[i] = i;
assert.areEqual(obj1[i], i, "NullTypeHandler first enumeration object with index " + i + " equal to " + i);
assert.isTrue(obj1.hasOwnProperty(i), "NullTypeHandler first enumeration object with index " + i + " returns true for hasOwnProperty");
assert.isTrue(obj1.propertyIsEnumerable(i), "NullTypeHandler object first enumeration with index " + i + " returns true for propertyIsEnumerable");
obj2[i] = i;
assert.areEqual(obj2[i], i, "NullTypeHandler second enumeration object with index " + i + " equal to " + i);
assert.isTrue(Object.prototype.hasOwnProperty.call(obj2, i), "NullTypeHandler first enumeration object with index " + i + " returns true for hasOwnProperty");
assert.isTrue(Object.prototype.propertyIsEnumerable.call(obj2, i), "NullTypeHandler object first enumeration with index " + i + " returns true for propertyIsEnumerable");
}
var j = 0;
for (var k in obj1)
{
++j;
}
assert.areEqual(j, numProperties, "NullTypeHandler first enumeration object gives same number of properties");
j = 0;
for (var k in obj2)
{
++j;
}
assert.areEqual(j, numProperties, "NullTypeHandler second enumeration object gives same number of properties");
}
}
];
testRunner.runTests(tests, { verbose : WScript.Arguments[0] != "summary" });
Morty Proxy This is a proxified and sanitized view of the page, visit original site.