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/decorators/2022-03-misc/setting-private-method-via-array-pattern/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { ([this.#x] = this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-array-pattern/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { [this.#x] = this.baz; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-for-of/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { for (this.#x of this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-for-of/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { for (this.#x of this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-object-pattern/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { ({ x: this.#x } = this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-object-pattern/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { ({ x: this.#x } = this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-rest/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { ([...this.#x] = this.baz); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-rest/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { [...this.#x] = this.baz; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-update/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { this.#x++; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method-via-update/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { this.#x++; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method/input.js
JavaScript
const dec = () => {}; class Foo { @dec #x() {} bar() { this.#x = 123; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/setting-private-method/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() {} ] ], [])); } constructor(){ _initProto(this); } get #x() { return _call_x; } bar() { this.#x = 123; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/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-misc/super-in-nested-constructor-expression/output.js
JavaScript
var _initClass, _Bar; const dec = ()=>{}; let _Foo; class Foo extends (_Bar = Bar) { static{ ({ c: [_Foo, _initClass] } = _apply_decs_2203_r(this, [], [ dec ], _Bar)); } 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-misc/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-misc/super-in-private-accessor/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo extends Bar { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 3, "x", function() { return super.foo(); } ] ], [])); } 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-misc/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-misc/super-in-private-method/output.js
JavaScript
var _call_x, _initProto; const dec = ()=>{}; class Foo extends Bar { static{ ({ e: [_call_x, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 2, "x", function() { return super.foo(); } ] ], [])); } constructor(...args){ super(...args), _initProto(this); } get #x() { return _call_x; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/valid-expression-formats/input.js
JavaScript
const dec = () => {}; @dec @call() @chain.expr() @(arbitrary + expr) @(array[expr]) class Foo { #a; @dec @call() @chain.expr() @(arbitrary + expr) @(array[expr]) method() {} makeClass() { return class Nested { @(this.#a) bar; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-misc/valid-expression-formats/output.js
JavaScript
var _dec, _dec1, _dec2, _dec3, _initClass, _dec4, _dec5, _dec6, _dec7, _initProto; const dec = ()=>{}; let _Foo; _dec = call(), _dec1 = chain.expr(), _dec2 = arbitrary + expr, _dec3 = array[expr], _dec4 = call(), _dec5 = chain.expr(), _dec6 = arbitrary + expr, _dec7 = array[expr]; class Foo { static{ ({ e: [_initProto], c: [_Foo, _initClass] } = _apply_decs_2203_r(this, [ [ [ dec, _dec4, _dec5, _dec6, _dec7 ], 2, "method" ] ], [ dec, _dec, _dec1, _dec2, _dec3 ])); } constructor(){ _initProto(this); } #a; method() {} makeClass() { var _dec, _init_bar; _dec = this.#a; return class Nested { static{ ({ e: [_init_bar] } = _apply_decs_2203_r(this, [ [ _dec, 0, "bar" ] ], [])); } bar = _init_bar(this); }; } static{ _initClass(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/accessor-initializers-fields/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logFieldDecoratorRun(a, b) { push(a); return function (el) { push(b); return el; }; } @logClassDecoratorRun(0, 19, 21) @logClassDecoratorRun(1, 18, 20) class A { @logAccessorDecoratorRun(2, 11, 23, 27) @logAccessorDecoratorRun(3, 10, 22, 26) accessor a; @logFieldDecoratorRun(4, 15) @logFieldDecoratorRun(5, 14) b; @logFieldDecoratorRun(6, 17) @logFieldDecoratorRun(7, 16) #c; @logAccessorDecoratorRun(8, 13, 25, 29) @logAccessorDecoratorRun(9, 12, 24, 28) accessor #d; constructor() { this.a = this.#d = null; } } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/accessor-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 21) @logClassDecoratorRun(1, 18, 20) class A { @logAccessorDecoratorRun(2, 11, 23, 31) @logAccessorDecoratorRun(3, 10, 22, 30) accessor a; @logMethodDecoratorRun(4, 13, 25, 35) @logMethodDecoratorRun(5, 12, 24, 34) b() {}; @logMethodDecoratorRun(6, 15, 27, 37) @logMethodDecoratorRun(7, 14, 26, 36) #c() {}; @logAccessorDecoratorRun(8, 17, 29, 33) @logAccessorDecoratorRun(9, 16, 28, 32) accessor #d; constructor() { this.b(); this.#c(); this.a = this.#d = null; } } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/accessor-static-accessor-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d) }; }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { @logAccessorDecoratorRun(2, 15, 31, 35) @logAccessorDecoratorRun(3, 14, 30, 34) accessor a; @logAccessorDecoratorRun(4, 11, 21, 25) @logAccessorDecoratorRun(5, 10, 20, 24) static accessor b; @logAccessorDecoratorRun(6, 13, 23, 27) @logAccessorDecoratorRun(7, 12, 22, 26) static accessor #c; @logAccessorDecoratorRun(8, 17, 33, 37) @logAccessorDecoratorRun(9, 16, 32, 36) accessor #d; } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/accessor-static-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { static { A.b(), A.#c(); } @logAccessorDecoratorRun(2, 15, 31, 35) @logAccessorDecoratorRun(3, 14, 30, 34) accessor a; @logMethodDecoratorRun(4, 11, 21, 25) @logMethodDecoratorRun(5, 10, 20, 24) static b() {}; @logMethodDecoratorRun(6, 13, 23, 27) @logMethodDecoratorRun(7, 12, 22, 26) static #c() {}; @logAccessorDecoratorRun(8, 17, 33, 37) @logAccessorDecoratorRun(9, 16, 32, 36) accessor #d; constructor() { this.a = this.#d = null; } } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/field-initializers-after-methods/exec.js
JavaScript
var counter = 0; @(x => x) class A { foo = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBeUndefined(); expect(this.bar).toBeUndefined(); return "foo"; })(); method() {} bar = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBe("foo"); expect(this.bar).toBeUndefined(); })(); } expect(counter).toBe(0); new A(); expect(counter).toBe(2);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/field/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logDecoratorRun(a, b) { push(a); return function (el) { push(b); return el; }; } @logDecoratorRun(0, 21) @logDecoratorRun(1, 20) class A { @logDecoratorRun(2, 17) @logDecoratorRun(3, 16) [push(4)]; @logDecoratorRun(5, 13) @logDecoratorRun(6, 12) static [push(7)]; @logDecoratorRun(8, 15) @logDecoratorRun(9, 14) static #c; @logDecoratorRun(10, 19) @logDecoratorRun(11, 18) #d; } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } @logDecoratorRun(0, 35, 45) @logDecoratorRun(1, 34, 44) class A { @logDecoratorRun(2, 27, 47) @logDecoratorRun(3, 26, 46) a() {}; @logDecoratorRun(4, 19, 37) @logDecoratorRun(5, 18, 36) static b() {}; @logDecoratorRun(6, 21, 39) @logDecoratorRun(7, 20, 38) static #c() {}; @logDecoratorRun(8, 29, 49) @logDecoratorRun(9, 28, 48) #d() {}; @logDecoratorRun(10, 31, 51) @logDecoratorRun(11, 30, 50) accessor e; @logDecoratorRun(12, 23, 41) @logDecoratorRun(13, 22, 40) static accessor f; @logDecoratorRun(14, 25, 43) @logDecoratorRun(15, 24, 42) static accessor #g; @logDecoratorRun(16, 33, 53) @logDecoratorRun(17, 32, 52) accessor #h; } var nums = Array.from({ length: 46 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 54 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/static-accessor-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { @logMethodDecoratorRun(2, 15, 31, 35) @logMethodDecoratorRun(3, 14, 30, 34) a() {} @logAccessorDecoratorRun(4, 11, 21, 25) @logAccessorDecoratorRun(5, 10, 20, 24) static accessor b; @logAccessorDecoratorRun(6, 13, 23, 27) @logAccessorDecoratorRun(7, 12, 22, 26) static accessor #c; @logMethodDecoratorRun(8, 17, 33, 37) @logMethodDecoratorRun(9, 16, 32, 36) #d() {} constructor() { this.a(); this.#d(); } } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering--to-es2015/static-field-initializers-after-methods/exec.js
JavaScript
var counter = 0; @(x => x) class A { static foo = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBeUndefined(); expect(this.bar).toBeUndefined(); return "foo"; })(); static method() {} static bar = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBe("foo"); expect(this.bar).toBeUndefined(); })(); } expect(counter).toBe(2);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-initializers-fields/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logFieldDecoratorRun(a, b) { push(a); return function (el) { push(b); return el; }; } @logClassDecoratorRun(0, 19, 21) @logClassDecoratorRun(1, 18, 20) class A { @logAccessorDecoratorRun(2, 11, 23, 27) @logAccessorDecoratorRun(3, 10, 22, 26) accessor a; @logFieldDecoratorRun(4, 15) @logFieldDecoratorRun(5, 14) b; @logFieldDecoratorRun(6, 17) @logFieldDecoratorRun(7, 16) #c; @logAccessorDecoratorRun(8, 13, 25, 29) @logAccessorDecoratorRun(9, 12, 24, 28) accessor #d; constructor() { this.a = this.#d = null; } } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 21) @logClassDecoratorRun(1, 18, 20) class A { @logAccessorDecoratorRun(2, 11, 23, 31) @logAccessorDecoratorRun(3, 10, 22, 30) accessor a; @logMethodDecoratorRun(4, 13, 25, 35) @logMethodDecoratorRun(5, 12, 24, 34) b() {}; @logMethodDecoratorRun(6, 15, 27, 37) @logMethodDecoratorRun(7, 14, 26, 36) #c() {}; @logAccessorDecoratorRun(8, 17, 29, 33) @logAccessorDecoratorRun(9, 16, 28, 32) accessor #d; constructor() { this.b(); this.#c(); this.a = this.#d = null; } } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-simple/1/input.js
JavaScript
@dec1 class A { @dec2 a() { } @dec3 static accessor b; @dec4 static accessor #c; @dec5 #d() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-simple/1/output.js
JavaScript
var _initClass, _init_b, _init_c, _get___c, _set___c, _call_d, _initProto, _initStatic; let _A; new class extends _identity { constructor(){ super(_A), _initClass(); } static{ class A { static{ ({ e: [_init_b, _init_c, _get___c, _set___c, _call_d, _initProto, _initStatic], c: [_A, _initClass] } = _apply_decs_2203_r(this, [ [ dec3, 6, "b" ], [ dec4, 6, "c", function() { return this.#__c_2; }, function(_v) { this.#__c_2 = _v; } ], [ dec2, 2, "a" ], [ dec5, 2, "d", function() {} ] ], [ dec1 ])); _initStatic(this); } constructor(){ _initProto(this); } a() {} static get b() { return this.#___private_b_1; } static set b(_v) { this.#___private_b_1 = _v; } get #d() { return _call_d; } } } #___private_b_1 = _init_b(this); #__c_2 = _init_c(this); get #c() { return _get___c(this); } set #c(_v) { _set___c(this, _v); } }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-static-accessor-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d) }; }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { @logAccessorDecoratorRun(2, 15, 31, 35) @logAccessorDecoratorRun(3, 14, 30, 34) accessor a; @logAccessorDecoratorRun(4, 11, 21, 25) @logAccessorDecoratorRun(5, 10, 20, 24) static accessor b; @logAccessorDecoratorRun(6, 13, 23, 27) @logAccessorDecoratorRun(7, 12, 22, 26) static accessor #c; @logAccessorDecoratorRun(8, 17, 33, 37) @logAccessorDecoratorRun(9, 16, 32, 36) accessor #d; } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-static-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { static { A.b(), A.#c(); } @logAccessorDecoratorRun(2, 15, 31, 35) @logAccessorDecoratorRun(3, 14, 30, 34) accessor a; @logMethodDecoratorRun(4, 11, 21, 25) @logMethodDecoratorRun(5, 10, 20, 24) static b() {}; @logMethodDecoratorRun(6, 13, 23, 27) @logMethodDecoratorRun(7, 12, 22, 26) static #c() {}; @logAccessorDecoratorRun(8, 17, 33, 37) @logAccessorDecoratorRun(9, 16, 32, 36) accessor #d; constructor() { this.a = this.#d = null; } } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-static-method-initializers/input.js
JavaScript
@logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { static { A.b(), A.#c(); } @logAccessorDecoratorRun(2, 15, 31, 35) @logAccessorDecoratorRun(3, 14, 30, 34) accessor a; @logMethodDecoratorRun(4, 11, 21, 25) @logMethodDecoratorRun(5, 10, 20, 24) static b() { }; @logMethodDecoratorRun(6, 13, 23, 27) @logMethodDecoratorRun(7, 12, 22, 26) static #c() { }; @logAccessorDecoratorRun(8, 17, 33, 37) @logAccessorDecoratorRun(9, 16, 32, 36) accessor #d; constructor() { this.a = this.#d = null; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/accessor-static-method-initializers/output.js
JavaScript
var _dec, _dec1, _initClass, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _init_a, _call_c, _init_d, _get___d, _set___d, _initProto, _initStatic; let _A; _dec = logClassDecoratorRun(0, 19, 29), _dec1 = logClassDecoratorRun(1, 18, 28), _dec2 = logAccessorDecoratorRun(2, 15, 31, 35), _dec3 = logAccessorDecoratorRun(3, 14, 30, 34), _dec4 = logMethodDecoratorRun(4, 11, 21, 25), _dec5 = logMethodDecoratorRun(5, 10, 20, 24), _dec6 = logMethodDecoratorRun(6, 13, 23, 27), _dec7 = logMethodDecoratorRun(7, 12, 22, 26), _dec8 = logAccessorDecoratorRun(8, 17, 33, 37), _dec9 = logAccessorDecoratorRun(9, 16, 32, 36); new class extends _identity { constructor(){ super(_A), (()=>{ _A.b(), _A.#c(); })(), _initClass(); } static{ class A { static{ ({ e: [_call_c, _init_a, _init_d, _get___d, _set___d, _initProto, _initStatic], c: [_A, _initClass] } = _apply_decs_2203_r(this, [ [ [ _dec4, _dec5 ], 7, "b" ], [ [ _dec6, _dec7 ], 7, "c", function() {} ], [ [ _dec2, _dec3 ], 1, "a" ], [ [ _dec8, _dec9 ], 1, "d", function() { return this.#__d_2; }, function(_v) { this.#__d_2 = _v; } ] ], [ _dec, _dec1 ])); _initStatic(this); } #___private_a_1 = (_initProto(this), _init_a(this)); get a() { return this.#___private_a_1; } set a(_v) { this.#___private_a_1 = _v; } static b() {} #__d_2 = _init_d(this); get #d() { return _get___d(this); } set #d(_v) { _set___d(this, _v); } constructor(){ this.a = this.#d = null; } } } get #c() { return _call_c; } }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/field-initializers-after-methods/exec.js
JavaScript
var counter = 0; @(x => x) class A { foo = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBeUndefined(); expect(this.bar).toBeUndefined(); return "foo"; })(); method() {} bar = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBe("foo"); expect(this.bar).toBeUndefined(); })(); } expect(counter).toBe(0); new A(); expect(counter).toBe(2);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/field/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logDecoratorRun(a, b) { push(a); return function (el) { push(b); return el; }; } @logDecoratorRun(0, 21) @logDecoratorRun(1, 20) class A { @logDecoratorRun(2, 17) @logDecoratorRun(3, 16) [push(4)]; @logDecoratorRun(5, 13) @logDecoratorRun(6, 12) static [push(7)]; @logDecoratorRun(8, 15) @logDecoratorRun(9, 14) static #c; @logDecoratorRun(10, 19) @logDecoratorRun(11, 18) #d; } var nums = Array.from({ length: 22 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } @logDecoratorRun(0, 35, 45) @logDecoratorRun(1, 34, 44) class A { @logDecoratorRun(2, 27, 47) @logDecoratorRun(3, 26, 46) a() {}; @logDecoratorRun(4, 19, 37) @logDecoratorRun(5, 18, 36) static b() {}; @logDecoratorRun(6, 21, 39) @logDecoratorRun(7, 20, 38) static #c() {}; @logDecoratorRun(8, 29, 49) @logDecoratorRun(9, 28, 48) #d() {}; @logDecoratorRun(10, 31, 51) @logDecoratorRun(11, 30, 50) accessor e; @logDecoratorRun(12, 23, 41) @logDecoratorRun(13, 22, 40) static accessor f; @logDecoratorRun(14, 25, 43) @logDecoratorRun(15, 24, 42) static accessor #g; @logDecoratorRun(16, 33, 53) @logDecoratorRun(17, 32, 52) accessor #h; } var nums = Array.from({ length: 46 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 54 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/initializers/input.js
JavaScript
@logDecoratorRun(0, 35, 45) @logDecoratorRun(1, 34, 44) class A { @logDecoratorRun(2, 27, 47) @logDecoratorRun(3, 26, 46) a() { }; @logDecoratorRun(4, 19, 37) @logDecoratorRun(5, 18, 36) static b() { }; @logDecoratorRun(6, 21, 39) @logDecoratorRun(7, 20, 38) static #c() { }; @logDecoratorRun(8, 29, 49) @logDecoratorRun(9, 28, 48) #d() { }; @logDecoratorRun(10, 31, 51) @logDecoratorRun(11, 30, 50) accessor e; @logDecoratorRun(12, 23, 41) @logDecoratorRun(13, 22, 40) static accessor f; @logDecoratorRun(14, 25, 43) @logDecoratorRun(15, 24, 42) static accessor #g; @logDecoratorRun(16, 33, 53) @logDecoratorRun(17, 32, 52) accessor #h; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/initializers/output.js
JavaScript
var _dec, _dec1, _initClass, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _call_c, _call_d, _init_e, _init_f, _init_g, _get___g, _set___g, _init_h, _get___h, _set___h, _initProto, _initStatic; let _A; _dec = logDecoratorRun(0, 35, 45), _dec1 = logDecoratorRun(1, 34, 44), _dec2 = logDecoratorRun(2, 27, 47), _dec3 = logDecoratorRun(3, 26, 46), _dec4 = logDecoratorRun(4, 19, 37), _dec5 = logDecoratorRun(5, 18, 36), _dec6 = logDecoratorRun(6, 21, 39), _dec7 = logDecoratorRun(7, 20, 38), _dec8 = logDecoratorRun(8, 29, 49), _dec9 = logDecoratorRun(9, 28, 48), _dec10 = logDecoratorRun(10, 31, 51), _dec11 = logDecoratorRun(11, 30, 50), _dec12 = logDecoratorRun(12, 23, 41), _dec13 = logDecoratorRun(13, 22, 40), _dec14 = logDecoratorRun(14, 25, 43), _dec15 = logDecoratorRun(15, 24, 42), _dec16 = logDecoratorRun(16, 33, 53), _dec17 = logDecoratorRun(17, 32, 52); new class extends _identity { constructor(){ super(_A), _initClass(); } static{ class A { static{ ({ e: [_call_c, _init_f, _init_g, _get___g, _set___g, _call_d, _init_e, _init_h, _get___h, _set___h, _initProto, _initStatic], c: [_A, _initClass] } = _apply_decs_2203_r(this, [ [ [ _dec4, _dec5 ], 7, "b" ], [ [ _dec6, _dec7 ], 7, "c", function() {} ], [ [ _dec12, _dec13 ], 6, "f" ], [ [ _dec14, _dec15 ], 6, "g", function() { return this.#__g_3; }, function(_v) { this.#__g_3 = _v; } ], [ [ _dec2, _dec3 ], 2, "a" ], [ [ _dec8, _dec9 ], 2, "d", function() {} ], [ [ _dec10, _dec11 ], 1, "e" ], [ [ _dec16, _dec17 ], 1, "h", function() { return this.#__h_4; }, function(_v) { this.#__h_4 = _v; } ] ], [ _dec, _dec1 ])); _initStatic(this); } a() {} static b() {} get #d() { return _call_d; } #___private_e_1 = (_initProto(this), _init_e(this)); get e() { return this.#___private_e_1; } set e(_v) { this.#___private_e_1 = _v; } static get f() { return this.#___private_f_2; } static set f(_v) { this.#___private_f_2 = _v; } #__h_4 = _init_h(this); get #h() { return _get___h(this); } set #h(_v) { _set___h(this, _v); } } } get #c() { return _call_c; } #___private_f_2 = _init_f(this); #__g_3 = _init_g(this); get #g() { return _get___g(this); } set #g(_v) { _set___g(this, _v); } }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/static-accessor-method-initializers/exec.js
JavaScript
var log = []; function push(x) { log.push(x); return x; } function logClassDecoratorRun(a, b, c) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return el; }; } function logAccessorDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return { init: () => push(d), }; }; } function logMethodDecoratorRun(a, b, c, d) { push(a); return function (el, { addInitializer }) { push(b); addInitializer(function () { push(c); }); return () => (el(), push(d)) }; } @logClassDecoratorRun(0, 19, 29) @logClassDecoratorRun(1, 18, 28) class A { @logMethodDecoratorRun(2, 15, 31, 35) @logMethodDecoratorRun(3, 14, 30, 34) a() {} @logAccessorDecoratorRun(4, 11, 21, 25) @logAccessorDecoratorRun(5, 10, 20, 24) static accessor b; @logAccessorDecoratorRun(6, 13, 23, 27) @logAccessorDecoratorRun(7, 12, 22, 26) static accessor #c; @logMethodDecoratorRun(8, 17, 33, 37) @logMethodDecoratorRun(9, 16, 32, 36) #d() {} constructor() { this.a(); this.#d(); } } var nums = Array.from({ length: 30 }, (_, i) => i); expect(log).toEqual(nums); new A(); var nums = Array.from({ length: 38 }, (_, i) => i); expect(log).toEqual(nums);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-ordering/static-field-initializers-after-methods/exec.js
JavaScript
var counter = 0; @(x => x) class A { static foo = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBeUndefined(); expect(this.bar).toBeUndefined(); return "foo"; })(); static method() {} static bar = (() => { counter++; expect(typeof this.method).toBe("function"); expect(this.foo).toBe("foo"); expect(this.bar).toBeUndefined(); })(); } expect(counter).toBe(2);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-accessor-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {} const returnsGetSet = () => ({ set(v) {}, get() {} }); const returnsInit = () => ({ init() {} }); const returnsGetFalse = () => ({ get: false }); const returnsSetFalse = () => ({ set: false }); const returnsInitFalse = () => ({ init: false }); expect(() => class { @returnsNull accessor a }).toThrow("accessor decorators must return an object with get, set, or init properties or void 0") expect(() => class { @returnsFalse accessor a }).toThrow("accessor decorators must return an object with get, set, or init properties or void 0") expect(() => class { @returnsFunction accessor a }).toThrow("accessor decorators must return an object with get, set, or init properties or void 0") expect(() => class { @returnsGetFalse accessor a }).toThrow("accessor.get must be a function"); expect(() => class { @returnsSetFalse accessor a }).toThrow("accessor.set must be a function"); expect(() => class { @returnsInitFalse accessor a }).toThrow("accessor.init must be a function"); expect(() => class { @returnsGetSet accessor a }).not.toThrow(); expect(() => class { @returnsInit accessor a }).not.toThrow(); expect(() => class { @returnsUndefined accessor a }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-add-initializer/exec.js
JavaScript
const decWithInitializer = (init) => (_, context) => { context.addInitializer(init) } expect(() => class { @decWithInitializer(null) static m() {} }).toThrow("An initializer must be a function") expect(() => class { @decWithInitializer(false) static m() {} }).toThrow("An initializer must be a function") expect(() => class { @decWithInitializer(void 0) static m() {} }).toThrow("An initializer must be a function"); expect(() => class { @decWithInitializer(() => {}) static m() {} }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-class-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {}; expect(() => @returnsNull class {}).toThrow("class decorators must return a function or void 0") expect(() => @returnsFalse class {}).toThrow("class decorators must return a function or void 0") expect(() => @returnsFunction class {}).not.toThrow(); expect(() => @returnsUndefined class {}).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-field-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {}; expect(() => class { @returnsNull m() {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFalse m() {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFunction m() {} }).not.toThrow(); expect(() => class { @returnsUndefined m() {} }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-getter-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {}; expect(() => class { @returnsNull get p() {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFalse get p() {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFunction get p() {} }).not.toThrow(); expect(() => class { @returnsUndefined get p() {} }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-method-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {}; expect(() => class { @returnsNull p }).toThrow("field decorators must return a function or void 0") expect(() => class { @returnsFalse p }).toThrow("field decorators must return a function or void 0") expect(() => class { @returnsFunction p }).not.toThrow(); expect(() => class { @returnsUndefined p }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-runtime-errors--to-es2015/invalid-setter-decorator-return/exec.js
JavaScript
const returnsUndefined = () => void 0; const returnsNull = () => null; const returnsFalse = () => false; const returnsFunction = () => () => {}; expect(() => class { @returnsNull set p(v) {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFalse set p(v) {} }).toThrow("method decorators must return a function or void 0") expect(() => class { @returnsFunction set p(v) {} }).not.toThrow(); expect(() => class { @returnsUndefined set p(v) {} }).not.toThrow();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/private/exec.js
JavaScript
function dec(set, context) { context.addInitializer(function() { this[context.name + 'Context'] = context; }); return function (v) { return set.call(this, v + 1); } } class Foo { value = 1; @dec set #a(v) { return this.value = v; } setA(v) { this.#a = v; } } let foo = new Foo(); const aContext = foo['#aContext']; expect(foo.value).toBe(1); aContext.access.set.call(foo, 123); expect(foo.value).toBe(124); foo.setA(456); expect(foo.value).toBe(457); expect(aContext.name).toBe('#a'); expect(aContext.kind).toBe('setter'); expect(aContext.static).toBe(false); expect(aContext.private).toBe(true); expect(typeof aContext.addInitializer).toBe('function');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/private/input.js
JavaScript
const dec = () => {}; class Foo { value = 1; @dec set #a(v) { return this.value = v; } setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/private/output.js
JavaScript
var _call_a, _initProto; const dec = ()=>{}; var _a = /*#__PURE__*/ new WeakMap(); class Foo { setA(v) { _class_private_field_set(this, _a, v); } constructor(){ _class_private_field_init(this, _a, { get: void 0, set: set_a }); _define_property(this, "value", (_initProto(this), 1)); } } ({ e: [_call_a, _initProto] } = _apply_decs_2203_r(Foo, [ [ dec, 4, "a", function(v) { return this.value = v; } ] ], [])); function set_a(v) { return _call_a(this, v); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/public/exec.js
JavaScript
function dec(set, context) { context.addInitializer(function() { this[context.name + 'Context'] = context; }); return function (v) { return set.call(this, v + 1); } } class Foo { value = 1; @dec set a(v) { return this.value = v; } @dec set ['b'](v) { return this.value = v; } } let foo = new Foo(); const aContext = foo['aContext']; const bContext = foo['bContext']; expect(foo.value).toBe(1); foo.a = 123; expect(foo.value).toBe(124); aContext.access.set.call(foo, 456); expect(foo.value).toBe(457); expect(aContext.name).toBe('a'); expect(aContext.kind).toBe('setter'); expect(aContext.static).toBe(false); expect(aContext.private).toBe(false); expect(typeof aContext.addInitializer).toBe('function'); expect(bContext.name).toBe('b'); expect(bContext.kind).toBe('setter'); expect(bContext.static).toBe(false); expect(bContext.private).toBe(false); 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-setters--to-es2015/public/input.js
JavaScript
const dec = () => {}; class Foo { value = 1; @dec set a(v) { return this.value = v; } @dec set ['b'](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/public/output.js
JavaScript
var _computedKey, _initProto; const dec = ()=>{}; _computedKey = 'b'; let _computedKey1 = _computedKey; class Foo { set a(v) { return this.value = v; } set [_computedKey1](v) { return this.value = v; } constructor(){ _define_property(this, "value", (_initProto(this), 1)); } } ({ e: [_initProto] } = _apply_decs_2203_r(Foo, [ [ dec, 4, "a" ], [ dec, 4, _computedKey ] ], []));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/static-private/exec.js
JavaScript
function dec(set, context) { context.addInitializer(function() { this[context.name + 'Context'] = context; }); return function (v) { return set.call(this, v + 1); } } class Foo { static value = 1; @dec static set #a(v) { return this.value = v; } static setA(v) { this.#a = v; } } const aContext = Foo['#aContext']; expect(Foo.value).toBe(1); aContext.access.set.call(Foo, 123); expect(Foo.value).toBe(124); Foo.setA(456); expect(Foo.value).toBe(457); expect(aContext.name).toBe('#a'); expect(aContext.kind).toBe('setter'); expect(aContext.static).toBe(true); expect(aContext.private).toBe(true); expect(typeof aContext.addInitializer).toBe('function');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/static-private/input.js
JavaScript
const dec = () => {}; class Foo { static value = 1; @dec static set #a(v) { return this.value = v; } static setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/static-private/output.js
JavaScript
var _call_a, _initStatic; const dec = ()=>{}; class Foo { static setA(v) { _class_static_private_field_spec_set(this, Foo, _a, v); } } var _a = { get: void 0, set: set_a }; (()=>{ ({ e: [_call_a, _initStatic] } = _apply_decs_2203_r(Foo, [ [ dec, 9, "a", function(v) { return this.value = v; } ] ], [])); _initStatic(Foo); })(); _define_property(Foo, "value", 1); function set_a(v) { return _call_a(this, v); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/static-public/exec.js
JavaScript
function dec(set, context) { context.addInitializer(function() { this[context.name + 'Context'] = context; }); return function (v) { return set.call(this, v + 1); } } class Foo { static value = 1; @dec static set a(v) { return this.value = v; } @dec static set ['b'](v) { return this.value = v; } } const aContext = Foo['aContext']; const bContext = Foo['bContext']; expect(Foo.value).toBe(1); Foo.a = 123; expect(Foo.value).toBe(124); aContext.access.set.call(Foo, 456); expect(Foo.value).toBe(457); expect(aContext.name).toBe('a'); expect(aContext.kind).toBe('setter'); expect(aContext.static).toBe(true); expect(aContext.private).toBe(false); expect(typeof aContext.addInitializer).toBe('function'); expect(bContext.name).toBe('b'); expect(bContext.kind).toBe('setter'); expect(bContext.static).toBe(true); expect(bContext.private).toBe(false); 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-setters--to-es2015/static-public/input.js
JavaScript
const dec = () => {}; class Foo { static value = 1; @dec static set a(v) { return this.value = v; } @dec static set ['b'](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters--to-es2015/static-public/output.js
JavaScript
var _computedKey, _initStatic; const dec = ()=>{}; _computedKey = 'b'; let _computedKey1 = _computedKey; class Foo { static set a(v) { return this.value = v; } static set [_computedKey1](v) { return this.value = v; } } (()=>{ ({ e: [_initStatic] } = _apply_decs_2203_r(Foo, [ [ dec, 9, "a" ], [ dec, 9, _computedKey ] ], [])); _initStatic(Foo); })(); _define_property(Foo, "value", 1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/private/input.js
JavaScript
const dec = () => {}; class Foo { value = 1; @dec set #a(v) { return this.value = v; } setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/private/output.js
JavaScript
var _call_a, _initProto; const dec = ()=>{}; class Foo { static{ ({ e: [_call_a, _initProto] } = _apply_decs_2203_r(this, [ [ dec, 4, "a", function(v) { return this.value = v; } ] ], [])); } value = (_initProto(this), 1); set #a(v) { return _call_a(this, v); } setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/public/input.js
JavaScript
const dec = () => {}; class Foo { value = 1; @dec set a(v) { return this.value = v; } @dec set ['b'](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/public/output.js
JavaScript
var _computedKey, _initProto; const dec = ()=>{}; _computedKey = 'b'; class Foo { static{ ({ e: [_initProto] } = _apply_decs_2203_r(this, [ [ dec, 4, "a" ], [ dec, 4, _computedKey ] ], [])); } value = (_initProto(this), 1); set a(v) { return this.value = v; } set [_computedKey](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/static-private/input.js
JavaScript
const dec = () => {}; class Foo { static value = 1; @dec static set #a(v) { return this.value = v; } static setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/static-private/output.js
JavaScript
var _call_a, _initStatic; const dec = ()=>{}; class Foo { static{ ({ e: [_call_a, _initStatic] } = _apply_decs_2203_r(this, [ [ dec, 9, "a", function(v) { return this.value = v; } ] ], [])); _initStatic(this); } static value = 1; static set #a(v) { return _call_a(this, v); } static setA(v) { this.#a = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/static-public/input.js
JavaScript
const dec = () => {}; class Foo { static value = 1; @dec static set a(v) { return this.value = v; } @dec static set ['b'](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/2022-03-setters/static-public/output.js
JavaScript
var _computedKey, _initStatic; const dec = ()=>{}; _computedKey = 'b'; class Foo { static{ ({ e: [_initStatic] } = _apply_decs_2203_r(this, [ [ dec, 9, "a" ], [ dec, 9, _computedKey ] ], [])); _initStatic(this); } static value = 1; static set a(v) { return this.value = v; } static set [_computedKey](v) { return this.value = v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/1/input.js
JavaScript
@decorate() export class Foo { @decorate() get name() { return "hello" } @decorate() sayHi() { return "hello" } } function decorate() { return function (target, { kind }) { console.log(target, kind) } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/1/output.js
JavaScript
var _dec, _initClass, _dec1, _dec2, _initProto; let _Foo; _dec = decorate(), _dec1 = decorate(), _dec2 = decorate(); class Foo { static{ ({ e: [_initProto] , c: [_Foo, _initClass] } = _apply_decs_2203_r(this, [ [ _dec1, 3, "name" ], [ _dec2, 2, "sayHi" ] ], [ _dec ])); } constructor(){ _initProto(this); } get name() { return "hello"; } sayHi() { return "hello"; } static{ _initClass(); } } function decorate() { return function(target, { kind }) { console.log(target, kind); }; } export { _Foo as Foo };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/2/input.js
JavaScript
export function test() { // try putting this in stmts instead of at the top level @decorate() class Foo { @decorate() get name() { return "hello" } @decorate() sayHi() { return "hello" } } function decorate() { return function (target, { kind }) { console.log(target, kind) } } return new Foo(); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/2/output.js
JavaScript
export function test() { var _dec, _initClass, _dec1, _dec2, _initProto; let _Foo; _dec = decorate(), _dec1 = decorate(), _dec2 = decorate(); // try putting this in stmts instead of at the top level class Foo { static{ ({ e: [_initProto], c: [_Foo, _initClass] } = _apply_decs_2203_r(this, [ [ _dec1, 3, "name" ], [ _dec2, 2, "sayHi" ] ], [ _dec ])); } constructor(){ _initProto(this); } get name() { return "hello"; } sayHi() { return "hello"; } static{ _initClass(); } } function decorate() { return function(target, { kind }) { console.log(target, kind); }; } return new _Foo(); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7499/1/input.js
JavaScript
class Tests { @test 'computed'() { } id() { class Bar { } } } function test(fn) { return fn; } let t = new Tests(); t.id()
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7499/1/output.js
JavaScript
var _computedKey, _initProto; _computedKey = 'computed'; class Tests { static{ ({ e: [_initProto] } = _apply_decs_2203_r(this, [ [ test, 2, _computedKey ] ], [])); } constructor(){ _initProto(this); } [_computedKey]() {} id() { class Bar { } } } function test(fn) { return fn; } let t = new Tests(); t.id();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8098/1/input.js
JavaScript
export default class T {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8098/1/output.js
JavaScript
export default class T { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8629/input.js
JavaScript
// main.ts export class Disposable { [Symbol.dispose]() { console.log('dispose') } } using _disposable = new Disposable() console.log('ok')
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8629/output.js
JavaScript
// main.ts var _computedKey; _computedKey = Symbol.dispose; export class Disposable { [_computedKey]() { console.log('dispose'); } } using _disposable = new Disposable() console.log('ok');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/input.ts
TypeScript
const decorate = (target: unknown, context: DecoratorContext) => { console.log("decorated"); }; export class Color { constructor(hex: string); constructor(r: number, g: number, b: number, a?: number); constructor(r: string | number, g?: number, b?: number, a = 1) {} @decorate get rgba() { return [0, 0, 0, 1]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/output.js
JavaScript
export default class T { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/output.ts
TypeScript
var _initProto; const decorate = (target: unknown, context: DecoratorContext)=>{ console.log("decorated"); }; export class Color { static{ ({ e: [_initProto] } = _apply_decs_2203_r(this, [ [ decorate, 3, "rgba" ] ], [])); } constructor(hex: string); constructor(r: number, g: number, b: number, a?: number); constructor(r: string | number, g?: number, b?: number, a = 1){ _initProto(this); } get rgba() { return [ 0, 0, 0, 1 ]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async-node-10/using-null-multiple-collapse.js
JavaScript
return (async function () { // async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null, async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 1]); } // async_null, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 1]); } // async_null, async_from_async { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { log.push(asyncId); }, }; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, async_from_sync { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, async_from_sync_throw { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } try { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); throw new Error(); }, }; log.push(asyncId); } catch {} log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, sync { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; using sync1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 0, 1]); } // async_null, async_from_async, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { log.push(asyncId); }, }; await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, async_from_sync, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, async_from_sync_throw, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } try { await using async_null_1 = null, async_null_2 = null; await using async1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); throw new Error(); }, }; await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } catch {} log.push(asyncId); await pending; expect(log).toEqual([0, 0, 2]); } // async_null, sync, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { await using async_null_1 = null, async_null_2 = null; using sync1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 1, 4]); } // sync, async_null, sync, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } { using sync1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; // asyncId: 2 await using async_null_1 = null, async_null_2 = null; using sync2 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; // asyncId: 1 await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } log.push(asyncId); await pending; expect(log).toEqual([0, 1, 2, 4]); } // sync_throw, async_null, sync, async_null { const log = []; let asyncId = 0, pending = Promise.resolve(); for (let i = 0; i < 10; i++) { pending = pending.then(() => asyncId++); } try { using sync1 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); throw new Error(); }, }; // asyncId: 2 await using async_null_1 = null, async_null_2 = null; using sync2 = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(asyncId); }, }; // asyncId: 1 await using async_null_3 = null, async_null_4 = null; log.push(asyncId); } catch {} log.push(asyncId); await pending; expect(log).toEqual([0, 1, 2, 4]); } })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/async-dispose-throws-synchronously.js
JavaScript
return (async function () { let disposed = false; let beforeEnd; const err1 = {}; const err2 = {}; let thrown; try { await using x = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { throw err1; }, }; throw err2; } catch (e) { thrown = e; } expect(thrown.suppressed).toBe(err2); expect(thrown.error).toBe(err1); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/completion-break.js
JavaScript
return async function () { let disposed = false; let beforeBreak; while (true) { await using x = { async [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { disposed = true; } }; beforeBreak = disposed; break; } expect(beforeBreak).toBe(false); expect(disposed).toBe(true); }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/completion-normal.js
JavaScript
return async function () { let disposed = false; let beforeEnd; { await using x = { async [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { disposed = true; } }; beforeEnd = disposed; } expect(beforeEnd).toBe(false); expect(disposed).toBe(true); }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/completion-return.js
JavaScript
return async function () { let disposed = false; let beforeReturn; await async function () { await using x = { async [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { disposed = true; } }; beforeReturn = disposed; return 0; }(); expect(beforeReturn).toBe(false); expect(disposed).toBe(true); }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/completion-throw.js
JavaScript
return (async function () { let disposed = false; let beforeReturn; let inCatch; let inFinally; try { await using x = { async [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { disposed = true; throw 1; }, }; beforeReturn = disposed; throw 0; } catch (e) { inCatch = disposed; expect(e.name).toBe("SuppressedError"); expect(e.suppressed).toBe(0); expect(e.error).toBe(1); } expect(beforeReturn).toBe(false); expect(inCatch).toBe(true); expect(disposed).toBe(true); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/invalid-not-a-function.js
JavaScript
expect( (async function () { await using foo = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]: 3, }; })() ).rejects.toThrow(TypeError); expect( (async function () { await using foo = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]: 3, }; })() ).rejects.toThrow("Object is not disposable."); expect( (async function () { await using foo = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]: null, [Symbol.dispose || Symbol.for("Symbol.dispose")]() {}, }; })() ).rejects.toThrow("Object is not disposable.");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/issue-9576.js
JavaScript
class Disposable { disposed = false; [Symbol.dispose]() { this.disposed = true } } const disposables = [new Disposable()] for (using _ of disposables) {/* ... */ } expect(disposables[0].disposed).toBe(true); class AsyncDisposable { disposed = false; [Symbol.asyncDispose]() { this.disposed = true } } const asyncDisposables = [new AsyncDisposable()] for (await using _ of asyncDisposables) {/* ... */ } expect(asyncDisposables[0].disposed).toBe(true);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/multiple.js
JavaScript
return async function () { let log = []; function disposable(name){ return { async [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { log.push(name); } }; } { await using x = disposable("x"); await using y = disposable("y"), z = disposable("z"); await using w = disposable("w"); log.push("body"); } expect(log).toEqual(["body", "w", "z", "y", "x"]); }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/sync-async-mixed.js
JavaScript
return (async function () { let log = []; function disposable(name, symbolName, cb){ return { async [Symbol[symbolName] || Symbol.for("Symbol." + symbolName)]() { log.push(name); if (cb) cb(); } }; } let inBmicrotick = false; let inBmicrotickWhileC = false; let inBmicrotickWhileD = false; let inBmicrotickWhileE = false; { using e = disposable("e", "dispose", () => { inBmicrotickWhileE = inBmicrotick; }); await using d = disposable("d", "asyncDispose", () => { inBmicrotickWhileD = inBmicrotick; }); using c = disposable("c", "dispose", () => { inBmicrotickWhileC = inBmicrotick; }); using b = disposable("b", "dispose", () => { inBmicrotick = true; Promise.resolve().then(() => { inBmicrotick = false; }); }); await using a = disposable("a", "asyncDispose"); } expect(log).toEqual(["a", "b", "c", "d", "e"]); expect(inBmicrotick).toBe(false); expect(inBmicrotickWhileC).toBe(true); expect(inBmicrotickWhileD).toBe(true); expect(inBmicrotickWhileE).toBe(false); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/sync-fallback-error.js
JavaScript
return (async () => { const log = []; async function main() { const promiseDispose = Promise.resolve().then(() => { log.push("interleave"); }); try { await using x = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push("dispose"); throw null; }, }; } catch (e) { log.push("catch"); } await promiseDispose; } await main(); expect(log).toEqual(["dispose", "interleave", "catch"]); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/sync-fallback-promise.js
JavaScript
return (async () => { const log = []; const promiseDispose = new Promise((resolve, _) => { setTimeout(() => { log.push("y dispose promise body"); resolve(); }, 0); }); { await using x = { [Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]() { log.push("x asyncDispose body"); }, }; await using y = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push("y dispose body"); return promiseDispose; }, }; } log.push("body"); await promiseDispose; expect(log).toEqual([ "y dispose body", "x asyncDispose body", "body", "y dispose promise body", ]); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/sync-fallback.js
JavaScript
return (async function () { let disposed = false; let awaited = false; let beforeEnd; { await using x = { [Symbol.dispose || Symbol.for("Symbol.dispose")]() { disposed = true; } }; beforeEnd = disposed; Promise.resolve().then(() => { awaited = true; }); } expect(beforeEnd).toBe(false); expect(disposed).toBe(true); expect(awaited).toBe(true); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/using-function.js
JavaScript
return async function () { let log = []; async function getDisposable() { function disposable() { log.push('call') } disposable[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")] = () => { log.push('dispose') }; return disposable; } { await using x = getDisposable(); x(); } expect(log).toEqual(['call', 'dispose']); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/using-null-multiple.js
JavaScript
return (async function () { const log = []; function disposable(name) { return { async [Symbol.dispose || Symbol.for("Symbol.dispose")]() { log.push(name); }, }; } async function f() { using y = disposable("y"); await using x = null; log.push("f body"); } const promise = f(); log.push("body"); await promise; expect(log).toEqual(["f body", "body", "y"]); })();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_transforms_proposal/tests/explicit-resource-management/exec-async/using-null.js
JavaScript
return expect(async function () { await using x = null; }()).resolves.toBeUndefined();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University