main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
839 bytes
|
Line | |
---|
1 | /* eslint no-restricted-syntax: 0, no-with: 0, strict: 0 */
|
---|
2 |
|
---|
3 | var test = require('tape');
|
---|
4 |
|
---|
5 | var shimUnscopables = require('../');
|
---|
6 |
|
---|
7 | test('`with` statement', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (t) {
|
---|
8 | var entries;
|
---|
9 | var concat;
|
---|
10 | with ([]) {
|
---|
11 | t.equal(concat, Array.prototype.concat, 'concat is dynamically bound');
|
---|
12 | t.notEqual(entries, Array.prototype.entries, 'entries is not dynamically bound');
|
---|
13 | }
|
---|
14 |
|
---|
15 | var obj = {
|
---|
16 | foo: 1,
|
---|
17 | bar: 2
|
---|
18 | };
|
---|
19 | var foo;
|
---|
20 | var bar;
|
---|
21 | obj[Symbol.unscopables] = { foo: true };
|
---|
22 | with (obj) {
|
---|
23 | t.equal(foo, undefined);
|
---|
24 | t.equal(bar, obj.bar);
|
---|
25 | }
|
---|
26 |
|
---|
27 | shimUnscopables('concat');
|
---|
28 |
|
---|
29 | with ([]) {
|
---|
30 | t.notEqual(concat, Array.prototype.concat, 'concat is no longer dynamically bound');
|
---|
31 | t.notEqual(entries, Array.prototype.entries, 'entries is still not dynamically bound');
|
---|
32 | }
|
---|
33 |
|
---|
34 | t.end();
|
---|
35 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.