-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f95dfeb
commit 8680e26
Showing
7 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export enum Lang { | ||
Fart = "fart", // ex use-case: generating typedefs/config in any lang | ||
Proto = "proto", // ex use-case: generating typedefs in multiple langs | ||
TypeScript = "ts", // ex use-case: generating all types of programs | ||
ESM = "esm", // JavaScript with `import` | ||
Go = "go", // ex use-case: generating all types of programs | ||
Rust = "rust", // ex use-case: generating fault-tolerant programs | ||
JSON = "json", // ex use-case: generating config | ||
HTML = "html", // ex use-case: generating web pages | ||
YAML = "yaml", // ex use-case: generating config | ||
XML = "xml", // ex use-case: generating unstructured info | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { assertEquals } from "../../deps/std/testing.ts"; | ||
import { transpile } from "./transpile.ts"; | ||
import { Cartridge, CartridgeEvent } from "./cartridge/mod.ts"; | ||
import type { CartridgeEventContext } from "./cartridge/mod.ts"; | ||
// import type { FartOptions } from "./transpile.ts"; | ||
|
||
Deno.test("empty string results in empty string", async () => { | ||
const fakeCart = new Cartridge(); | ||
fakeCart.on( | ||
CartridgeEvent.StructOpen, | ||
(event: CartridgeEventContext<CartridgeEvent.StructOpen>) => { | ||
assertEquals(event.data.name, "Example"); | ||
console.log({ event }); | ||
return ""; | ||
}, | ||
); | ||
const result = await transpile(`type Example {`, fakeCart); | ||
assertEquals(result, ""); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Lexicon, Token } from "./tokenize/mod.ts"; | ||
|
||
/** | ||
* @todo write tests in utils.test.ts | ||
*/ | ||
export function assertKind(token: Token | null, lexeme: Lexicon): Token { | ||
if (token === null || token.kind !== lexeme) { | ||
throw new Error( | ||
`Expected token kind ${Lexicon[lexeme]}, got ${token}`, | ||
); | ||
} | ||
return token; | ||
} |
8680e26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to deploy: