-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
77 lines (61 loc) · 1.7 KB
/
test.js
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
const test = require('pitesti')();
const assert = require('assert');
let PrivateSymbol;
test`require`(() => {
PrivateSymbol = require('.');
});
test.context`symbol`(() => {
let sym;
const obj = {};
test`is created and set`(() => {
sym = PrivateSymbol('foo');
obj[sym] = 'bar';
assert.strictEqual(obj[sym], 'bar');
});
test`is "in" obj`(() => {
assert.ok(sym in obj);
});
test`is not enumerably "in" obj`(() => {
for (const key in obj) {
assert.notStrictEqual(key, sym);
}
});
test`is not enumerably "of" obj`(() => {
for (const value in obj) {
assert.notStrictEqual(value, 'bar');
}
});
test`is not in Object.keys`(() => {
assert.ok(!Object.keys(obj).includes(sym));
});
test`is not in Object.values`(() => {
assert.ok(!Object.values(obj).includes('bar'));
});
test`is not in Object.entries`(() => {
assert.ok(!Object.entries(obj).map(x => x[0]).includes(sym));
});
test`is not in Object.getOwnPropertyNames`(() => {
assert.ok(!Object.getOwnPropertyNames(obj).includes(sym));
});
test`is not in Object.getOwnPropertySymbols`(() => {
assert.ok(!Object.getOwnPropertySymbols(obj).includes(sym));
});
test`is not in Object.getOwnPropertySymbols`(() => {
assert.ok(!Object.keys(Object.getOwnPropertyDescriptors(obj)).includes(sym));
});
test`is not in Reflect.ownKeys`(() => {
assert.ok(!Reflect.ownKeys(obj).includes(sym));
});
});
test`does not alter v8 flag`(() => {
function testEval () {
// eslint-disable-next-line no-eval
eval('%CreatePrivateSymbol()');
}
if (process.argv[2] === 'flag') {
assert.doesNotThrow(testEval);
} else {
assert.throws(testEval);
}
});
test();