Skip to content

Commit

Permalink
feat: expand syntax (#24)
Browse files Browse the repository at this point in the history
Add the new language syntax.
  • Loading branch information
robmeth authored Apr 24, 2024
1 parent d4d779f commit 1fae28a
Show file tree
Hide file tree
Showing 172 changed files with 3,070 additions and 2,889 deletions.
2 changes: 1 addition & 1 deletion docs/development/call-graph-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ graph test.

## Adding a call graph test

1. Create a new file with the extension `.sdstest` in the `tests/resources/call graph` directory or any subdirectory.
1. Create a new file with the extension `.Tsltest` in the `tests/resources/call graph` directory or any subdirectory.
Give the file a descriptive name, since the file name becomes part of the test name.

!!! tip "Skipping a test"
Expand Down
4 changes: 2 additions & 2 deletions docs/development/formatting-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ formatting test.

## Adding a formatting test

1. Create a new file with the extension `.sdstest` in the `tests/resources/formatting` directory or any subdirectory.
1. Create a new file with the extension `.Tsltest` in the `tests/resources/formatting` directory or any subdirectory.
Give the file a descriptive name, since the file name becomes part of the test name.

!!! tip "Skipping a test"
Expand All @@ -14,7 +14,7 @@ formatting test.

2. Add the original unformatted Safe-DS code to the top of the file. The code must be syntactically valid.
3. Add the following separator to the file:
```sds
```Tsl
// -----------------------------------------------------------------------------
```
4. Add the expected formatted Safe-DS code to the file below the separator.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/generation-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ generation test.

If you want to skip a test, add the prefix `skip-` to the folder name.

2. Add files with the extension `.sdstest`, `.sdspipe`, or `.sdsstub` **directly inside the folder**. All files in a
2. Add files with the extension `.Tsltest`, `.Tslpipe`, or `.Tslstub` **directly inside the folder**. All files in a
folder will be loaded into the same workspace, so they can reference each other. Files in different folders are
loaded into different workspaces, so they cannot reference each other. Generation will be triggered for all files in
the folder.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/grammar-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test.

## Adding a grammar test

1. Create a new file with the extension `.sdstest` in the `tests/resources/grammar` directory or any subdirectory. Give
1. Create a new file with the extension `.Tsltest` in the `tests/resources/grammar` directory or any subdirectory. Give
the file a descriptive name, since the file name becomes part of the test name.

!!! note "Naming convention"
Expand Down
2 changes: 1 addition & 1 deletion docs/development/partial-evaluation-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ partial evaluation test.

If you want to skip a test, add the prefix `skip-` to the folder name.

2. Add files with the extension `.sdstest` **directly inside the folder**. All files in a folder will be loaded into the
2. Add files with the extension `.Tsltest` **directly inside the folder**. All files in a folder will be loaded into the
same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so
they cannot reference each other.
3. Add the Safe-DS code that you want to test to the files.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/scoping-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.

If you want to skip a test, add the prefix `skip-` to the folder name.

2. Add files with the extension `.sdstest` **directly inside
2. Add files with the extension `.Tsltest` **directly inside
the folder**. All files in a folder will be loaded into the same workspace, so they can
reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other.
3. Add the Safe-DS code that you want to test to the files.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/typing-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.

If you want to skip a test, add the prefix `skip-` to the folder name.

2. Add files with the extension `.sdstest` **directly inside the folder**. All files in a folder will be loaded into the
2. Add files with the extension `.Tsltest` **directly inside the folder**. All files in a folder will be loaded into the
same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so
they cannot reference each other.
3. Add the Safe-DS code that you want to test to the files.
Expand Down
2 changes: 1 addition & 1 deletion docs/development/validation-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ validation test.

If you want to skip a test, add the prefix `skip-` to the folder name.

2. Add files with the extension `.sdstest`, `.sdspipe`, or `.sdsstub` **directly inside the folder**. All files in a
2. Add files with the extension `.Tsltest`, `.Tslpipe`, or `.Tslstub` **directly inside the folder**. All files in a
folder will be loaded into the same workspace, so they can reference each other. Files in different folders are
loaded into different workspaces, so they cannot reference each other.
3. Add the Safe-DS code that you want to test to the files.
Expand Down
2 changes: 1 addition & 1 deletion docs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mkdocs-same-dir = "^0.1.3"
pygments = "^2.17.2"

[tool.poetry.plugins."pygments.lexers"]
sds = "ttsl_lexer:TTSLLexer"
Tsl = "ttsl_lexer:TTSLLexer"

[build-system]
requires = ["poetry-core"]
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions packages/ttsl-cli/tests/cli/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ describe('safe-ds', () => {
});

it('should show not show errors in correct files', () => {
const process = spawnCheckProcess([], ['correct.sdstest']);
const process = spawnCheckProcess([], ['correct.Tsltest']);
expect(process.stdout.toString()).toContain('No errors found.');
expect(process.status).toBe(ExitCode.Success);
});

it('should handle references to builtins', () => {
const process = spawnCheckProcess([], ['references builtins.sdstest']);
const process = spawnCheckProcess([], ['references builtins.Tsltest']);
expect(process.stdout.toString()).toContain('No errors found.');
expect(process.status).toBe(ExitCode.Success);
});

it('should treat warnings as errors in strict mode', () => {
const process = spawnCheckProcess(['-s'], ['contains warnings.sdstest']);
const process = spawnCheckProcess(['-s'], ['contains warnings.Tsltest']);
expect(process.stderr.toString()).toMatch(/Found \d+ errors?\./u);
expect(process.status).toBe(ExitCode.FileHasErrors);
});

it('should show an error if the file does not exist', () => {
const process = spawnCheckProcess([], ['missing.sdstest']);
const process = spawnCheckProcess([], ['missing.Tsltest']);
expect(process.stderr.toString()).toMatch(/Path .* does not exist\./u);
expect(process.status).toBe(ExitCode.MissingPath);
});
Expand Down Expand Up @@ -121,13 +121,13 @@ describe('safe-ds', () => {
});

it('should show not show errors in correct files', () => {
const process = spawnFormatProcess([], ['correct.sdstest']);
const process = spawnFormatProcess([], ['correct.Tsltest']);
expect(process.stdout.toString()).toContain('Safe-DS code formatted successfully.');
expect(process.status).toBe(ExitCode.Success);
});

it('should show an error if the file does not exist', () => {
const process = spawnFormatProcess([], ['missing.sdstest']);
const process = spawnFormatProcess([], ['missing.Tsltest']);
expect(process.stderr.toString()).toMatch(/Path .* does not exist\./u);
expect(process.status).toBe(ExitCode.MissingPath);
});
Expand Down Expand Up @@ -165,19 +165,19 @@ describe('safe-ds', () => {
});

it('should generate Python code', () => {
const process = spawnGenerateProcess([], ['correct.sdstest']);
const process = spawnGenerateProcess([], ['correct.Tsltest']);
expect(process.stdout.toString()).toContain('Python code generated successfully.');
expect(process.status).toBe(ExitCode.Success);
});

it('should generate Python code (Safe-DS code references builtins)', () => {
const process = spawnGenerateProcess([], ['references builtins.sdstest']);
const process = spawnGenerateProcess([], ['references builtins.Tsltest']);
expect(process.stdout.toString()).toContain('Python code generated successfully.');
expect(process.status).toBe(ExitCode.Success);
});

it('should show an error if the file does not exist', () => {
const process = spawnGenerateProcess([], ['missing.sdstest']);
const process = spawnGenerateProcess([], ['missing.Tsltest']);
expect(process.stderr.toString()).toMatch(/Path .* does not exist./u);
expect(process.status).toBe(ExitCode.MissingPath);
});
Expand All @@ -191,7 +191,7 @@ describe('safe-ds', () => {
it('should show an error if a Safe-DS file has errors', () => {
const process = spawnGenerateProcess([], ['.']);
expect(process.stderr.toString()).toContain(
"Could not resolve reference to SdsNamedTypeDeclaration named 'Unresolved'",
"Could not resolve reference to TslNamedTypeDeclaration named 'Unresolved'",
);
expect(process.status).toBe(ExitCode.FileHasErrors);
});
Expand Down
14 changes: 7 additions & 7 deletions packages/ttsl-cli/tests/helpers/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('diagnosticToString', () => {
range,
message,
},
expected: chalk.red(`test.sdstest:1:1: [error] message`),
expected: chalk.red(`test.Tsltest:1:1: [error] message`),
},
{
testName: 'warning',
Expand All @@ -35,7 +35,7 @@ describe('diagnosticToString', () => {
range,
message,
},
expected: chalk.yellow(`test.sdstest:1:1: [warning] message`),
expected: chalk.yellow(`test.Tsltest:1:1: [warning] message`),
},
{
testName: 'warning (strict)',
Expand All @@ -47,7 +47,7 @@ describe('diagnosticToString', () => {
options: {
strict: true,
},
expected: chalk.red(`test.sdstest:1:1: [warning] message`),
expected: chalk.red(`test.Tsltest:1:1: [warning] message`),
},
{
testName: 'info',
Expand All @@ -56,7 +56,7 @@ describe('diagnosticToString', () => {
range,
message,
},
expected: chalk.blue(`test.sdstest:1:1: [info] message`),
expected: chalk.blue(`test.Tsltest:1:1: [info] message`),
},
{
testName: 'hint',
Expand All @@ -65,7 +65,7 @@ describe('diagnosticToString', () => {
range,
message,
},
expected: chalk.gray(`test.sdstest:1:1: [hint] message`),
expected: chalk.gray(`test.Tsltest:1:1: [hint] message`),
},
{
testName: 'with code',
Expand All @@ -75,12 +75,12 @@ describe('diagnosticToString', () => {
message,
code: 'CODE',
},
expected: chalk.red(`test.sdstest:1:1: [error] message (CODE)`),
expected: chalk.red(`test.Tsltest:1:1: [error] message (CODE)`),
},
];

it.each(tests)('$testName', ({ diagnostic, options, expected }) => {
const uri = URI.file(path.join(process.cwd(), 'test.sdstest'));
const uri = URI.file(path.join(process.cwd(), 'test.Tsltest'));
const actual = diagnosticToString(uri, diagnostic, options);
expect(actual).toBe(expected);
});
Expand Down
32 changes: 16 additions & 16 deletions packages/ttsl-cli/tests/helpers/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ describe('processPaths', async () => {
const tests: ProcessPathsTest[] = [
{
testName: 'pipe file',
paths: ['a.sdspipe'],
expected: Result.ok(['a.sdspipe']),
paths: ['a.Tslpipe'],
expected: Result.ok(['a.Tslpipe']),
},
{
testName: 'stub file',
paths: ['b.sdsstub'],
expected: Result.ok(['b.sdsstub']),
paths: ['b.Tslstub'],
expected: Result.ok(['b.Tslstub']),
},
{
testName: 'test file',
paths: ['c.sdstest'],
expected: Result.ok(['c.sdstest']),
paths: ['c.Tsltest'],
expected: Result.ok(['c.Tsltest']),
},
{
testName: 'multiple files',
paths: ['a.sdspipe', 'b.sdsstub', 'c.sdstest'],
expected: Result.ok(['a.sdspipe', 'b.sdsstub', 'c.sdstest']),
paths: ['a.Tslpipe', 'b.Tslstub', 'c.Tsltest'],
expected: Result.ok(['a.Tslpipe', 'b.Tslstub', 'c.Tsltest']),
},
{
testName: 'duplicates',
paths: ['a.sdspipe', 'a.sdspipe'],
expected: Result.ok(['a.sdspipe']),
paths: ['a.Tslpipe', 'a.Tslpipe'],
expected: Result.ok(['a.Tslpipe']),
},
{
testName: 'directory',
paths: ['.'],
expected: Result.ok([
'a.sdspipe',
'b.sdsstub',
'c.sdstest',
'nested/a.sdspipe',
'nested/b.sdsstub',
'nested/c.sdstest',
'a.Tslpipe',
'b.Tslstub',
'c.Tsltest',
'nested/a.Tslpipe',
'nested/b.Tslstub',
'nested/c.Tsltest',
]),
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/ttsl-cli/tests/helpers/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { uriToRelativePath } from '../../src/helpers/files.js';

describe('uriToRelativePath', () => {
it('should return a path that is relative to the current working directory', () => {
const fileName = 'test.sdstest';
const fileName = 'test.Tsltest';
const uri = URI.file(path.join(process.cwd(), fileName));

expect(uriToRelativePath(uri)).toBe(fileName);
Expand Down
2 changes: 1 addition & 1 deletion packages/ttsl-lang/langium-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"id": "safe-ds",
"grammar": "src/language/grammar/safe-ds.langium",
"fileExtensions": [".sdspipe", ".sdsstub", ".sdstest"]
"fileExtensions": [".tsl", ".tsltest"]
}
],
"out": "src/language/generated"
Expand Down
Loading

0 comments on commit 1fae28a

Please sign in to comment.