Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test for First* and Last* enums #425

Open
osyrisrblx opened this issue Feb 7, 2024 · 1 comment
Open

Unit test for First* and Last* enums #425

osyrisrblx opened this issue Feb 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@osyrisrblx
Copy link
Member

osyrisrblx commented Feb 7, 2024

https://github.com/roblox-ts/luau-ast/blob/master/src/LuauAST/impl/enums.ts#L51-L58

It's easy to accidentally break these. So we should add a quick unit test which verifies:

assert(SyntaxKind.FirstIndexableExpression === 0);
assert(SyntaxKind.FirstExpression === 0);
// TODO: verify SyntaxKind.LastIndexableExpression?
assert(SyntaxKind.LastExpression + 1 === SyntaxKind.FirstStatement);
assert(SyntaxKind.LastStatement + 1 === SyntaxKind.FirstField);
assert(SyntaxKind.LastField === Math.max(...Object.values(SyntaxKind).filter((v): v is number => typeof v === "number")));

playground

@osyrisrblx osyrisrblx added the enhancement New feature or request label Feb 7, 2024
@osyrisrblx
Copy link
Member Author

A way to possibly verify LastIndexableExpression:

assert(SyntaxKind.LastIndexableExpression + 1 === SyntaxKind.None);

None is pretty unlikely to ever not be the first non-indexable expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant