-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from FnControlOption/comma
Allow trailing comma in enum
- Loading branch information
Showing
7 changed files
with
277 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
- run: npm ci | ||
- run: npm run compile | ||
- run: npm test --prefix server |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "test/**/*.spec.ts", | ||
"require": "ts-node/register" | ||
} |
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,68 @@ | ||
import {tokenize} from "../../src/compile/tokenizer"; | ||
import {parseFromTokenized} from "../../src/compile/parser"; | ||
import {diagnostic} from '../../src/code/diagnostic'; | ||
import {preprocessTokensForParser} from "../../src/compile/parserPreprocess"; | ||
|
||
function itParses(content: string) { | ||
it(`parses ${content}`, () => { | ||
diagnostic.beginSession(); | ||
|
||
const targetUri = "/foo/bar.as"; | ||
const tokenizedTokens = tokenize(content, targetUri); | ||
const preprocessedTokens = preprocessTokensForParser(tokenizedTokens); | ||
parseFromTokenized(preprocessedTokens.parsingTokens); | ||
|
||
const diagnosticsInAnalyzer = diagnostic.endSession(); | ||
if (diagnosticsInAnalyzer.length > 0) { | ||
const diagnostic = diagnosticsInAnalyzer[0]; | ||
const message = diagnostic.message; | ||
const line = diagnostic.range.start.line; | ||
const character = diagnostic.range.start.character; | ||
throw new Error(`${message} (:${line}:${character})`); | ||
} | ||
}); | ||
} | ||
|
||
describe("Parser", () => { | ||
itParses("void foo() {}"); | ||
itParses("int MyValue = 0;"); | ||
itParses("const uint Flag1 = 0x01;"); | ||
itParses(` | ||
class Foo | ||
{ | ||
void bar() { value++; } | ||
int value; | ||
} | ||
`); | ||
itParses(` | ||
interface MyInterface | ||
{ | ||
void DoSomething(); | ||
} | ||
`); | ||
itParses(` | ||
enum MyEnum | ||
{ | ||
eValue0, | ||
eValue2 = 2, | ||
eValue3, | ||
eValue200 = eValue2 * 100 | ||
} | ||
`); | ||
itParses(` | ||
enum Foo | ||
{ | ||
fizz, | ||
buzz, | ||
} | ||
`); | ||
itParses("funcdef bool CALLBACK(int, int);"); | ||
itParses("typedef double real64;"); | ||
itParses(` | ||
namespace A | ||
{ | ||
void function() { variable++; } | ||
int variable; | ||
} | ||
`); | ||
}); |