Skip to content

Commit

Permalink
Merge pull request #66 from azizghuloum/vitest-support
Browse files Browse the repository at this point in the history
vitest support
  • Loading branch information
azizghuloum authored Dec 30, 2024
2 parents 7e4582a + fde87ea commit b5b6e1b
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/library-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ abstract class Module implements imported_module {
cuid: this.state.cid,
clauses: binding.clauses,
};
case "imported_type":
case "imported_lexical":
return binding;
default:
throw new Error(`unhandled binding type ${binding.type} for label '${name}'`);
}
Expand Down Expand Up @@ -468,9 +471,20 @@ class DtsModule extends Module {
return [name, res];
}
case "imported": {
const label = `e.${binding.name}.${binding.module}`;
//assert(binding.name !== undefined, `namespace reexports not handled yet`);
if (binding.name) {
context[label] = {
type: "imported_lexical",
cuid: binding.module,
name: binding.name,
};
} else {
console.error(`nameless reexports not handled yet`);
}
const res: import_resolution = {
type: "ts",
label: { cuid: cid, name: `e.${binding.name}.${binding.module}` },
label: { cuid: cid, name: label },
};
return [name, [res]];
}
Expand Down
82 changes: 82 additions & 0 deletions test-project/.rts/test1.test.rts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"cid": "test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
"cookie": "rewrite-ts-016",
"imports": [
{
"pkg": {"name": "vitest", "version": "2.1.8"},
"pkg_relative_path": "./dist/index.d.ts"
}
],
"exported_identifiers": {},
"context": {},
"unit": {
"cu_id": "test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
"store": {
"r0": {
"type": "rib",
"normal_env": {
"suite": [
[
[
"test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
["top", null]
],
{
"cuid": "dist/index.d.ts vitest 2.1.8",
"name": "e.suite.@vitest/runner"
}
]
],
"test": [
[
[
"test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
["top", null]
],
{
"cuid": "dist/index.d.ts vitest 2.1.8",
"name": "e.test.@vitest/runner"
}
]
],
"expect": [
[
[
"test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
["top", null]
],
{"cuid": "dist/index.d.ts vitest 2.1.8", "name": "l.globalExpect"}
]
]
},
"types_env": {
"suite": [
[
[
"test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
["top", null]
],
{
"cuid": "dist/index.d.ts vitest 2.1.8",
"name": "e.suite.@vitest/runner"
}
]
],
"test": [
[
[
"test-project/test1.test.rts rewrite-ts-visualized 0.0.0",
["top", null]
],
{
"cuid": "dist/index.d.ts vitest 2.1.8",
"name": "e.test.@vitest/runner"
}
]
]
},
"libs": ["es2024.full"]
}
}
}
}
6 changes: 6 additions & 0 deletions test-project/.rts/test1.test.rts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { suite as suite_1, test as test_2, expect as expect_3 } from "vitest";
suite_1("sample test", () => {
test_2("should work", () => {
expect_3(5).toBe(5);
});
});
7 changes: 7 additions & 0 deletions test-project/test1.test.rts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test, suite } from "vitest";

suite("sample test", () => {
test("should work", () => {
expect(5).toBe(5);
});
});
2 changes: 2 additions & 0 deletions test-project/test1.test.rts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* This is an automatically generated file. Do not edit. */
import { } from "./.rts/test1.test.rts.ts";
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./files.test.ts","./generate-stdlibs.test.ts","./vite.config.ts","./vitest.config.ts","./rtsc/compile-all.ts","./rtsc/watch.ts","./src/assert.ts","./src/ast.ts","./src/data.ts","./src/expander.ts","./src/fs-helpers.ts","./src/generate-stdlibs.ts","./src/generated-stdlibs.ts","./src/global-module.ts","./src/library-manager.ts","./src/llhelpers.ts","./src/parse-dts.ts","./src/parse.ts","./src/pprint.ts","./src/preexpand-handlers.ts","./src/preexpand-helpers.ts","./src/proxy-code.ts","./src/serialize.ts","./src/stx-error.ts","./src/stx.ts","./src/syntax-core-patterns.ts","./src/syntax-structures.ts","./src/tags.ts","./src/zipper.ts","./test-project/index.ts","./test-project/main.rts.ts","./test-project/mod.rts.ts","./ui/astvis.tsx","./ui/app.tsx","./ui/editor.tsx","./ui/main.tsx","./ui/vite-env.d.ts"],"version":"5.7.2"}
{"root":["./files.test.ts","./generate-stdlibs.test.ts","./vite.config.ts","./vitest.config.ts","./rtsc/compile-all.ts","./rtsc/watch.ts","./src/assert.ts","./src/ast.ts","./src/data.ts","./src/expander.ts","./src/fs-helpers.ts","./src/generate-stdlibs.ts","./src/generated-stdlibs.ts","./src/global-module.ts","./src/library-manager.ts","./src/llhelpers.ts","./src/parse-dts.ts","./src/parse.ts","./src/pprint.ts","./src/preexpand-handlers.ts","./src/preexpand-helpers.ts","./src/proxy-code.ts","./src/serialize.ts","./src/stx-error.ts","./src/stx.ts","./src/syntax-core-patterns.ts","./src/syntax-structures.ts","./src/tags.ts","./src/zipper.ts","./test-project/index.ts","./test-project/main.rts.ts","./test-project/mod.rts.ts","./test-project/test1.test.rts.ts","./ui/astvis.tsx","./ui/app.tsx","./ui/editor.tsx","./ui/main.tsx","./ui/vite-env.d.ts"],"version":"5.7.2"}
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["**/*.test.ts", "**/.rts/*.test.rts.ts"],
coverage: {
provider: "v8", // or 'istanbul'
},
Expand Down

0 comments on commit b5b6e1b

Please sign in to comment.