Skip to content

Commit

Permalink
TEMP: Autogenerated tests without templates
Browse files Browse the repository at this point in the history
  • Loading branch information
pzuraq authored and ptomato committed Oct 15, 2024
1 parent f02d606 commit 15f73b9
Show file tree
Hide file tree
Showing 12 changed files with 556 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/language/expressions/class/decorator/field-context-kind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-context-kind.case
// - src/decorator/default/cls-expr.template
/*---
description: Context kind is the string "field" when decorating a field (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
info: |
CreateDecoratorContextObject ( kind, name, initializers, decorationState [ , isStatic ] )
...
6. Else if kind is field, then
a. Let kindStr be "field".
---*/


function dec(_, context) {
assert.sameValue(context.kind, "field");
}


var C = class {
@dec foo;
@dec bar = 123;

@dec static foo;
@dec static bar = 123;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-initializers-interleave.case
// - src/decorator/default/cls-expr.template
/*---
description: Decorated field initializers are interleaved with undecorated fields (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
---*/


var ord = [];

function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) {
ord.push(evalOrd);

return (value, context) => {
ord.push(applyOrd);

context.addInitializer(() => ord.push(extraOrd));

return () => {
ord.push(initOrd);
}
}
}


var C = class {
@pushOrd(0, 5, 9, 12)
@pushOrd(1, 4, 10, 11)
foo = ord.push(8);

bar = ord.push(13);

@pushOrd(2, 7, 15, 18)
@pushOrd(3, 6, 16, 17)
baz = ord.push(14)

}

new C();

assert.sameValue(ord.length, 19);
ord.forEach(assert.sameValue);
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-instance-initializer-order.case
// - src/decorator/with-super-class/cls-expr.template
/*---
description: Decorated field instance initializers run after super, before constructor (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
---*/


var ord = [];

function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) {
ord.push(evalOrd);

return (value, context) => {
ord.push(applyOrd);

context.addInitializer(() => ord.push(extraOrd));

return () => {
ord.push(initOrd);
}
}
}


class B {}

var C = class extends B {
@pushOrd(0, 3, 6, 9)
@pushOrd(1, 2, 7, 8)
foo = ord.push(5);

constructor() {
ord.push(4);
super();
ord.push(10)
}

}

new C();

assert.sameValue(ord.length, 11);
ord.forEach(assert.sameValue);
41 changes: 41 additions & 0 deletions test/language/expressions/class/decorator/field-received-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-received-value.case
// - src/decorator/default/cls-expr.template
/*---
description: Value passed to field decorators is undefined (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
info: |
ApplyDecoratorsToElementDefinition ( homeObject, elementRecord, extraInitializers, isStatic )
...
5. For each element decoratorRecord of decorators, do
a. Let decorator be decoratorRecord.[[Decorator]].
b. Let decoratorReceiver be decoratorRecord.[[Receiver]].
c. Let decorationState be the Record { [[Finished]]: false }.
d. Let context be CreateDecoratorContextObject(kind, key, extraInitializers, decorationState, isStatic).
e. Let value be undefined.
...
j. Let newValue be ? Call(decorator, decoratorReceiver, « value, context »).
---*/


function dec(value) {
assert.sameValue(value, undefined);
}


var C = class {
@dec foo;
@dec bar = 123;

@dec static foo;
@dec static bar = 123;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-static-initializer-order.case
// - src/decorator/default/cls-expr.template
/*---
description: Decorated field static initializers interleave with static blocks (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
---*/


var ord = [];

function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) {
ord.push(evalOrd);

return (value, context) => {
ord.push(applyOrd);

context.addInitializer(() => ord.push(extraOrd));

return () => {
ord.push(initOrd);
}
}
}


var C = class {
static {
ord.push(4)
}

@pushOrd(0, 3, 6, 9)
@pushOrd(1, 2, 7, 8)
static foo = ord.push(5);

static {
ord.push(10)
}

}

assert.sameValue(ord.length, 11);
ord.forEach(assert.sameValue);
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-instance-initializer-order.case
// - src/decorator/with-super-class/cls-expr.template
/*---
description: Decorated field instance initializers run after super, before constructor (decorator usage in a class expression)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
---*/


var ord = [];

function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) {
ord.push(evalOrd);

return (value, context) => {
ord.push(applyOrd);

context.addInitializer(() => ord.push(extraOrd));

return () => {
ord.push(initOrd);
}
}
}


class B {}

var C = class extends B {
constructor() {
ord.push(4);
super();
ord.push(10);
}

@pushOrd(0, 3, 6, 9)
@pushOrd(1, 2, 7, 8)
foo = ord.push(5);

}

new C();

assert.sameValue(ord.length, 11);
ord.forEach(assert.sameValue);
33 changes: 33 additions & 0 deletions test/language/statements/class/decorator/field-context-kind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-context-kind.case
// - src/decorator/default/cls-decl.template
/*---
description: Context kind is the string "field" when decorating a field (decorator usage in a class declaration)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
info: |
CreateDecoratorContextObject ( kind, name, initializers, decorationState [ , isStatic ] )
...
6. Else if kind is field, then
a. Let kindStr be "field".
---*/


function dec(_, context) {
assert.sameValue(context.kind, "field");
}


class C {
@dec foo;
@dec bar = 123;

@dec static foo;
@dec static bar = 123;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-initializers-interleave.case
// - src/decorator/default/cls-decl.template
/*---
description: Decorated field initializers are interleaved with undecorated fields (decorator usage in a class declaration)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
---*/


var ord = [];

function pushOrd(evalOrd, applyOrd, initOrd, extraOrd) {
ord.push(evalOrd);

return (value, context) => {
ord.push(applyOrd);

context.addInitializer(() => ord.push(extraOrd));

return () => {
ord.push(initOrd);
}
}
}


class C {
@pushOrd(0, 5, 9, 12)
@pushOrd(1, 4, 10, 11)
foo = ord.push(8);

bar = ord.push(13);

@pushOrd(2, 7, 15, 18)
@pushOrd(3, 6, 16, 17)
baz = ord.push(14)

}

new C();

assert.sameValue(ord.length, 19);
ord.forEach(assert.sameValue);
41 changes: 41 additions & 0 deletions test/language/statements/class/decorator/field-received-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file was procedurally generated from the following sources:
// - src/decorator/field-received-value.case
// - src/decorator/default/cls-decl.template
/*---
description: Value passed to field decorators is undefined (decorator usage in a class declaration)
esid: prod-FieldDefinition
features: [decorators, class]
flags: [generated]
info: |
ApplyDecoratorsToElementDefinition ( homeObject, elementRecord, extraInitializers, isStatic )
...
5. For each element decoratorRecord of decorators, do
a. Let decorator be decoratorRecord.[[Decorator]].
b. Let decoratorReceiver be decoratorRecord.[[Receiver]].
c. Let decorationState be the Record { [[Finished]]: false }.
d. Let context be CreateDecoratorContextObject(kind, key, extraInitializers, decorationState, isStatic).
e. Let value be undefined.
...
j. Let newValue be ? Call(decorator, decoratorReceiver, « value, context »).
---*/


function dec(value) {
assert.sameValue(value, undefined);
}


class C {
@dec foo;
@dec bar = 123;

@dec static foo;
@dec static bar = 123;
}


Loading

0 comments on commit 15f73b9

Please sign in to comment.