Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for reversed keywords used as import/export specifiers
- Loading branch information
Showing
8 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
test/form/samples/reserved-keywords-in-imports-exports/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
description: 'correctly handles reserved keywords in exports/imports', | ||
options: { | ||
input: ['main'], | ||
output: { | ||
name: 'reservedKeywords' | ||
}, | ||
external: ['external'] | ||
} | ||
}; |
41 changes: 41 additions & 0 deletions
41
test/form/samples/reserved-keywords-in-imports-exports/_expected/amd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
define(['exports', 'external'], (function (exports, external) { 'use strict'; | ||
|
||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
|
||
var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); | ||
|
||
console.log(external.finally, external.catch); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
Object.defineProperty(exports, 'const', { | ||
enumerable: true, | ||
get: function () { return external.const; } | ||
}); | ||
Object.defineProperty(exports, 'in', { | ||
enumerable: true, | ||
get: function () { return external.for; } | ||
}); | ||
Object.defineProperty(exports, 'return', { | ||
enumerable: true, | ||
get: function () { return external.bar; } | ||
}); | ||
exports.yield = external__namespace; | ||
exports.await = legal; | ||
|
||
})); |
41 changes: 41 additions & 0 deletions
41
test/form/samples/reserved-keywords-in-imports-exports/_expected/cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
var external = require('external'); | ||
|
||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
|
||
var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); | ||
|
||
console.log(external.finally, external.catch); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
Object.defineProperty(exports, 'const', { | ||
enumerable: true, | ||
get: function () { return external.const; } | ||
}); | ||
Object.defineProperty(exports, 'in', { | ||
enumerable: true, | ||
get: function () { return external.for; } | ||
}); | ||
Object.defineProperty(exports, 'return', { | ||
enumerable: true, | ||
get: function () { return external.bar; } | ||
}); | ||
exports.yield = external__namespace; | ||
exports.await = legal; |
10 changes: 10 additions & 0 deletions
10
test/form/samples/reserved-keywords-in-imports-exports/_expected/es.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { finally as finally$1, catch as catch$1 } from 'external'; | ||
import * as external from 'external'; | ||
export { external as yield }; | ||
export { const, for as in, bar as return } from 'external'; | ||
|
||
console.log(finally$1, catch$1); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
export { legal as await }; |
44 changes: 44 additions & 0 deletions
44
test/form/samples/reserved-keywords-in-imports-exports/_expected/iife.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var reservedKeywords = (function (exports, external) { | ||
'use strict'; | ||
|
||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
|
||
var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); | ||
|
||
console.log(external.finally, external.catch); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
Object.defineProperty(exports, 'const', { | ||
enumerable: true, | ||
get: function () { return external.const; } | ||
}); | ||
Object.defineProperty(exports, 'in', { | ||
enumerable: true, | ||
get: function () { return external.for; } | ||
}); | ||
Object.defineProperty(exports, 'return', { | ||
enumerable: true, | ||
get: function () { return external.bar; } | ||
}); | ||
exports.yield = external__namespace; | ||
exports.await = legal; | ||
|
||
return exports; | ||
|
||
})({}, external); |
18 changes: 18 additions & 0 deletions
18
test/form/samples/reserved-keywords-in-imports-exports/_expected/system.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
System.register('reservedKeywords', ['external'], (function (exports) { | ||
'use strict'; | ||
var finally$1, catch$1; | ||
return { | ||
setters: [function (module) { | ||
finally$1 = module.finally; | ||
catch$1 = module.catch; | ||
exports({ const: module.const, in: module.for, return: module.bar, yield: module }); | ||
}], | ||
execute: (function () { | ||
|
||
console.log(finally$1, catch$1); // retain those local bindings | ||
|
||
const legal = exports('await', 10); | ||
|
||
}) | ||
}; | ||
})); |
45 changes: 45 additions & 0 deletions
45
test/form/samples/reserved-keywords-in-imports-exports/_expected/umd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.reservedKeywords = {}, global.external)); | ||
})(this, (function (exports, external) { 'use strict'; | ||
|
||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
|
||
var external__namespace = /*#__PURE__*/_interopNamespaceDefault(external); | ||
|
||
console.log(external.finally, external.catch); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
Object.defineProperty(exports, 'const', { | ||
enumerable: true, | ||
get: function () { return external.const; } | ||
}); | ||
Object.defineProperty(exports, 'in', { | ||
enumerable: true, | ||
get: function () { return external.for; } | ||
}); | ||
Object.defineProperty(exports, 'return', { | ||
enumerable: true, | ||
get: function () { return external.bar; } | ||
}); | ||
exports.yield = external__namespace; | ||
exports.await = legal; | ||
|
||
})); |
11 changes: 11 additions & 0 deletions
11
test/form/samples/reserved-keywords-in-imports-exports/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { finally as baz, catch as bazinga } from 'external'; | ||
console.log(baz, bazinga); // retain those local bindings | ||
|
||
const legal = 10; | ||
|
||
export { legal as await }; | ||
|
||
export { bar as return, const, for as in } from 'external'; | ||
|
||
import * as lib from 'external'; | ||
export { lib as yield }; |