mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 15:32:16 +00:00
Update test instructions
This commit is contained in:
parent
c17dd14fc4
commit
ee94634ffb
@ -1,29 +1,98 @@
|
|||||||
|
Tests
|
||||||
|
=====
|
||||||
|
|
||||||
|
This directory contains the test cases for AssemblyScript's parser and compiler. A test case
|
||||||
|
consists of:
|
||||||
|
|
||||||
|
* A test file that is parsed or compiled (.ts)
|
||||||
|
* One or multiple automatically generated fixtures generated from the source file
|
||||||
|
|
||||||
|
Creating a test:
|
||||||
|
|
||||||
|
* Run `npm run clean` to make sure that the sources are tested instead of the distribution
|
||||||
|
* Create a new test file (.ts) within the respective directory (see below) that contains your test code
|
||||||
|
* Follow the instructions below to generate the first fixture(s)
|
||||||
|
* Make sure the fixture(s) contain exactly what you'd expect
|
||||||
|
|
||||||
|
Updating a test:
|
||||||
|
|
||||||
|
* Run `npm run clean` to make sure that the sources are tested instead of the distribution
|
||||||
|
* Make changes to the respective test file (.ts)
|
||||||
|
* Follow the instructions below to update the fixture(s)
|
||||||
|
* Make sure the fixture(s) contain exactly what you'd expect
|
||||||
|
|
||||||
|
See also: [Contribution guidelines](../CONTRIBUTING.md)
|
||||||
|
|
||||||
Parser
|
Parser
|
||||||
------
|
------
|
||||||
|
|
||||||
Tests consist of a test case that is first parsed and then serialized again. The output is then compared to its respective fixture.
|
Directory: [tests/parser](./parser)
|
||||||
|
|
||||||
|
The test file is parsed while warnings and errors are recorded and re-serialized to a new source
|
||||||
|
afterwards. The new source with warnings and errors appended as comments is compared to the fixture.
|
||||||
|
|
||||||
|
Running all tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
$> npm run test:parser [case name]
|
$> npm run test:parser
|
||||||
```
|
```
|
||||||
|
|
||||||
To recreate the fixtures:
|
Running a specific test only:
|
||||||
|
|
||||||
|
```
|
||||||
|
$> npm run test:parser -- testNameWithoutTs
|
||||||
|
```
|
||||||
|
|
||||||
|
To (re-)create all fixtures:
|
||||||
|
|
||||||
```
|
```
|
||||||
$>npm run test:parser -- --create
|
$>npm run test:parser -- --create
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that the parser suite currently can't recreate just a specific fixture.
|
||||||
|
|
||||||
Compiler
|
Compiler
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Tests consist of a test case that is compiled to a module, validated, interpreted, converted to text format and then compared to its respective fixture.
|
General directory: [tests/compiler](./compiler)
|
||||||
|
Standard library directory: [tests/compiler/std](./compiler/std)
|
||||||
|
|
||||||
|
The source file is parsed and compiled to a module, validated, interpreted and the resulting module
|
||||||
|
converted to WebAsssembly text format.
|
||||||
|
|
||||||
|
The text format output is compared to its fixture and the module interpreted in a WebAssembly VM. To
|
||||||
|
assert for runtime conditions, the `assert` builtin can be used. Note that tree-shaking is enabled
|
||||||
|
and it might be necessary to export entry points.
|
||||||
|
|
||||||
|
Additional fixtures for the optimized module etc. are generated as well but are used for visual
|
||||||
|
confirmation only.
|
||||||
|
|
||||||
|
Running all tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
$> npm run test:compiler [case name]
|
$> npm run test:compiler
|
||||||
```
|
```
|
||||||
|
|
||||||
To recreate the fixtures:
|
Running a specific test only:
|
||||||
|
|
||||||
```
|
```
|
||||||
$>npm run test:compiler -- --create
|
$> npm run test:compiler -- testNameWithoutTs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To (re-)create all fixtures:
|
||||||
|
|
||||||
|
```
|
||||||
|
$> npm run test:compiler -- --create
|
||||||
|
```
|
||||||
|
|
||||||
|
To (re-)create a specific fixture only:
|
||||||
|
|
||||||
|
```
|
||||||
|
$> npm run test:compiler -- testNameWithoutTs --create
|
||||||
|
```
|
||||||
|
|
||||||
|
Other
|
||||||
|
-----
|
||||||
|
|
||||||
|
Tests in other directories are not run automatically and do not need to be updated. Most of them
|
||||||
|
are legacy tests.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user