Bug 1172641 - Fix class tests to not fail on builds where classes are not enabled. r=shu

This commit is contained in:
Jon Coppeard 2015-06-09 07:20:00 +02:00
parent ae4c6bfb86
commit cb7ff4726f
5 changed files with 86 additions and 59 deletions

View File

@ -1,3 +1,5 @@
load(libdir + "class.js");
var JSMSG_ILLEGAL_CHARACTER = "illegal character";
var JSMSG_UNTERMINATED_STRING = "unterminated string literal";
@ -25,7 +27,6 @@ function test_eval(code) {
assertEq(caught, true);
}
function test(code) {
test_reflect(code);
test_reflect("'use strict'; " + code);
@ -468,16 +469,18 @@ test_no_fun_no_eval("export const a = 1, b = @");
test_no_fun_no_eval("export const a = 1, b = 2 @");
test_no_fun_no_eval("export const a = 1, b = 2; @");
test_no_fun_no_eval("export class @");
test_no_fun_no_eval("export class Foo @");
test_no_fun_no_eval("export class Foo { @");
test_no_fun_no_eval("export class Foo { constructor @");
test_no_fun_no_eval("export class Foo { constructor( @");
test_no_fun_no_eval("export class Foo { constructor() @");
test_no_fun_no_eval("export class Foo { constructor() { @");
test_no_fun_no_eval("export class Foo { constructor() {} @");
test_no_fun_no_eval("export class Foo { constructor() {} } @");
test_no_fun_no_eval("export class Foo { constructor() {} }; @");
if (classesEnabled()) {
test_no_fun_no_eval("export class @");
test_no_fun_no_eval("export class Foo @");
test_no_fun_no_eval("export class Foo { @");
test_no_fun_no_eval("export class Foo { constructor @");
test_no_fun_no_eval("export class Foo { constructor( @");
test_no_fun_no_eval("export class Foo { constructor() @");
test_no_fun_no_eval("export class Foo { constructor() { @");
test_no_fun_no_eval("export class Foo { constructor() {} @");
test_no_fun_no_eval("export class Foo { constructor() {} } @");
test_no_fun_no_eval("export class Foo { constructor() {} }; @");
}
test_no_fun_no_eval("export default @");
test_no_fun_no_eval("export default 1 @");
@ -496,25 +499,27 @@ test_no_fun_no_eval("export default function foo() { @");
test_no_fun_no_eval("export default function foo() {} @");
test_no_fun_no_eval("export default function foo() {}; @");
test_no_fun_no_eval("export default class @");
test_no_fun_no_eval("export default class { @");
test_no_fun_no_eval("export default class { constructor @");
test_no_fun_no_eval("export default class { constructor( @");
test_no_fun_no_eval("export default class { constructor() @");
test_no_fun_no_eval("export default class { constructor() { @");
test_no_fun_no_eval("export default class { constructor() {} @");
test_no_fun_no_eval("export default class { constructor() {} } @");
test_no_fun_no_eval("export default class { constructor() {} }; @");
if (classesEnabled()) {
test_no_fun_no_eval("export default class @");
test_no_fun_no_eval("export default class { @");
test_no_fun_no_eval("export default class { constructor @");
test_no_fun_no_eval("export default class { constructor( @");
test_no_fun_no_eval("export default class { constructor() @");
test_no_fun_no_eval("export default class { constructor() { @");
test_no_fun_no_eval("export default class { constructor() {} @");
test_no_fun_no_eval("export default class { constructor() {} } @");
test_no_fun_no_eval("export default class { constructor() {} }; @");
test_no_fun_no_eval("export default class Foo @");
test_no_fun_no_eval("export default class Foo { @");
test_no_fun_no_eval("export default class Foo { constructor @");
test_no_fun_no_eval("export default class Foo { constructor( @");
test_no_fun_no_eval("export default class Foo { constructor() @");
test_no_fun_no_eval("export default class Foo { constructor() { @");
test_no_fun_no_eval("export default class Foo { constructor() {} @");
test_no_fun_no_eval("export default class Foo { constructor() {} } @");
test_no_fun_no_eval("export default class Foo { constructor() {} }; @");
test_no_fun_no_eval("export default class Foo @");
test_no_fun_no_eval("export default class Foo { @");
test_no_fun_no_eval("export default class Foo { constructor @");
test_no_fun_no_eval("export default class Foo { constructor( @");
test_no_fun_no_eval("export default class Foo { constructor() @");
test_no_fun_no_eval("export default class Foo { constructor() { @");
test_no_fun_no_eval("export default class Foo { constructor() {} @");
test_no_fun_no_eval("export default class Foo { constructor() {} } @");
test_no_fun_no_eval("export default class Foo { constructor() {} }; @");
}
// import

View File

@ -1,5 +1,6 @@
load(libdir + "match.js");
load(libdir + "asserts.js");
load(libdir + "class.js");
var { Pattern, MatchError } = Match;
@ -202,16 +203,18 @@ program([
)
]).assert(Reflect.parse("export function f() {}"));
program([
exportDeclaration(
classDeclaration(
ident("Foo")
),
null,
null,
false
)
]).assert(Reflect.parse("export class Foo { constructor() {} }"));
if (classesEnabled()) {
program([
exportDeclaration(
classDeclaration(
ident("Foo")
),
null,
null,
false
)
]).assert(Reflect.parse("export class Foo { constructor() {} }"));
}
program([
exportDeclaration(
@ -292,27 +295,29 @@ program([
)
]).assert(Reflect.parse("export default function foo() {}"));
program([
exportDeclaration(
classDeclaration(
ident("*default*")
),
null,
null,
true
)
]).assert(Reflect.parse("export default class { constructor() {} }"));
if (classesEnabled()) {
program([
exportDeclaration(
classDeclaration(
ident("*default*")
),
null,
null,
true
)
]).assert(Reflect.parse("export default class { constructor() {} }"));
program([
exportDeclaration(
classDeclaration(
ident("Foo")
),
null,
null,
true
)
]).assert(Reflect.parse("export default class Foo { constructor() {} }"));
program([
exportDeclaration(
classDeclaration(
ident("Foo")
),
null,
null,
true
)
]).assert(Reflect.parse("export default class Foo { constructor() {} }"));
}
program([
exportDeclaration(

View File

@ -1,3 +1,5 @@
var test = `
// Just like newTargetDirectInvoke, except to prove it works in functions
// defined with method syntax as well. Note that methods, getters, and setters
// are not constructible.
@ -46,7 +48,10 @@ for (let i = 0; i < TEST_ITERATIONS; i++)
clInst.cl;
for (let i = 0; i < TEST_ITERATIONS; i++)
clInst.cl = 4;
`;
if (classesEnabled())
eval(test);
if (typeof reportCompare === "function")
reportCompare(0,0,"OK");

View File

@ -1,3 +1,5 @@
var test = `
class foo {
constructor() { }
@ -6,6 +8,10 @@ class foo {
}
}
assertEq(new foo().method()(), Object.prototype.toString);
`;
if (classesEnabled())
eval(test);
if (typeof reportCompare === "function")
reportCompare(0,0,"OK");

View File

@ -1,3 +1,5 @@
var test = `
class foo {
constructor() { }
@ -7,6 +9,10 @@ class foo {
}
assertEq(new foo().method()(), Object.prototype.toString);
`;
if (classesEnabled())
eval(test);
if (typeof reportCompare === "function")
reportCompare(0,0,"OK");