Skip to content

Commit

Permalink
Add tests (#21)
Browse files Browse the repository at this point in the history
* Added tests for table (failing)

* Added test step to CI

* Add jest dependency

* Moved test to its own CI job separate from lint

* Added a whole bunch of tests

* Prettier format

* Removed not needed records
  • Loading branch information
Perryvw authored Mar 13, 2021
1 parent 651ab44 commit 0cd2a63
Show file tree
Hide file tree
Showing 34 changed files with 14,860 additions and 2,364 deletions.
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
allow:
- dependency-name: 'typescript-to-lua'
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
allow:
- dependency-name: 'typescript-to-lua'
35 changes: 24 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@ name: CI
on: [push, pull_request]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm run lint
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm run lint

test:
name: Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ npm install -D lua-types

Where `<version>` is one of:

- `5.1`
- `5.2`
- `5.3`
- `5.4`
- `jit`
- `5.1`
- `5.2`
- `5.3`
- `5.4`
- `jit`

> NOTE: All other files in this module shouldn't be considered public. Do not import them manually, as they may change in non-major updates. If your environment doesn't provide all of standard Lua features, consider banning them with a [no-restricted-globals](https://eslint.org/docs/rules/no-restricted-globals) eslint rule.
84 changes: 42 additions & 42 deletions core/coroutine.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,50 @@
* inside the table coroutine.
*/
declare namespace coroutine {
/**
* Creates a new coroutine, with body f. f must be a function. Returns this
* new coroutine, an object with type "thread".
*/
function create(f: (...args: any[]) => any): LuaThread;
/**
* Creates a new coroutine, with body f. f must be a function. Returns this
* new coroutine, an object with type "thread".
*/
function create(f: (...args: any[]) => any): LuaThread;

/**
* Starts or continues the execution of coroutine co. The first time you
* resume a coroutine, it starts running its body. The values val1, ... are
* passed as the arguments to the body function. If the coroutine has yielded,
* resume restarts it; the values val1, ... are passed as the results from the
* yield.
*
* If the coroutine runs without any errors, resume returns true plus any
* values passed to yield (when the coroutine yields) or any values returned
* by the body function (when the coroutine terminates). If there is any
* error, resume returns false plus the error message.
* @tupleReturn
*/
function resume(co: LuaThread, ...val: any[]): [true, ...any[]] | [false, string];
/**
* Starts or continues the execution of coroutine co. The first time you
* resume a coroutine, it starts running its body. The values val1, ... are
* passed as the arguments to the body function. If the coroutine has yielded,
* resume restarts it; the values val1, ... are passed as the results from the
* yield.
*
* If the coroutine runs without any errors, resume returns true plus any
* values passed to yield (when the coroutine yields) or any values returned
* by the body function (when the coroutine terminates). If there is any
* error, resume returns false plus the error message.
* @tupleReturn
*/
function resume(co: LuaThread, ...val: any[]): [true, ...any[]] | [false, string];

/**
* Returns the status of coroutine co, as a string: "running", if the
* coroutine is running (that is, it called status); "suspended", if the
* coroutine is suspended in a call to yield, or if it has not started running
* yet; "normal" if the coroutine is active but not running (that is, it has
* resumed another coroutine); and "dead" if the coroutine has finished its
* body function, or if it has stopped with an error.
*/
function status(co: LuaThread): 'running' | 'suspended' | 'normal' | 'dead';
/**
* Returns the status of coroutine co, as a string: "running", if the
* coroutine is running (that is, it called status); "suspended", if the
* coroutine is suspended in a call to yield, or if it has not started running
* yet; "normal" if the coroutine is active but not running (that is, it has
* resumed another coroutine); and "dead" if the coroutine has finished its
* body function, or if it has stopped with an error.
*/
function status(co: LuaThread): 'running' | 'suspended' | 'normal' | 'dead';

/**
* Creates a new coroutine, with body f. f must be a function. Returns a
* function that resumes the coroutine each time it is called. Any arguments
* passed to the function behave as the extra arguments to resume. Returns the
* same values returned by resume, except the first boolean. In case of error,
* propagates the error.
*/
function wrap(f: (...args: any[]) => any): /** @tupleReturn */ (...args: any[]) => any[];
/**
* Creates a new coroutine, with body f. f must be a function. Returns a
* function that resumes the coroutine each time it is called. Any arguments
* passed to the function behave as the extra arguments to resume. Returns the
* same values returned by resume, except the first boolean. In case of error,
* propagates the error.
*/
function wrap(f: (...args: any[]) => any): /** @tupleReturn */ (...args: any[]) => any[];

/**
* Suspends the execution of the calling coroutine. Any arguments to yield are
* passed as extra results to resume.
* @tupleReturn
*/
function yield(...args: any[]): any[];
/**
* Suspends the execution of the calling coroutine. Any arguments to yield are
* passed as extra results to resume.
* @tupleReturn
*/
function yield(...args: any[]): any[];
}
Loading

0 comments on commit 0cd2a63

Please sign in to comment.