Bug 1204402 - Fix export-entries.js and module-environment.js to not fail when classes are disabled, r=jorendorff

This commit is contained in:
Eric Faust 2015-09-16 13:03:00 -07:00
parent 3f7087fb33
commit 2b70848925
2 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,5 @@
load(libdir + "class.js");
// Test localExportEntries property
function testArrayContents(actual, expected) {
@ -30,9 +32,11 @@ testLocalExportEntries(
'export const x = 1;',
[{exportName: 'x', moduleRequest: null, importName: null, localName: 'x'}]);
testLocalExportEntries(
'export class foo { constructor() {} };',
[{exportName: 'foo', moduleRequest: null, importName: null, localName: 'foo'}]);
if (classesEnabled()) {
testLocalExportEntries(
'export class foo { constructor() {} };',
[{exportName: 'foo', moduleRequest: null, importName: null, localName: 'foo'}]);
}
testLocalExportEntries(
'export default function f() {};',

View File

@ -1,3 +1,5 @@
load(libdir + "class.js");
// Test top-level module environment
function testInitialEnvironment(source, expected) {
@ -17,11 +19,14 @@ testInitialEnvironment('let x = 1;', ['x']);
testInitialEnvironment("if (true) { let x = 1; }", []);
testInitialEnvironment("if (true) { var x = 1; }", ['x']);
testInitialEnvironment('function x() {}', ['x']);
testInitialEnvironment("class x { constructor() {} }", ['x']);
testInitialEnvironment('export var x = 1;', ['x']);
testInitialEnvironment('export let x = 1;', ['x']);
testInitialEnvironment('export default class x { constructor() {} };', ['x']);
testInitialEnvironment('export default function x() {};', ['x']);
testInitialEnvironment('export default 1;', ['*default*']);
testInitialEnvironment('export default class { constructor() {} };', ['*default*']);
testInitialEnvironment('export default function() {};', ['*default*']);
if (classesEnabled()) {
testInitialEnvironment("class x { constructor() {} }", ['x']);
testInitialEnvironment('export default class x { constructor() {} };', ['x']);
testInitialEnvironment('export default class { constructor() {} };', ['*default*']);
}