file_path stringlengths 3 280 | file_language stringclasses 66 values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108 values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Return-null-static-getter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
static get foo() { return; }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Return-object-instance-getter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
get foo() { return; }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Return-object-private-instance-getter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
get #foo() { return; }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Return-object-private-static-getter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static get #foo() { return; }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Return-object-static-getter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static get foo() { return; }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Shim-instance-getter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
class Foo {
bar = 123;
@dec
get foo() { return this.bar; }
}
assertEq(() => Object.getOwnPropertyDescriptor(Foo.prototype, 'foo').get, bar);
assertEq(() => new Foo().foo, 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Shim-private-instance-getter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
let get$foo;
class Foo {
#bar = 123;
@dec
get #foo() { return this.#bar; }
static { get$foo = x => x.#foo; }
}
assertEq(() => get$foo(new Foo), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Shim-private-static-getter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
let get$foo;
class Foo {
static #bar = 123;
@dec
static get #foo() { return this.#bar; }
static { get$foo = x => x.#foo; }
}
assertEq(() => get$foo(Foo), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Getter-decorators-Shim-static-getter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
class Foo {
static bar = 123;
@dec
static get foo() { return this.bar; }
}
assertEq(() => Object.getOwnPropertyDescriptor(Foo, 'foo').get, bar);
assertEq(() => Foo.foo, 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Initializer-order-private-members,-class-expression.js | JavaScript | (() => {
const log = [];
// Class decorators
const classDec1 = (cls, ctxClass) => {
log.push('c2');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c5'));
ctxClass.addInitializer(() => log.push('c6'));
};
const classDec2 = (cls, ctxClass) => {
log.push('c1');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c3'));
ctxClass.addInitializer(() => log.push('c4'));
};
// Method decorators
const methodDec1 = (fn, ctxMethod) => {
log.push('m2');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m5'));
ctxMethod.addInitializer(() => log.push('m6'));
};
const methodDec2 = (fn, ctxMethod) => {
log.push('m1');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m3'));
ctxMethod.addInitializer(() => log.push('m4'));
};
const staticMethodDec1 = (fn, ctxStaticMethod) => {
log.push('M2');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M5'));
ctxStaticMethod.addInitializer(() => log.push('M6'));
};
const staticMethodDec2 = (fn, ctxStaticMethod) => {
log.push('M1');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M3'));
ctxStaticMethod.addInitializer(() => log.push('M4'));
};
// Field decorators
const fieldDec1 = (value, ctxField) => {
log.push('f2');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f5'));
ctxField.addInitializer(() => log.push('f6'));
return () => { log.push('f7'); };
};
const fieldDec2 = (value, ctxField) => {
log.push('f1');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f3'));
ctxField.addInitializer(() => log.push('f4'));
return () => { log.push('f8'); };
};
const staticFieldDec1 = (value, ctxStaticField) => {
log.push('F2');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F5'));
ctxStaticField.addInitializer(() => log.push('F6'));
return () => { log.push('F7'); };
};
const staticFieldDec2 = (value, ctxStaticField) => {
log.push('F1');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F3'));
ctxStaticField.addInitializer(() => log.push('F4'));
return () => { log.push('F8'); };
};
// Getter decorators
const getterDec1 = (fn, ctxGetter) => {
log.push('g2');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g5'));
ctxGetter.addInitializer(() => log.push('g6'));
};
const getterDec2 = (fn, ctxGetter) => {
log.push('g1');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g3'));
ctxGetter.addInitializer(() => log.push('g4'));
};
const staticGetterDec1 = (fn, ctxStaticGetter) => {
log.push('G2');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G5'));
ctxStaticGetter.addInitializer(() => log.push('G6'));
};
const staticGetterDec2 = (fn, ctxStaticGetter) => {
log.push('G1');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G3'));
ctxStaticGetter.addInitializer(() => log.push('G4'));
};
// Setter decorators
const setterDec1 = (fn, ctxSetter) => {
log.push('s2');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s5'));
ctxSetter.addInitializer(() => log.push('s6'));
};
const setterDec2 = (fn, ctxSetter) => {
log.push('s1');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s3'));
ctxSetter.addInitializer(() => log.push('s4'));
};
const staticSetterDec1 = (fn, ctxStaticSetter) => {
log.push('S2');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S5'));
ctxStaticSetter.addInitializer(() => log.push('S6'));
};
const staticSetterDec2 = (fn, ctxStaticSetter) => {
log.push('S1');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S3'));
ctxStaticSetter.addInitializer(() => log.push('S4'));
};
// Auto-accessor decorators
const accessorDec1 = (target, ctxAccessor) => {
log.push('a2');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a5'));
ctxAccessor.addInitializer(() => log.push('a6'));
return { init() { log.push('a7'); } };
};
const accessorDec2 = (target, ctxAccessor) => {
log.push('a1');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a3'));
ctxAccessor.addInitializer(() => log.push('a4'));
return { init() { log.push('a8'); } };
};
const staticAccessorDec1 = (target, ctxStaticAccessor) => {
log.push('A2');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A5'));
ctxStaticAccessor.addInitializer(() => log.push('A6'));
return { init() { log.push('A7'); } };
};
const staticAccessorDec2 = (target, ctxStaticAccessor) => {
log.push('A1');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A3'));
ctxStaticAccessor.addInitializer(() => log.push('A4'));
return { init() { log.push('A8'); } };
};
log.push('start');
const Foo =
@classDec1
@classDec2
class extends (log.push('extends'), Object) {
static { log.push('static:start'); }
constructor() {
log.push('ctor:start');
super();
log.push('ctor:end');
}
@methodDec1
@methodDec2
#method() { }
@staticMethodDec1
@staticMethodDec2
static #staticMethod() { }
@fieldDec1
@fieldDec2
#field;
@staticFieldDec1
@staticFieldDec2
static #staticField;
@getterDec1
@getterDec2
get #getter() { return; }
@staticGetterDec1
@staticGetterDec2
static get #staticGetter() { return; }
@setterDec1
@setterDec2
set #setter(x) { }
@staticSetterDec1
@staticSetterDec2
static set #staticSetter(x) { }
@accessorDec1
@accessorDec2
accessor #accessor;
@staticAccessorDec1
@staticAccessorDec2
static accessor #staticAccessor;
static { log.push('static:end'); }
};
log.push('after');
new Foo;
log.push('end');
assertEq(() => log + '', 'start,extends,' +
'M1,M2,G1,G2,S1,S2,A1,A2,' + // For each element e of staticElements if e.[[Kind]] is not field
'm1,m2,g1,g2,s1,s2,a1,a2,' + // For each element e of instanceElements if e.[[Kind]] is not field
'F1,F2,' + // For each element e of staticElements if e.[[Kind]] is field
'f1,f2,' + // For each element e of instanceElements if e.[[Kind]] is field
'c1,c2,' + // ApplyDecoratorsToClassDefinition
'M3,M4,M5,M6,G3,G4,G5,G6,S3,S4,S5,S6,' + // For each element initializer of staticMethodExtraInitializers
'static:start,' + // For each element elementRecord of staticElements
'F7,F8,F3,F4,F5,F6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'A7,A8,A3,A4,A5,A6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'static:end,' + // For each element elementRecord of staticElements
'c3,c4,c5,c6,' + // For each element initializer of classExtraInitializers
'after,' +
'ctor:start,' +
'm3,m4,m5,m6,g3,g4,g5,g6,s3,s4,s5,s6,' + // For each element initializer of constructor.[[Initializers]] (a.k.a. instanceMethodExtraInitializers)
'f7,f8,f3,f4,f5,f6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'a7,a8,a3,a4,a5,a6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'ctor:end,' +
'end');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Initializer-order-private-members,-class-statement.js | JavaScript | (() => {
const log = [];
// Class decorators
const classDec1 = (cls, ctxClass) => {
log.push('c2');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c5'));
ctxClass.addInitializer(() => log.push('c6'));
};
const classDec2 = (cls, ctxClass) => {
log.push('c1');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c3'));
ctxClass.addInitializer(() => log.push('c4'));
};
// Method decorators
const methodDec1 = (fn, ctxMethod) => {
log.push('m2');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m5'));
ctxMethod.addInitializer(() => log.push('m6'));
};
const methodDec2 = (fn, ctxMethod) => {
log.push('m1');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m3'));
ctxMethod.addInitializer(() => log.push('m4'));
};
const staticMethodDec1 = (fn, ctxStaticMethod) => {
log.push('M2');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M5'));
ctxStaticMethod.addInitializer(() => log.push('M6'));
};
const staticMethodDec2 = (fn, ctxStaticMethod) => {
log.push('M1');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M3'));
ctxStaticMethod.addInitializer(() => log.push('M4'));
};
// Field decorators
const fieldDec1 = (value, ctxField) => {
log.push('f2');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f5'));
ctxField.addInitializer(() => log.push('f6'));
return () => { log.push('f7'); };
};
const fieldDec2 = (value, ctxField) => {
log.push('f1');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f3'));
ctxField.addInitializer(() => log.push('f4'));
return () => { log.push('f8'); };
};
const staticFieldDec1 = (value, ctxStaticField) => {
log.push('F2');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F5'));
ctxStaticField.addInitializer(() => log.push('F6'));
return () => { log.push('F7'); };
};
const staticFieldDec2 = (value, ctxStaticField) => {
log.push('F1');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F3'));
ctxStaticField.addInitializer(() => log.push('F4'));
return () => { log.push('F8'); };
};
// Getter decorators
const getterDec1 = (fn, ctxGetter) => {
log.push('g2');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g5'));
ctxGetter.addInitializer(() => log.push('g6'));
};
const getterDec2 = (fn, ctxGetter) => {
log.push('g1');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g3'));
ctxGetter.addInitializer(() => log.push('g4'));
};
const staticGetterDec1 = (fn, ctxStaticGetter) => {
log.push('G2');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G5'));
ctxStaticGetter.addInitializer(() => log.push('G6'));
};
const staticGetterDec2 = (fn, ctxStaticGetter) => {
log.push('G1');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G3'));
ctxStaticGetter.addInitializer(() => log.push('G4'));
};
// Setter decorators
const setterDec1 = (fn, ctxSetter) => {
log.push('s2');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s5'));
ctxSetter.addInitializer(() => log.push('s6'));
};
const setterDec2 = (fn, ctxSetter) => {
log.push('s1');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s3'));
ctxSetter.addInitializer(() => log.push('s4'));
};
const staticSetterDec1 = (fn, ctxStaticSetter) => {
log.push('S2');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S5'));
ctxStaticSetter.addInitializer(() => log.push('S6'));
};
const staticSetterDec2 = (fn, ctxStaticSetter) => {
log.push('S1');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S3'));
ctxStaticSetter.addInitializer(() => log.push('S4'));
};
// Auto-accessor decorators
const accessorDec1 = (target, ctxAccessor) => {
log.push('a2');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a5'));
ctxAccessor.addInitializer(() => log.push('a6'));
return { init() { log.push('a7'); } };
};
const accessorDec2 = (target, ctxAccessor) => {
log.push('a1');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a3'));
ctxAccessor.addInitializer(() => log.push('a4'));
return { init() { log.push('a8'); } };
};
const staticAccessorDec1 = (target, ctxStaticAccessor) => {
log.push('A2');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A5'));
ctxStaticAccessor.addInitializer(() => log.push('A6'));
return { init() { log.push('A7'); } };
};
const staticAccessorDec2 = (target, ctxStaticAccessor) => {
log.push('A1');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A3'));
ctxStaticAccessor.addInitializer(() => log.push('A4'));
return { init() { log.push('A8'); } };
};
log.push('start');
@classDec1
@classDec2
class Foo extends (log.push('extends'), Object) {
static { log.push('static:start'); }
constructor() {
log.push('ctor:start');
super();
log.push('ctor:end');
}
@methodDec1
@methodDec2
#method() { }
@staticMethodDec1
@staticMethodDec2
static #staticMethod() { }
@fieldDec1
@fieldDec2
#field;
@staticFieldDec1
@staticFieldDec2
static #staticField;
@getterDec1
@getterDec2
get #getter() { return; }
@staticGetterDec1
@staticGetterDec2
static get #staticGetter() { return; }
@setterDec1
@setterDec2
set #setter(x) { }
@staticSetterDec1
@staticSetterDec2
static set #staticSetter(x) { }
@accessorDec1
@accessorDec2
accessor #accessor;
@staticAccessorDec1
@staticAccessorDec2
static accessor #staticAccessor;
static { log.push('static:end'); }
}
log.push('after');
new Foo;
log.push('end');
assertEq(() => log + '', 'start,extends,' +
'M1,M2,G1,G2,S1,S2,A1,A2,' + // For each element e of staticElements if e.[[Kind]] is not field
'm1,m2,g1,g2,s1,s2,a1,a2,' + // For each element e of instanceElements if e.[[Kind]] is not field
'F1,F2,' + // For each element e of staticElements if e.[[Kind]] is field
'f1,f2,' + // For each element e of instanceElements if e.[[Kind]] is field
'c1,c2,' + // ApplyDecoratorsToClassDefinition
'M3,M4,M5,M6,G3,G4,G5,G6,S3,S4,S5,S6,' + // For each element initializer of staticMethodExtraInitializers
'static:start,' + // For each element elementRecord of staticElements
'F7,F8,F3,F4,F5,F6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'A7,A8,A3,A4,A5,A6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'static:end,' + // For each element elementRecord of staticElements
'c3,c4,c5,c6,' + // For each element initializer of classExtraInitializers
'after,' +
'ctor:start,' +
'm3,m4,m5,m6,g3,g4,g5,g6,s3,s4,s5,s6,' + // For each element initializer of constructor.[[Initializers]] (a.k.a. instanceMethodExtraInitializers)
'f7,f8,f3,f4,f5,f6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'a7,a8,a3,a4,a5,a6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'ctor:end,' +
'end');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Initializer-order-public-members,-class-expression.js | JavaScript | (() => {
const log = [];
// Class decorators
const classDec1 = (cls, ctxClass) => {
log.push('c2');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c5'));
ctxClass.addInitializer(() => log.push('c6'));
};
const classDec2 = (cls, ctxClass) => {
log.push('c1');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c3'));
ctxClass.addInitializer(() => log.push('c4'));
};
// Method decorators
const methodDec1 = (fn, ctxMethod) => {
log.push('m2');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m5'));
ctxMethod.addInitializer(() => log.push('m6'));
};
const methodDec2 = (fn, ctxMethod) => {
log.push('m1');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m3'));
ctxMethod.addInitializer(() => log.push('m4'));
};
const staticMethodDec1 = (fn, ctxStaticMethod) => {
log.push('M2');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M5'));
ctxStaticMethod.addInitializer(() => log.push('M6'));
};
const staticMethodDec2 = (fn, ctxStaticMethod) => {
log.push('M1');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M3'));
ctxStaticMethod.addInitializer(() => log.push('M4'));
};
// Field decorators
const fieldDec1 = (value, ctxField) => {
log.push('f2');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f5'));
ctxField.addInitializer(() => log.push('f6'));
return () => { log.push('f7'); };
};
const fieldDec2 = (value, ctxField) => {
log.push('f1');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f3'));
ctxField.addInitializer(() => log.push('f4'));
return () => { log.push('f8'); };
};
const staticFieldDec1 = (value, ctxStaticField) => {
log.push('F2');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F5'));
ctxStaticField.addInitializer(() => log.push('F6'));
return () => { log.push('F7'); };
};
const staticFieldDec2 = (value, ctxStaticField) => {
log.push('F1');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F3'));
ctxStaticField.addInitializer(() => log.push('F4'));
return () => { log.push('F8'); };
};
// Getter decorators
const getterDec1 = (fn, ctxGetter) => {
log.push('g2');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g5'));
ctxGetter.addInitializer(() => log.push('g6'));
};
const getterDec2 = (fn, ctxGetter) => {
log.push('g1');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g3'));
ctxGetter.addInitializer(() => log.push('g4'));
};
const staticGetterDec1 = (fn, ctxStaticGetter) => {
log.push('G2');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G5'));
ctxStaticGetter.addInitializer(() => log.push('G6'));
};
const staticGetterDec2 = (fn, ctxStaticGetter) => {
log.push('G1');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G3'));
ctxStaticGetter.addInitializer(() => log.push('G4'));
};
// Setter decorators
const setterDec1 = (fn, ctxSetter) => {
log.push('s2');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s5'));
ctxSetter.addInitializer(() => log.push('s6'));
};
const setterDec2 = (fn, ctxSetter) => {
log.push('s1');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s3'));
ctxSetter.addInitializer(() => log.push('s4'));
};
const staticSetterDec1 = (fn, ctxStaticSetter) => {
log.push('S2');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S5'));
ctxStaticSetter.addInitializer(() => log.push('S6'));
};
const staticSetterDec2 = (fn, ctxStaticSetter) => {
log.push('S1');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S3'));
ctxStaticSetter.addInitializer(() => log.push('S4'));
};
// Auto-accessor decorators
const accessorDec1 = (target, ctxAccessor) => {
log.push('a2');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a5'));
ctxAccessor.addInitializer(() => log.push('a6'));
return { init() { log.push('a7'); } };
};
const accessorDec2 = (target, ctxAccessor) => {
log.push('a1');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a3'));
ctxAccessor.addInitializer(() => log.push('a4'));
return { init() { log.push('a8'); } };
};
const staticAccessorDec1 = (target, ctxStaticAccessor) => {
log.push('A2');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A5'));
ctxStaticAccessor.addInitializer(() => log.push('A6'));
return { init() { log.push('A7'); } };
};
const staticAccessorDec2 = (target, ctxStaticAccessor) => {
log.push('A1');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A3'));
ctxStaticAccessor.addInitializer(() => log.push('A4'));
return { init() { log.push('A8'); } };
};
log.push('start');
const Foo =
@classDec1
@classDec2
class extends (log.push('extends'), Object) {
static { log.push('static:start'); }
constructor() {
log.push('ctor:start');
super();
log.push('ctor:end');
}
@methodDec1
@methodDec2
method() { }
@staticMethodDec1
@staticMethodDec2
static method() { }
@fieldDec1
@fieldDec2
field;
@staticFieldDec1
@staticFieldDec2
static field;
@getterDec1
@getterDec2
get getter() { return; }
@staticGetterDec1
@staticGetterDec2
static get getter() { return; }
@setterDec1
@setterDec2
set setter(x) { }
@staticSetterDec1
@staticSetterDec2
static set setter(x) { }
@accessorDec1
@accessorDec2
accessor accessor;
@staticAccessorDec1
@staticAccessorDec2
static accessor accessor;
static { log.push('static:end'); }
};
log.push('after');
new Foo;
log.push('end');
assertEq(() => log + '', 'start,extends,' +
'M1,M2,G1,G2,S1,S2,A1,A2,' + // For each element e of staticElements if e.[[Kind]] is not field
'm1,m2,g1,g2,s1,s2,a1,a2,' + // For each element e of instanceElements if e.[[Kind]] is not field
'F1,F2,' + // For each element e of staticElements if e.[[Kind]] is field
'f1,f2,' + // For each element e of instanceElements if e.[[Kind]] is field
'c1,c2,' + // ApplyDecoratorsToClassDefinition
'M3,M4,M5,M6,G3,G4,G5,G6,S3,S4,S5,S6,' + // For each element initializer of staticMethodExtraInitializers
'static:start,' + // For each element elementRecord of staticElements
'F7,F8,F3,F4,F5,F6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'A7,A8,A3,A4,A5,A6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'static:end,' + // For each element elementRecord of staticElements
'c3,c4,c5,c6,' + // For each element initializer of classExtraInitializers
'after,' +
'ctor:start,' +
'm3,m4,m5,m6,g3,g4,g5,g6,s3,s4,s5,s6,' + // For each element initializer of constructor.[[Initializers]] (a.k.a. instanceMethodExtraInitializers)
'f7,f8,f3,f4,f5,f6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'a7,a8,a3,a4,a5,a6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'ctor:end,' +
'end');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Initializer-order-public-members,-class-statement.js | JavaScript | (() => {
const log = [];
// Class decorators
const classDec1 = (cls, ctxClass) => {
log.push('c2');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c5'));
ctxClass.addInitializer(() => log.push('c6'));
};
const classDec2 = (cls, ctxClass) => {
log.push('c1');
if (!assertEq(() => typeof ctxClass.addInitializer, 'function'))
return;
ctxClass.addInitializer(() => log.push('c3'));
ctxClass.addInitializer(() => log.push('c4'));
};
// Method decorators
const methodDec1 = (fn, ctxMethod) => {
log.push('m2');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m5'));
ctxMethod.addInitializer(() => log.push('m6'));
};
const methodDec2 = (fn, ctxMethod) => {
log.push('m1');
if (!assertEq(() => typeof ctxMethod.addInitializer, 'function'))
return;
ctxMethod.addInitializer(() => log.push('m3'));
ctxMethod.addInitializer(() => log.push('m4'));
};
const staticMethodDec1 = (fn, ctxStaticMethod) => {
log.push('M2');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M5'));
ctxStaticMethod.addInitializer(() => log.push('M6'));
};
const staticMethodDec2 = (fn, ctxStaticMethod) => {
log.push('M1');
if (!assertEq(() => typeof ctxStaticMethod.addInitializer, 'function'))
return;
ctxStaticMethod.addInitializer(() => log.push('M3'));
ctxStaticMethod.addInitializer(() => log.push('M4'));
};
// Field decorators
const fieldDec1 = (value, ctxField) => {
log.push('f2');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f5'));
ctxField.addInitializer(() => log.push('f6'));
return () => { log.push('f7'); };
};
const fieldDec2 = (value, ctxField) => {
log.push('f1');
if (!assertEq(() => typeof ctxField.addInitializer, 'function'))
return;
ctxField.addInitializer(() => log.push('f3'));
ctxField.addInitializer(() => log.push('f4'));
return () => { log.push('f8'); };
};
const staticFieldDec1 = (value, ctxStaticField) => {
log.push('F2');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F5'));
ctxStaticField.addInitializer(() => log.push('F6'));
return () => { log.push('F7'); };
};
const staticFieldDec2 = (value, ctxStaticField) => {
log.push('F1');
if (!assertEq(() => typeof ctxStaticField.addInitializer, 'function'))
return;
ctxStaticField.addInitializer(() => log.push('F3'));
ctxStaticField.addInitializer(() => log.push('F4'));
return () => { log.push('F8'); };
};
// Getter decorators
const getterDec1 = (fn, ctxGetter) => {
log.push('g2');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g5'));
ctxGetter.addInitializer(() => log.push('g6'));
};
const getterDec2 = (fn, ctxGetter) => {
log.push('g1');
if (!assertEq(() => typeof ctxGetter.addInitializer, 'function'))
return;
ctxGetter.addInitializer(() => log.push('g3'));
ctxGetter.addInitializer(() => log.push('g4'));
};
const staticGetterDec1 = (fn, ctxStaticGetter) => {
log.push('G2');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G5'));
ctxStaticGetter.addInitializer(() => log.push('G6'));
};
const staticGetterDec2 = (fn, ctxStaticGetter) => {
log.push('G1');
if (!assertEq(() => typeof ctxStaticGetter.addInitializer, 'function'))
return;
ctxStaticGetter.addInitializer(() => log.push('G3'));
ctxStaticGetter.addInitializer(() => log.push('G4'));
};
// Setter decorators
const setterDec1 = (fn, ctxSetter) => {
log.push('s2');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s5'));
ctxSetter.addInitializer(() => log.push('s6'));
};
const setterDec2 = (fn, ctxSetter) => {
log.push('s1');
if (!assertEq(() => typeof ctxSetter.addInitializer, 'function'))
return;
ctxSetter.addInitializer(() => log.push('s3'));
ctxSetter.addInitializer(() => log.push('s4'));
};
const staticSetterDec1 = (fn, ctxStaticSetter) => {
log.push('S2');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S5'));
ctxStaticSetter.addInitializer(() => log.push('S6'));
};
const staticSetterDec2 = (fn, ctxStaticSetter) => {
log.push('S1');
if (!assertEq(() => typeof ctxStaticSetter.addInitializer, 'function'))
return;
ctxStaticSetter.addInitializer(() => log.push('S3'));
ctxStaticSetter.addInitializer(() => log.push('S4'));
};
// Auto-accessor decorators
const accessorDec1 = (target, ctxAccessor) => {
log.push('a2');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a5'));
ctxAccessor.addInitializer(() => log.push('a6'));
return { init() { log.push('a7'); } };
};
const accessorDec2 = (target, ctxAccessor) => {
log.push('a1');
if (!assertEq(() => typeof ctxAccessor.addInitializer, 'function'))
return;
ctxAccessor.addInitializer(() => log.push('a3'));
ctxAccessor.addInitializer(() => log.push('a4'));
return { init() { log.push('a8'); } };
};
const staticAccessorDec1 = (target, ctxStaticAccessor) => {
log.push('A2');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A5'));
ctxStaticAccessor.addInitializer(() => log.push('A6'));
return { init() { log.push('A7'); } };
};
const staticAccessorDec2 = (target, ctxStaticAccessor) => {
log.push('A1');
if (!assertEq(() => typeof ctxStaticAccessor.addInitializer, 'function'))
return;
ctxStaticAccessor.addInitializer(() => log.push('A3'));
ctxStaticAccessor.addInitializer(() => log.push('A4'));
return { init() { log.push('A8'); } };
};
log.push('start');
@classDec1
@classDec2
class Foo extends (log.push('extends'), Object) {
static { log.push('static:start'); }
constructor() {
log.push('ctor:start');
super();
log.push('ctor:end');
}
@methodDec1
@methodDec2
method() { }
@staticMethodDec1
@staticMethodDec2
static method() { }
@fieldDec1
@fieldDec2
field;
@staticFieldDec1
@staticFieldDec2
static field;
@getterDec1
@getterDec2
get getter() { return; }
@staticGetterDec1
@staticGetterDec2
static get getter() { return; }
@setterDec1
@setterDec2
set setter(x) { }
@staticSetterDec1
@staticSetterDec2
static set setter(x) { }
@accessorDec1
@accessorDec2
accessor accessor;
@staticAccessorDec1
@staticAccessorDec2
static accessor accessor;
static { log.push('static:end'); }
}
log.push('after');
new Foo;
log.push('end');
assertEq(() => log + '', 'start,extends,' +
'M1,M2,G1,G2,S1,S2,A1,A2,' + // For each element e of staticElements if e.[[Kind]] is not field
'm1,m2,g1,g2,s1,s2,a1,a2,' + // For each element e of instanceElements if e.[[Kind]] is not field
'F1,F2,' + // For each element e of staticElements if e.[[Kind]] is field
'f1,f2,' + // For each element e of instanceElements if e.[[Kind]] is field
'c1,c2,' + // ApplyDecoratorsToClassDefinition
'M3,M4,M5,M6,G3,G4,G5,G6,S3,S4,S5,S6,' + // For each element initializer of staticMethodExtraInitializers
'static:start,' + // For each element elementRecord of staticElements
'F7,F8,F3,F4,F5,F6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'A7,A8,A3,A4,A5,A6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'static:end,' + // For each element elementRecord of staticElements
'c3,c4,c5,c6,' + // For each element initializer of classExtraInitializers
'after,' +
'ctor:start,' +
'm3,m4,m5,m6,g3,g4,g5,g6,s3,s4,s5,s6,' + // For each element initializer of constructor.[[Initializers]] (a.k.a. instanceMethodExtraInitializers)
'f7,f8,f3,f4,f5,f6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'a7,a8,a3,a4,a5,a6,' + // InitializeFieldOrAccessor + For each element initializer of elementRecord.[[ExtraInitializers]]
'ctor:end,' +
'end');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Basic-instance-method.js | JavaScript | (() => {
const old = {};
const dec = (key, name) => (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, name);
assertEq(() => ctx.kind, 'method');
assertEq(() => ctx.name, key);
assertEq(() => ctx.static, false);
assertEq(() => ctx.private, false);
assertEq(() => ctx.access.has({ [key]: false }), true);
assertEq(() => ctx.access.has({ bar: true }), false);
assertEq(() => ctx.access.get({ [key]: 123 }), 123);
assertEq(() => 'set' in ctx.access, false);
old[key] = fn;
};
const bar = Symbol('bar');
const baz = Symbol();
class Foo {
@dec('foo', 'foo')
foo() { }
@dec(bar, '[bar]')
[bar]() { }
@dec(baz, '')
[baz]() { }
}
assertEq(() => Foo.prototype.foo, old['foo']);
assertEq(() => Foo.prototype[bar], old[bar]);
assertEq(() => Foo.prototype[baz], old[baz]);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Basic-private-instance-method.js | JavaScript | (() => {
let old;
let lateAsserts;
const dec = (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, '#foo');
assertEq(() => ctx.kind, 'method');
assertEq(() => ctx.name, '#foo');
assertEq(() => ctx.static, false);
assertEq(() => ctx.private, true);
lateAsserts = () => {
assertEq(() => ctx.access.has(new Foo), true);
assertEq(() => ctx.access.has({}), false);
assertEq(() => ctx.access.get(new Foo), $foo);
assertEq(() => 'set' in ctx.access, false);
};
old = fn;
};
let $foo;
class Foo {
@dec
#foo() { }
static { $foo = new Foo().#foo; }
}
assertEq(() => $foo, old);
lateAsserts();
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Basic-private-static-method.js | JavaScript | (() => {
let old;
let lateAsserts;
const dec = (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, '#foo');
assertEq(() => ctx.kind, 'method');
assertEq(() => ctx.name, '#foo');
assertEq(() => ctx.static, true);
assertEq(() => ctx.private, true);
lateAsserts = () => {
assertEq(() => ctx.access.has(Foo), true);
assertEq(() => ctx.access.has({}), false);
assertEq(() => ctx.access.get(Foo), $foo);
assertEq(() => 'set' in ctx.access, false);
};
old = fn;
};
let $foo;
class Foo {
@dec
static #foo() { }
static { $foo = this.#foo; }
}
assertEq(() => $foo, old);
lateAsserts();
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Basic-static-method.js | JavaScript | (() => {
const old = {};
const dec = (key, name) => (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, name);
assertEq(() => ctx.kind, 'method');
assertEq(() => ctx.name, key);
assertEq(() => ctx.static, true);
assertEq(() => ctx.private, false);
assertEq(() => ctx.access.has({ [key]: false }), true);
assertEq(() => ctx.access.has({ bar: true }), false);
assertEq(() => ctx.access.get({ [key]: 123 }), 123);
assertEq(() => 'set' in ctx.access, false);
old[key] = fn;
};
const bar = Symbol('bar');
const baz = Symbol();
class Foo {
@dec('foo', 'foo')
static foo() { }
@dec(bar, '[bar]')
static [bar]() { }
@dec(baz, '')
static [baz]() { }
}
assertEq(() => Foo.foo, old['foo']);
assertEq(() => Foo[bar], old[bar]);
assertEq(() => Foo[baz], old[baz]);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Extra-initializer-instance-method.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
foo() { }
}
assertEq(() => got, undefined);
const instance = new Foo;
assertEq(() => got.this, instance);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Extra-initializer-private-instance-method.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
#foo() { }
}
assertEq(() => got, undefined);
const instance = new Foo;
assertEq(() => got.this, instance);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Extra-initializer-private-static-method.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
static #foo() { }
}
assertEq(() => got.this, Foo);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Extra-initializer-static-method.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
static foo() { }
}
assertEq(() => got.this, Foo);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Order-instance-method.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function () {
log.push(4);
return fn.call(this);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function () {
log.push(5);
return fn.call(this);
};
return baz;
};
log.push(0);
class Foo {
@dec1
@dec2
foo() { return log.push(6); }
}
log.push(3);
new Foo().foo();
log.push(7);
assertEq(() => Foo.prototype.foo, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Order-private-instance-method.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function () {
log.push(4);
return fn.call(this);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function () {
log.push(5);
return fn.call(this);
};
return baz;
};
log.push(0);
let $foo;
class Foo {
@dec1
@dec2
#foo() { return log.push(6); }
static { $foo = new Foo().#foo; }
}
log.push(3);
$foo.call(new Foo);
log.push(7);
assertEq(() => $foo, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Order-private-static-method.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function () {
log.push(4);
return fn.call(this);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function () {
log.push(5);
return fn.call(this);
};
return baz;
};
log.push(0);
let $foo;
class Foo {
@dec1
@dec2
static #foo() { return log.push(6); }
static { $foo = Foo.#foo; }
}
log.push(3);
$foo.call(Foo);
log.push(7);
assertEq(() => $foo, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Order-static-method.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function () {
log.push(4);
return fn.call(this);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function () {
log.push(5);
return fn.call(this);
};
return baz;
};
log.push(0);
class Foo {
@dec1
@dec2
static foo() { return log.push(6); }
}
log.push(3);
Foo.foo();
log.push(7);
assertEq(() => Foo.foo, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-null-instance-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-null-private-instance-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
#foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-null-private-static-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
static #foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-null-static-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
static foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-object-instance-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-object-private-instance-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
#foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-object-private-static-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static #foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Return-object-static-method.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static foo() { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Shim-instance-method.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
class Foo {
bar = 123;
@dec
foo() { return this.bar; }
}
assertEq(() => Foo.prototype.foo, bar);
assertEq(() => new Foo().foo(), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Shim-private-instance-method.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
let $foo;
class Foo {
bar = 123;
@dec
#foo() { return this.bar; }
static { $foo = new Foo().#foo; }
}
assertEq(() => $foo, bar);
assertEq(() => bar.call(new Foo), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Shim-private-static-method.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
let $foo;
class Foo {
static bar = 123;
@dec
static #foo() { return this.bar; }
static { $foo = this.#foo; }
}
assertEq(() => $foo, bar);
assertEq(() => bar.call(Foo), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Method-decorators-Shim-static-method.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function () { return fn.call(this) + 1; };
return bar;
};
class Foo {
static bar = 123;
@dec
static foo() { return this.bar; }
}
assertEq(() => Foo.foo, bar);
assertEq(() => Foo.foo(), 124);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Basic-instance-setter.js | JavaScript | (() => {
const dec = (key, name) => (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, name);
assertEq(() => ctx.kind, 'setter');
assertEq(() => ctx.name, key);
assertEq(() => ctx.static, false);
assertEq(() => ctx.private, false);
assertEq(() => ctx.access.has({ [key]: false }), true);
assertEq(() => ctx.access.has({ bar: true }), false);
assertEq(() => 'get' in ctx.access, false);
const obj = {};
ctx.access.set(obj, 123);
assertEq(() => obj[key], 123);
assertEq(() => 'bar' in obj, false);
};
const bar = Symbol('bar');
const baz = Symbol();
class Foo {
bar = 0;
@dec('foo', 'set foo')
set foo(x) { this.bar = x; }
@dec(bar, 'set [bar]')
set [bar](x) { this.bar = x; }
@dec(baz, 'set ')
set [baz](x) { this.bar = x; }
}
var obj = new Foo;
obj.foo = 321;
assertEq(() => obj.bar, 321);
obj[bar] = 4321;
assertEq(() => obj.bar, 4321);
obj[baz] = 54321;
assertEq(() => obj.bar, 54321);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Basic-private-instance-setter.js | JavaScript | (() => {
let lateAsserts;
const dec = (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, 'set #foo');
assertEq(() => ctx.kind, 'setter');
assertEq(() => ctx.name, '#foo');
assertEq(() => ctx.static, false);
assertEq(() => ctx.private, true);
lateAsserts = () => {
assertEq(() => ctx.access.has(new Foo), true);
assertEq(() => ctx.access.has({}), false);
assertEq(() => 'get' in ctx.access, false);
assertEq(() => {
const obj = new Foo;
ctx.access.set(obj, 123);
return obj.bar;
}, 123);
};
};
let set$foo;
class Foo {
bar = 0;
@dec
set #foo(x) { this.bar = x; }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
lateAsserts();
var obj = new Foo;
assertEq(() => set$foo(obj, 321), undefined);
assertEq(() => obj.bar, 321);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Basic-private-static-setter.js | JavaScript | (() => {
let lateAsserts;
const dec = (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, 'set #foo');
assertEq(() => ctx.kind, 'setter');
assertEq(() => ctx.name, '#foo');
assertEq(() => ctx.static, true);
assertEq(() => ctx.private, true);
lateAsserts = () => {
assertEq(() => ctx.access.has(Foo), true);
assertEq(() => ctx.access.has({}), false);
assertEq(() => 'get' in ctx.access, false);
assertEq(() => {
ctx.access.set(Foo, 123);
return Foo.bar;
}, 123);
};
};
let set$foo;
class Foo {
static bar = 0;
@dec
static set #foo(x) { this.bar = x; }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
lateAsserts();
assertEq(() => set$foo(Foo, 321), undefined);
assertEq(() => Foo.bar, 321);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Basic-static-setter.js | JavaScript | (() => {
const dec = (key, name) => (fn, ctx) => {
assertEq(() => typeof fn, 'function');
assertEq(() => fn.name, name);
assertEq(() => ctx.kind, 'setter');
assertEq(() => ctx.name, key);
assertEq(() => ctx.static, true);
assertEq(() => ctx.private, false);
assertEq(() => ctx.access.has({ [key]: false }), true);
assertEq(() => ctx.access.has({ bar: true }), false);
assertEq(() => 'get' in ctx.access, false);
const obj = {};
ctx.access.set(obj, 123);
assertEq(() => obj[key], 123);
assertEq(() => 'bar' in obj, false);
};
const bar = Symbol('bar');
const baz = Symbol();
class Foo {
static bar = 0;
@dec('foo', 'set foo')
static set foo(x) { this.bar = x; }
@dec(bar, 'set [bar]')
static set [bar](x) { this.bar = x; }
@dec(baz, 'set ')
static set [baz](x) { this.bar = x; }
}
Foo.foo = 321;
assertEq(() => Foo.bar, 321);
Foo[bar] = 4321;
assertEq(() => Foo.bar, 4321);
Foo[baz] = 54321;
assertEq(() => Foo.bar, 54321);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Extra-initializer-instance-setter.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
set foo(x) { }
}
assertEq(() => got, undefined);
const instance = new Foo;
assertEq(() => got.this, instance);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Extra-initializer-private-instance-setter.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
set #foo(x) { }
}
assertEq(() => got, undefined);
const instance = new Foo;
assertEq(() => got.this, instance);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Extra-initializer-private-static-setter.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
static set #foo(x) { }
}
assertEq(() => got.this, Foo);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Extra-initializer-static-setter.js | JavaScript | (() => {
let oldAddInitializer;
let got;
const dec = (fn, ctx) => {
ctx.addInitializer(function (...args) {
got = { this: this, args };
});
if (oldAddInitializer)
assertThrows(() => oldAddInitializer(() => { }), TypeError);
assertThrows(() => ctx.addInitializer({}), TypeError);
oldAddInitializer = ctx.addInitializer;
};
class Foo {
@dec
@dec
static set foo(x) { }
}
assertEq(() => got.this, Foo);
assertEq(() => got.args.length, 0);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Order-instance-setter.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function (x) {
log.push(4);
fn.call(this, x);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function (x) {
log.push(5);
fn.call(this, x);
};
return baz;
};
log.push(0);
class Foo {
@dec1
@dec2
set foo(x) { log.push(6); }
}
log.push(3);
new Foo().foo = 123;
log.push(7);
assertEq(() => Object.getOwnPropertyDescriptor(Foo.prototype, 'foo').set, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Order-private-instance-setter.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function (x) {
log.push(4);
fn.call(this, x);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function (x) {
log.push(5);
fn.call(this, x);
};
return baz;
};
log.push(0);
let set$foo;
class Foo {
@dec1
@dec2
set #foo(x) { log.push(6); }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
log.push(3);
assertEq(() => set$foo(new Foo, 123), undefined);
log.push(7);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Order-private-static-setter.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function (x) {
log.push(4);
fn.call(this, x);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function (x) {
log.push(5);
fn.call(this, x);
};
return baz;
};
log.push(0);
let set$foo;
class Foo {
@dec1
@dec2
static set #foo(x) { log.push(6); }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
log.push(3);
assertEq(() => set$foo(Foo, 123), undefined);
log.push(7);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Order-static-setter.js | JavaScript | (() => {
const log = [];
let bar;
let baz;
const dec1 = (fn, ctx) => {
log.push(2);
bar = function (x) {
log.push(4);
fn.call(this, x);
};
return bar;
};
const dec2 = (fn, ctx) => {
log.push(1);
baz = function (x) {
log.push(5);
fn.call(this, x);
};
return baz;
};
log.push(0);
class Foo {
@dec1
@dec2
static set foo(x) { log.push(6); }
}
log.push(3);
Foo.foo = 123;
log.push(7);
assertEq(() => Object.getOwnPropertyDescriptor(Foo, 'foo').set, bar);
assertEq(() => log + '', '0,1,2,3,4,5,6,7');
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-null-instance-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
set foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-null-private-instance-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
set #foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-null-private-static-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
static set #foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-null-static-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return null;
};
class Foo {
@dec
static set foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-object-instance-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
set foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-object-private-instance-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
set #foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-object-private-static-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static set #foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Return-object-static-setter.js | JavaScript | (() => {
assertThrows(() => {
const dec = (fn, ctx) => {
return {};
};
class Foo {
@dec
static set foo(x) { }
}
}, TypeError);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Shim-instance-setter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function (x) { fn.call(this, x + 1); };
return bar;
};
class Foo {
bar = 123;
@dec
set foo(x) { this.bar = x; }
}
assertEq(() => Object.getOwnPropertyDescriptor(Foo.prototype, 'foo').set, bar);
var obj = new Foo;
obj.foo = 321;
assertEq(() => obj.bar, 322);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Shim-private-instance-setter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function (x) { fn.call(this, x + 1); };
return bar;
};
let set$foo;
class Foo {
bar = 123;
@dec
set #foo(x) { this.bar = x; }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
var obj = new Foo;
assertEq(() => set$foo(obj, 321), undefined);
assertEq(() => obj.bar, 322);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Shim-private-static-setter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function (x) { fn.call(this, x + 1); };
return bar;
};
let set$foo;
class Foo {
static bar = 123;
@dec
static set #foo(x) { this.bar = x; }
static { set$foo = (x, y) => { x.#foo = y; }; }
}
assertEq(() => set$foo(Foo, 321), undefined);
assertEq(() => Foo.bar, 322);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator-evanw-split/Setter-decorators-Shim-static-setter.js | JavaScript | (() => {
let bar;
const dec = (fn, ctx) => {
bar = function (x) { fn.call(this, x + 1); };
return bar;
};
class Foo {
static bar = 123;
@dec
static set foo(x) { this.bar = x; }
}
assertEq(() => Object.getOwnPropertyDescriptor(Foo, 'foo').set, bar);
Foo.foo = 321;
assertEq(() => Foo.bar, 322);
})();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorator_evanw.rs | Rust | use std::{fs, path::PathBuf};
use swc_ecma_parser::{EsSyntax, Syntax};
use swc_ecma_transforms_proposal::decorator_2022_03::decorator_2022_03;
use swc_ecma_transforms_testing::exec_tr;
const HELPERS: &str = r###"
function assertEq(callback, expected) {
let details;
try {
let x = callback();
if (x === expected)
return true;
details = ` Expected: ${prettyPrint(expected)}\n Observed: ${prettyPrint(x)}`;
}
catch (error) {
details = ` Throws: ${error}`;
}
const code = callback.toString().replace(/^\(\) => /, '').replace(/\s+/g, ' ');
console.log(`❌\n Code: ${code}\n${details}\n`);
return false;
}
function assertThrows(callback, expected) {
let details;
try {
let x = callback();
details = ` Expected: throws instanceof ${expected.name}\n Observed: returns ${prettyPrint(x)}`;
}
catch (error) {
if (error instanceof expected)
return true;
details = ` Expected: throws instanceof ${expected.name}\n Observed: throws ${error}`;
}
const code = callback.toString().replace(/^\(\) => /, '').replace(/\s+/g, ' ');
console.log(`❌\n Code: ${code}\n${details}\n`);
return false;
}
"###;
// TODO: Unignore tests
#[testing::fixture(
"tests/decorator-evanw-split/*.js",
exclude(
"Decorator-list-evaluation-await-class-statement.js",
"Decorator-list-evaluation-Inner-private-name-class-statement.js",
"Decorator-list-evaluation-Inner-private-name-class-expression.js"
)
)]
fn fixture(input: PathBuf) {
let code = fs::read_to_string(&input).unwrap();
let code = format!(
"{HELPERS}
{code}"
);
exec_tr(
&input.file_name().unwrap().to_string_lossy(),
Syntax::Es(EsSyntax {
decorators: true,
auto_accessors: true,
..Default::default()
}),
|_| decorator_2022_03(),
&code,
);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators.rs | Rust | #![allow(unused)]
use std::{
path::{Path, PathBuf},
rc::Rc,
};
use serde::Deserialize;
use swc_common::{comments::SingleThreadedComments, Mark};
use swc_ecma_ast::Pass;
use swc_ecma_parser::{EsSyntax, Syntax, TsSyntax};
use swc_ecma_transforms_base::{assumptions::Assumptions, resolver};
use swc_ecma_transforms_proposal::{decorator_2022_03::decorator_2022_03, DecoratorVersion};
use swc_ecma_transforms_testing::{test_fixture, FixtureTestConfig};
use swc_ecma_visit::Fold;
fn syntax_default() -> Syntax {
Syntax::Es(EsSyntax {
decorators: true,
auto_accessors: true,
allow_super_outside_method: true,
decorators_before_export: true,
explicit_resource_management: true,
..Default::default()
})
}
fn syntax_default_ts() -> Syntax {
Syntax::Typescript(TsSyntax {
decorators: true,
..Default::default()
})
}
#[testing::fixture("tests/decorators/**/exec.js")]
fn exec(input: PathBuf) {
exec_inner(input)
}
fn exec_inner(input: PathBuf) {
let code = std::fs::read_to_string(&input).unwrap();
swc_ecma_transforms_testing::exec_tr(
"decorator",
Syntax::Typescript(TsSyntax {
decorators: true,
..Default::default()
}),
|t| create_pass(t.comments.clone(), &input),
&code,
);
}
#[testing::fixture("tests/decorators/**/input.js")]
#[testing::fixture("tests/decorators/**/input.mjs")]
#[testing::fixture("tests/decorators/**/input.ts")]
fn fixture(input: PathBuf) {
fixture_inner(input)
}
fn fixture_inner(input: PathBuf) {
let src = std::fs::read_to_string(&input).unwrap();
let output = input.with_file_name(format!(
"output.{}",
input.extension().unwrap().to_string_lossy()
));
test_fixture(
if input.to_string_lossy().ends_with(".ts") {
syntax_default_ts()
} else {
syntax_default()
},
&|t| create_pass(t.comments.clone(), &input),
&input,
&output,
FixtureTestConfig {
allow_error: true,
module: Some(true),
..Default::default()
},
);
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct BabelTestOptions {
#[serde(default)]
assumptions: Assumptions,
#[serde(default)]
plugins: Vec<BabelPluginEntry>,
#[serde(default)]
min_node_version: String,
#[serde(default)]
throws: Option<String>,
}
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase", untagged)]
enum BabelPluginEntry {
NameOnly(String),
WithConfig(String, BabelPluginOption),
}
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields, untagged, rename_all = "camelCase")]
enum BabelPluginOption {
Decorator { version: DecoratorVersion },
}
fn create_pass(comments: Rc<SingleThreadedComments>, input: &Path) -> Box<dyn Pass> {
let options_json: BabelTestOptions =
swc_ecma_transforms_testing::parse_options(input.parent().unwrap());
let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
let mut pass: Box<dyn Pass> = Box::new(resolver(unresolved_mark, top_level_mark, false));
macro_rules! add {
($e:expr) => {{
pass = Box::new((pass, $e));
}};
}
let static_block_mark = Mark::new();
for plugin in &options_json.plugins {
match plugin {
BabelPluginEntry::NameOnly(name) => match &**name {
"proposal-class-properties" => {
add!(swc_ecma_transforms_compat::es2022::static_blocks());
add!(swc_ecma_transforms_compat::es2022::class_properties(
Default::default(),
unresolved_mark
));
continue;
}
"proposal-private-methods" => {
add!(swc_ecma_transforms_compat::es2022::class_properties(
Default::default(),
unresolved_mark
));
continue;
}
"proposal-class-static-block" => {
add!(swc_ecma_transforms_compat::es2022::static_blocks());
continue;
}
_ => {}
},
BabelPluginEntry::WithConfig(name, config) => match &**name {
"proposal-decorators" => match config {
BabelPluginOption::Decorator { version } => match version {
DecoratorVersion::V202311 => {
todo!()
}
DecoratorVersion::V202112 => todo!(),
DecoratorVersion::V202203 => {
add!(decorator_2022_03());
}
},
},
_ => {
panic!("Unknown plugin: {}", name);
}
},
}
dbg!(&plugin);
}
pass
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-nested-constructor-expression/input.js | JavaScript | const dec = () => {};
@dec
class Foo extends Bar {
constructor() {
let foo = super();
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-nested-constructor-expression/output.js | JavaScript | var _initClass;
const dec = () => { };
let _Foo;
class Foo extends Bar {
static {
[_Foo, _initClass] = _applyDecs2203R(this, [], [dec]).c;
}
constructor() {
let foo = super();
}
static {
_initClass();
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-private-accessor/input.js | JavaScript | const dec = () => {};
class Foo extends Bar {
@dec
get #x() {
return super.foo();
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-private-accessor/output.js | JavaScript | var _call_x, _initProto;
const dec = () => { };
class Foo extends Bar {
static {
[_call_x, _initProto] = _applyDecs2203R(this, [[dec, 3, "x", function () {
return Bar.prototype.foo.call(this);
}]], []).e;
}
constructor(...args) {
super(...args);
_initProto(this);
}
get #x() {
return _call_x(this);
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-private-method/input.js | JavaScript | const dec = () => {};
class Foo extends Bar {
@dec
#x() {
return super.foo();
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/.2022-03-assumption-constantSuper/super-in-private-method/output.js | JavaScript | var _call_x, _initProto;
const dec = () => { };
class Foo extends Bar {
static {
[_call_x, _initProto] = _applyDecs2203R(this, [[dec, 2, "x", function () {
return Bar.prototype.foo.call(this);
}]], []).e;
}
constructor(...args) {
super(...args);
_initProto(this);
}
#x = _call_x;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/private/exec.js | JavaScript | function dec({ get, set }, context) {
context.addInitializer(function() {
this[context.name + 'Context'] = context;
});
return {
get() {
return get.call(this) + 1;
},
set(v) {
set.call(this, v + 1);
},
init(v) {
return v ? v : 1;
}
}
}
class Foo {
@dec
accessor #a;
@dec
accessor #b = 123;
}
let foo = new Foo();
const aContext = foo['#aContext'];
const bContext = foo['#bContext'];
expect(aContext.access.get.call(foo)).toBe(2);
aContext.access.set.call(foo, 123);
expect(aContext.access.get.call(foo)).toBe(125);
expect(aContext.name).toBe('#a');
expect(aContext.kind).toBe('accessor');
expect(aContext.static).toBe(false);
expect(aContext.private).toBe(true);
expect(typeof aContext.addInitializer).toBe('function');
expect(bContext.access.get.call(foo)).toBe(124);
bContext.access.set.call(foo, 123);
expect(bContext.access.get.call(foo)).toBe(125);
expect(bContext.name).toBe('#b');
expect(bContext.kind).toBe('accessor');
expect(bContext.static).toBe(false);
expect(bContext.private).toBe(true);
expect(typeof bContext.addInitializer).toBe('function');
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/private/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
accessor #a;
@dec
accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/private/output.js | JavaScript | var _init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initProto;
const dec = ()=>{};
var ___a_1 = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b_2 = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
class Foo {
constructor(){
_class_private_field_init(this, _a, {
get: get_a,
set: set_a
});
_class_private_field_init(this, _b, {
get: get_b,
set: set_b
});
_class_private_field_init(this, ___a_1, {
writable: true,
value: (_initProto(this), _init_a(this))
});
_class_private_field_init(this, ___b_2, {
writable: true,
value: _init_b(this, 123)
});
}
}
({ e: [_init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initProto] } = _apply_decs_2203_r(Foo, [
[
dec,
1,
"a",
function() {
return _class_private_field_get(this, ___a_1);
},
function(_v) {
_class_private_field_set(this, ___a_1, _v);
}
],
[
dec,
1,
"b",
function() {
return _class_private_field_get(this, ___b_2);
},
function(_v) {
_class_private_field_set(this, ___b_2, _v);
}
]
], []));
function get_a() {
return _get___a(this);
}
function set_a(_v) {
_set___a(this, _v);
}
function get_b() {
return _get___b(this);
}
function set_b(_v) {
_set___b(this, _v);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/public/exec.js | JavaScript | function dec({ get, set }, context) {
context.addInitializer(function() {
this[context.name + 'Context'] = context;
});
return {
get() {
return get.call(this) + 1;
},
set(v) {
set.call(this, v + 1);
},
init(v) {
return v ? v : 1;
}
}
}
class Foo {
@dec
accessor a;
@dec
accessor b = 123;
@dec
accessor ['c'] = 456;
}
let foo = new Foo();
const aContext = foo['aContext'];
const bContext = foo['bContext'];
const cContext = foo['cContext'];
expect(foo.a).toBe(2);
expect(aContext.access.get.call(foo)).toBe(2);
foo.a = 123;
expect(foo.a).toBe(125);
expect(aContext.access.get.call(foo)).toBe(125);
aContext.access.set.call(foo, 456);
expect(foo.a).toBe(458);
expect(aContext.access.get.call(foo)).toBe(458);
expect(aContext.name).toBe('a');
expect(aContext.kind).toBe('accessor');
expect(aContext.static).toBe(false);
expect(aContext.private).toBe(false);
expect(typeof aContext.addInitializer).toBe('function');
expect(foo.hasOwnProperty('a')).toBe(false);
expect(Foo.prototype.hasOwnProperty('a')).toBe(true);
expect(foo.b).toBe(124);
foo.b = 123;
expect(foo.b).toBe(125);
expect(bContext.name).toBe('b');
expect(bContext.kind).toBe('accessor');
expect(bContext.static).toBe(false);
expect(bContext.private).toBe(false);
expect(typeof bContext.addInitializer).toBe('function');
expect(foo.hasOwnProperty('b')).toBe(false);
expect(Foo.prototype.hasOwnProperty('b')).toBe(true);
expect(foo.c).toBe(457);
foo.c = 456;
expect(foo.c).toBe(458);
expect(cContext.name).toBe('c');
expect(cContext.kind).toBe('accessor');
expect(cContext.static).toBe(false);
expect(cContext.private).toBe(false);
expect(typeof cContext.addInitializer).toBe('function');
expect(foo.hasOwnProperty('c')).toBe(false);
expect(Foo.prototype.hasOwnProperty('c')).toBe(true);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/public/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
accessor a;
@dec
accessor b = 123;
@dec
accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/public/output.js | JavaScript | var _init_a, _init_b, _computedKey, _init_computedKey, _initProto;
const dec = ()=>{};
_computedKey = 'c';
var ____private_a_1 = /*#__PURE__*/ new WeakMap(), ____private_b_2 = /*#__PURE__*/ new WeakMap(), ____private_computedKey_3 = /*#__PURE__*/ new WeakMap();
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
get a() {
return _class_private_field_get(this, ____private_a_1);
}
set a(_v) {
_class_private_field_set(this, ____private_a_1, _v);
}
get b() {
return _class_private_field_get(this, ____private_b_2);
}
set b(_v) {
_class_private_field_set(this, ____private_b_2, _v);
}
get [_computedKey1]() {
return _class_private_field_get(this, ____private_computedKey_3);
}
set [_computedKey2](_v) {
_class_private_field_set(this, ____private_computedKey_3, _v);
}
constructor(){
_class_private_field_init(this, ____private_a_1, {
writable: true,
value: (_initProto(this), _init_a(this))
});
_class_private_field_init(this, ____private_b_2, {
writable: true,
value: _init_b(this, 123)
});
_class_private_field_init(this, ____private_computedKey_3, {
writable: true,
value: _init_computedKey(this, 456)
});
}
}
({ e: [_init_a, _init_b, _init_computedKey, _initProto] } = _apply_decs_2203_r(Foo, [
[
dec,
1,
"a"
],
[
dec,
1,
"b"
],
[
dec,
1,
_computedKey
]
], []));
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-private/exec.js | JavaScript | function dec({ get, set }, context) {
context.addInitializer(function() {
this[context.name + 'Context'] = context;
});
return {
get() {
return get.call(this) + 1;
},
set(v) {
set.call(this, v + 1);
},
init(v) {
return v ? v : 1;
}
}
}
class Foo {
@dec
static accessor #a;
@dec
static accessor #b = 123;
}
const aContext = Foo['#aContext'];
const bContext = Foo['#bContext'];
expect(aContext.access.get.call(Foo)).toBe(2);
aContext.access.set.call(Foo, 123);
expect(aContext.access.get.call(Foo)).toBe(125);
expect(aContext.name).toBe('#a');
expect(aContext.kind).toBe('accessor');
expect(aContext.static).toBe(true);
expect(aContext.private).toBe(true);
expect(typeof aContext.addInitializer).toBe('function');
expect(bContext.access.get.call(Foo)).toBe(124);
bContext.access.set.call(Foo, 123);
expect(bContext.access.get.call(Foo)).toBe(125);
expect(bContext.name).toBe('#b');
expect(bContext.kind).toBe('accessor');
expect(bContext.static).toBe(true);
expect(bContext.private).toBe(true);
expect(typeof bContext.addInitializer).toBe('function');
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-private/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
static accessor #a;
@dec
static accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-private/output.js | JavaScript | var _init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initStatic;
const dec = ()=>{};
class Foo {
}
var _a = {
get: get_a,
set: set_a
};
var _b = {
get: get_b,
set: set_b
};
(()=>{
({ e: [_init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initStatic] } = _apply_decs_2203_r(Foo, [
[
dec,
6,
"a",
function() {
return _class_static_private_field_spec_get(this, Foo, ___a_1);
},
function(_v) {
_class_static_private_field_spec_set(this, Foo, ___a_1, _v);
}
],
[
dec,
6,
"b",
function() {
return _class_static_private_field_spec_get(this, Foo, ___b_2);
},
function(_v) {
_class_static_private_field_spec_set(this, Foo, ___b_2, _v);
}
]
], []));
_initStatic(Foo);
})();
var ___a_1 = {
writable: true,
value: _init_a(Foo)
};
var ___b_2 = {
writable: true,
value: _init_b(Foo, 123)
};
function get_a() {
return _get___a(this);
}
function set_a(_v) {
_set___a(this, _v);
}
function get_b() {
return _get___b(this);
}
function set_b(_v) {
_set___b(this, _v);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-public/exec.js | JavaScript | function dec({ get, set }, context) {
context.addInitializer(function() {
this[context.name + 'Context'] = context;
});
return {
get() {
return get.call(this) + 1;
},
set(v) {
set.call(this, v + 1);
},
init(v) {
return v ? v : 1;
}
}
}
class Foo {
@dec
static accessor a;
@dec
static accessor b = 123;
@dec
static accessor ['c'] = 456;
}
const aContext = Foo['aContext'];
const bContext = Foo['bContext'];
const cContext = Foo['cContext'];
expect(Foo.a).toBe(2);
expect(aContext.access.get.call(Foo)).toBe(2);
Foo.a = 123;
expect(Foo.a).toBe(125);
expect(aContext.access.get.call(Foo)).toBe(125);
aContext.access.set.call(Foo, 456);
expect(Foo.a).toBe(458);
expect(aContext.access.get.call(Foo)).toBe(458);
expect(aContext.name).toBe('a');
expect(aContext.kind).toBe('accessor');
expect(aContext.static).toBe(true);
expect(aContext.private).toBe(false);
expect(typeof aContext.addInitializer).toBe('function');
expect(Foo.hasOwnProperty('a')).toBe(true);
expect(Foo.b).toBe(124);
Foo.b = 123;
expect(Foo.b).toBe(125);
expect(bContext.name).toBe('b');
expect(bContext.kind).toBe('accessor');
expect(bContext.static).toBe(true);
expect(bContext.private).toBe(false);
expect(typeof bContext.addInitializer).toBe('function');
expect(Foo.hasOwnProperty('b')).toBe(true);
expect(Foo.c).toBe(457);
Foo.c = 456;
expect(Foo.c).toBe(458);
expect(cContext.name).toBe('c');
expect(cContext.kind).toBe('accessor');
expect(cContext.static).toBe(true);
expect(cContext.private).toBe(false);
expect(typeof cContext.addInitializer).toBe('function');
expect(Foo.hasOwnProperty('c')).toBe(true);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-public/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
static accessor a;
@dec
static accessor b = 123;
@dec
static accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/static-public/output.js | JavaScript | var _init_a, _init_b, _computedKey, _init_computedKey, _initStatic;
const dec = ()=>{};
_computedKey = 'c';
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
static get a() {
return _class_static_private_field_spec_get(this, Foo, ____private_a_1);
}
static set a(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_a_1, _v);
}
static get b() {
return _class_static_private_field_spec_get(this, Foo, ____private_b_2);
}
static set b(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_b_2, _v);
}
static get [_computedKey1]() {
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey_3);
}
static set [_computedKey2](_v) {
_class_static_private_field_spec_set(this, Foo, ____private_computedKey_3, _v);
}
}
(()=>{
({ e: [_init_a, _init_b, _init_computedKey, _initStatic] } = _apply_decs_2203_r(Foo, [
[
dec,
6,
"a"
],
[
dec,
6,
"b"
],
[
dec,
6,
_computedKey
]
], []));
_initStatic(Foo);
})();
var ____private_a_1 = {
writable: true,
value: _init_a(Foo)
};
var ____private_b_2 = {
writable: true,
value: _init_b(Foo, 123)
};
var ____private_computedKey_3 = {
writable: true,
value: _init_computedKey(Foo, 456)
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-private/exec.js | JavaScript | class Foo {
accessor #a;
accessor #b = 123;
getA() {
return this.#a;
}
setA(v) {
this.#a = v;
}
getB() {
return this.#b;
}
setB(v) {
this.#b = v;
}
}
let foo = new Foo();
expect(foo.getA()).toBe(undefined);
foo.setA(123)
expect(foo.getA()).toBe(123);
expect(foo.getB()).toBe(123);
foo.setB(456)
expect(foo.getB()).toBe(456);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-private/input.js | JavaScript | const dec = () => {};
class Foo {
accessor #a;
accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-private/output.js | JavaScript | const dec = ()=>{};
var ___a_1 = /*#__PURE__*/ new WeakMap(), _a = /*#__PURE__*/ new WeakMap(), ___b_2 = /*#__PURE__*/ new WeakMap(), _b = /*#__PURE__*/ new WeakMap();
class Foo {
constructor(){
_class_private_field_init(this, _a, {
get: get_a,
set: set_a
});
_class_private_field_init(this, _b, {
get: get_b,
set: set_b
});
_class_private_field_init(this, ___a_1, {
writable: true,
value: void 0
});
_class_private_field_init(this, ___b_2, {
writable: true,
value: 123
});
}
}
function get_a() {
return _class_private_field_get(this, ___a_1);
}
function set_a(_v) {
_class_private_field_set(this, ___a_1, _v);
}
function get_b() {
return _class_private_field_get(this, ___b_2);
}
function set_b(_v) {
_class_private_field_set(this, ___b_2, _v);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-public/exec.js | JavaScript | class Foo {
accessor a;
accessor b = 123;
accessor ['c'] = 456;
}
let foo = new Foo();
expect(foo.a).toBe(undefined);
foo.a = 123;
expect(foo.a).toBe(123);
expect(foo.hasOwnProperty('a')).toBe(false);
expect(Foo.prototype.hasOwnProperty('a')).toBe(true);
expect(foo.b).toBe(123);
foo.b = 456
expect(foo.b).toBe(456);
expect(foo.hasOwnProperty('b')).toBe(false);
expect(Foo.prototype.hasOwnProperty('b')).toBe(true);
expect(foo.c).toBe(456);
foo.c = 789
expect(foo.c).toBe(789);
expect(foo.hasOwnProperty('c')).toBe(false);
expect(Foo.prototype.hasOwnProperty('c')).toBe(true);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-public/input.js | JavaScript | const dec = () => {};
class Foo {
accessor a;
accessor b = 123;
accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-public/output.js | JavaScript | var _computedKey;
const dec = ()=>{};
_computedKey = 'c';
var ____private_a_1 = /*#__PURE__*/ new WeakMap(), ____private_b_2 = /*#__PURE__*/ new WeakMap(), ____private_computedKey_3 = /*#__PURE__*/ new WeakMap();
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
get a() {
return _class_private_field_get(this, ____private_a_1);
}
set a(_v) {
_class_private_field_set(this, ____private_a_1, _v);
}
get b() {
return _class_private_field_get(this, ____private_b_2);
}
set b(_v) {
_class_private_field_set(this, ____private_b_2, _v);
}
get [_computedKey1]() {
return _class_private_field_get(this, ____private_computedKey_3);
}
set [_computedKey2](_v) {
_class_private_field_set(this, ____private_computedKey_3, _v);
}
constructor(){
_class_private_field_init(this, ____private_a_1, {
writable: true,
value: void 0
});
_class_private_field_init(this, ____private_b_2, {
writable: true,
value: 123
});
_class_private_field_init(this, ____private_computedKey_3, {
writable: true,
value: 456
});
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-private/exec.js | JavaScript | class Foo {
static accessor #a;
static accessor #b = 123;
static getA() {
return this.#a;
}
static setA(v) {
this.#a = v;
}
static getB() {
return this.#b;
}
static setB(v) {
this.#b = v;
}
}
expect(Foo.getA()).toBe(undefined);
Foo.setA(123)
expect(Foo.getA()).toBe(123);
expect(Foo.getB()).toBe(123);
Foo.setB(456)
expect(Foo.getB()).toBe(456);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-private/input.js | JavaScript | const dec = () => {};
class Foo {
static accessor #a;
static accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-private/output.js | JavaScript | const dec = ()=>{};
class Foo {
}
var _a = {
get: get_a,
set: set_a
};
var _b = {
get: get_b,
set: set_b
};
var ___a_1 = {
writable: true,
value: void 0
};
var ___b_2 = {
writable: true,
value: 123
};
function get_a() {
return _class_static_private_field_spec_get(this, Foo, ___a_1);
}
function set_a(_v) {
_class_static_private_field_spec_set(this, Foo, ___a_1, _v);
}
function get_b() {
return _class_static_private_field_spec_get(this, Foo, ___b_2);
}
function set_b(_v) {
_class_static_private_field_spec_set(this, Foo, ___b_2, _v);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-public/exec.js | JavaScript | class Foo {
static accessor a;
static accessor b = 123;
static accessor ['c'] = 456;
}
expect(Foo.a).toBe(undefined);
Foo.a = 123;
expect(Foo.a).toBe(123);
expect(Foo.hasOwnProperty('a')).toBe(true);
expect(Foo.b).toBe(123);
Foo.b = 456
expect(Foo.b).toBe(456);
expect(Foo.hasOwnProperty('b')).toBe(true);
expect(Foo.c).toBe(456);
Foo.c = 789
expect(Foo.c).toBe(789);
expect(Foo.hasOwnProperty('c')).toBe(true);
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-public/input.js | JavaScript | const dec = () => {};
class Foo {
static accessor a;
static accessor b = 123;
static accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors--to-es2015/undecorated-static-public/output.js | JavaScript | var _computedKey;
const dec = ()=>{};
_computedKey = 'c';
let _computedKey1 = _computedKey, _computedKey2 = _computedKey;
class Foo {
static get a() {
return _class_static_private_field_spec_get(this, Foo, ____private_a_1);
}
static set a(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_a_1, _v);
}
static get b() {
return _class_static_private_field_spec_get(this, Foo, ____private_b_2);
}
static set b(_v) {
_class_static_private_field_spec_set(this, Foo, ____private_b_2, _v);
}
static get [_computedKey1]() {
return _class_static_private_field_spec_get(this, Foo, ____private_computedKey_3);
}
static set [_computedKey2](_v) {
_class_static_private_field_spec_set(this, Foo, ____private_computedKey_3, _v);
}
}
var ____private_a_1 = {
writable: true,
value: void 0
};
var ____private_b_2 = {
writable: true,
value: 123
};
var ____private_computedKey_3 = {
writable: true,
value: 456
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/private/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
accessor #a;
@dec
accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/private/output.js | JavaScript | var _init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initProto;
const dec = ()=>{};
class Foo {
static{
({ e: [_init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initProto] } = _apply_decs_2203_r(this, [
[
dec,
1,
"a",
function() {
return this.#__a_1;
},
function(_v) {
this.#__a_1 = _v;
}
],
[
dec,
1,
"b",
function() {
return this.#__b_2;
},
function(_v) {
this.#__b_2 = _v;
}
]
], []));
}
#__a_1 = (_initProto(this), _init_a(this));
get #a() {
return _get___a(this);
}
set #a(_v) {
_set___a(this, _v);
}
#__b_2 = _init_b(this, 123);
get #b() {
return _get___b(this);
}
set #b(_v) {
_set___b(this, _v);
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/public/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
accessor a;
@dec
accessor b = 123;
@dec
accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/public/output.js | JavaScript | var _init_a, _init_b, _computedKey, _init_computedKey, _initProto;
const dec = ()=>{};
_computedKey = 'c';
class Foo {
static{
({ e: [_init_a, _init_b, _init_computedKey, _initProto] } = _apply_decs_2203_r(this, [
[
dec,
1,
"a"
],
[
dec,
1,
"b"
],
[
dec,
1,
_computedKey
]
], []));
}
#___private_a_1 = (_initProto(this), _init_a(this));
get a() {
return this.#___private_a_1;
}
set a(_v) {
this.#___private_a_1 = _v;
}
#___private_b_2 = _init_b(this, 123);
get b() {
return this.#___private_b_2;
}
set b(_v) {
this.#___private_b_2 = _v;
}
#___private_computedKey_3 = _init_computedKey(this, 456);
get [_computedKey]() {
return this.#___private_computedKey_3;
}
set [_computedKey](_v) {
this.#___private_computedKey_3 = _v;
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/static-private/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
static accessor #a;
@dec
static accessor #b = 123;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/static-private/output.js | JavaScript | var _init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initStatic;
const dec = ()=>{};
class Foo {
static{
({ e: [_init_a, _get___a, _set___a, _init_b, _get___b, _set___b, _initStatic] } = _apply_decs_2203_r(this, [
[
dec,
6,
"a",
function() {
return this.#__a_1;
},
function(_v) {
this.#__a_1 = _v;
}
],
[
dec,
6,
"b",
function() {
return this.#__b_2;
},
function(_v) {
this.#__b_2 = _v;
}
]
], []));
_initStatic(this);
}
static #__a_1 = _init_a(this);
static get #a() {
return _get___a(this);
}
static set #a(_v) {
_set___a(this, _v);
}
static #__b_2 = _init_b(this, 123);
static get #b() {
return _get___b(this);
}
static set #b(_v) {
_set___b(this, _v);
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-accessors/static-public/input.js | JavaScript | const dec = () => {};
class Foo {
@dec
static accessor a;
@dec
static accessor b = 123;
@dec
static accessor ['c'] = 456;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.