Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4468695
test_es2016_includes_and_strict.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
test_es2016_includes_and_strict.cjs
View Options
const assert = require("node:assert");
let passed = 0;
assert.strictEqual([].includes.call({
get "0"() {
passed = NaN;
return "foo";
},
get "11"() {
passed += 1;
return 0;
},
get "19"() {
passed += 1;
return "foo";
},
get "21"() {
passed = NaN;
return "foo";
},
get length() {
passed += 1;
return 24;
}
}, "foo", 6), true);
assert.strictEqual(passed, 3);
assert.strictEqual([,].includes(), true);
assert.strictEqual(Array(1).includes(), true);
let getLog = [];
let proxy = new Proxy({ length: 3, 0: "", 1: "", 2: "", 3: "" }, {
get(target, key) {
getLog.push(String(key));
return target[key];
}
});
Array.prototype.includes.call(proxy, {});
assert.deepStrictEqual(getLog, ["length", "0", "1", "2"]);
getLog = [];
proxy = new Proxy({ length: 4, 0: NaN, 1: "", 2: NaN, 3: "" }, {
get(target, key) {
getLog.push(String(key));
return target[key];
}
});
Array.prototype.includes.call(proxy, NaN, 1);
assert.deepStrictEqual(getLog, ["length", "1", "2"]);
[
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
].forEach((TypedArray) => {
const view = new TypedArray([1, 2, 3]);
assert.strictEqual(view.includes(1), true);
assert.strictEqual(view.includes(4), false);
assert.strictEqual(view.includes(1, 1), false);
});
let threw = false;
try {
Function("function bar(...a) {'use strict';}")();
} catch (_err) {
threw = true;
}
assert.strictEqual(threw, true);
assert.doesNotThrow(() => {
const fn = Function('"use strict"; return function(a = 1) { return a; };')();
assert.strictEqual(fn(), 1);
});
assert.doesNotThrow(() => {
const fn = Function('"use strict"; return function(...a) { return a.length; };')();
assert.strictEqual(fn(1, 2), 2);
});
console.log("ES2016 includes and strict-mode regressions pass");
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 7:44 PM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543270
Default Alt Text
test_es2016_includes_and_strict.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment