Skip to content

Commit

Permalink
test(transformer/class-properties): exec test for this in computed key
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel authored and Dunqing committed Dec 6, 2024
1 parent 72b5d58 commit 44e7bee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tasks/transform_conformance/snapshots/oxc_exec.snap.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
commit: 54a8389f

node: v22.11.0
filter: fixtures/oxc
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*, ""

No test files found, exiting with code 1
RUN v2.1.2 /Users/jim/Programming/crates/oxc/tasks/transform_conformance

✓ fixtures/oxc/babel-plugin-transform-class-properties-test-fixtures-this-in-computed-key-exec.test.js (1 test) 2ms

Test Files 1 passed (1)
Tests 1 passed (1)
Start at 20:11:31
Duration 188ms (transform 13ms, setup 0ms, collect 7ms, tests 2ms, environment 0ms, prepare 37ms)

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function createClassDeclaration() {
class C {
[this] = 1;
[this + 'bar'] = 2;
}
return C;
}

function createClassExpression() {
return class {
[this] = 3;
[this + 'bar'] = 4;
};
}

const C = createClassDeclaration.call("foo");
expect(new C().foo).toBe(1);
expect(new C().foobar).toBe(2);

const D = createClassExpression.call("foo");
expect(new D().foo).toBe(3);
expect(new D().foobar).toBe(4);

0 comments on commit 44e7bee

Please sign in to comment.