Skip to content

Commit

Permalink
Add some more tests (#158)
Browse files Browse the repository at this point in the history
* Just tweaking crap

* Working on the converter for some reason

* Add a nested type test

* Bunnnnnn
  • Loading branch information
UnstoppableMango authored Jun 12, 2024
1 parent 8b9a990 commit a354d00
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
Binary file modified bun.lockb
Binary file not shown.
9 changes: 9 additions & 0 deletions packages/ts/converter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import * as tdl from '@unmango/tdl';
import type { Spec } from '@unmango/tdl-es';
import type { BunFile } from 'bun';
import ts from 'typescript';

export const from: tdl.From<Spec> = async (reader: BunFile): Promise<Spec> => {
const data = await reader.arrayBuffer();
const content = new TextDecoder().decode(data);
const source = ts.createSourceFile('stdin', content, ts.ScriptTarget.ES2019, undefined, ts.ScriptKind.TS);
source.forEachChild(parseNode);
return await Promise.reject('not implemented');
};

function parseNode(node: ts.Node): void {
throw new Error('not implemented');
}
3 changes: 2 additions & 1 deletion packages/ts/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function genProps(name: string, field: Field): ts.PropertySignature {
const type = ts.factory.createTypeReferenceNode(field.type);

return ts.factory.createPropertySignature(
[ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],
// [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)],
[],
name,
undefined,
type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ types:
type: string
numberField:
type: number
booleanField:
type: boolean
5 changes: 5 additions & 0 deletions packages/ts/testdata/interface/target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface TestType {
stringField: string;
numberField: number;
booleanField: boolean;
}
11 changes: 11 additions & 0 deletions packages/ts/testdata/nested_interface/source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
types:
NestedType:
type: object
fields:
field:
type: string
TestType:
type: object
fields:
nested:
type: NestedType
6 changes: 6 additions & 0 deletions packages/ts/testdata/nested_interface/target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface NestedType {
field: string;
}
export interface TestType {
nested: NestedType;
}
4 changes: 0 additions & 4 deletions packages/ts/testdata/type/target.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/Testing/RunnerTest.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module UnMango.Tdl.Testing.RunnerTest

open System.IO
open Google.Protobuf
open UnMango.Tdl

let roundTrip (gen: Tdl.Gen, from: Tdl.From) spec = async {
Expand Down

0 comments on commit a354d00

Please sign in to comment.