diff --git a/docs/development/generation-testing.md b/docs/development/generation-testing.md new file mode 100644 index 000000000..37d470d53 --- /dev/null +++ b/docs/development/generation-testing.md @@ -0,0 +1,29 @@ +# Generation Testing + +Generation tests are data-driven instead of being specified explicitly. This document explains how to add a new +generation test. + +## Adding a generation test + +1. Create a new **folder** (not just a file!) in the `tests/resources/generation` directory or any subdirectory. Give + the folder a descriptive name, since the folder name becomes part of the test name. + + !!! tip "Skipping a 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 + 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. +3. Add the Safe-DS code that you want to test to the files. +4. If you want to run the program only up to a specific placeholder of a pipeline, surround **the name** of that + placeholder with test markers, e.g. `val »a« = 1;`. You may only mark a single placeholder this way. Add a comment in + the preceding line with the following format: + ```ts + // $TEST$ run_until + ``` +5. Add another folder called `output` inside the folder that you created in step 1. Place folders and Python files + inside the `output` folder to specify the expected output of the program. The relative paths to the Python files and + the contents of the Python files will be compared to the actual generation output. +6. Run the tests. The test runner will automatically pick up the new test. diff --git a/docs/development/partial-evaluation-testing.md b/docs/development/partial-evaluation-testing.md index d852913e0..867bcefee 100644 --- a/docs/development/partial-evaluation-testing.md +++ b/docs/development/partial-evaluation-testing.md @@ -15,7 +15,7 @@ partial evaluation test. 2. Add files with the extension `.sdstest` **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 file. +3. Add the Safe-DS code that you want to test to the files. 4. Surround entire nodes whose value you want to check with test markers, e.g. `1 + 2`. 5. For each pair of test markers, add a test comment with one of the formats listed below. Test comments and test markers are mapped to each other by their position in the file, i.e. the first test comment corresponds to the first diff --git a/docs/development/scoping-testing.md b/docs/development/scoping-testing.md index 27cc4e583..223b82d8c 100644 --- a/docs/development/scoping-testing.md +++ b/docs/development/scoping-testing.md @@ -15,7 +15,7 @@ test. 2. Add files with the extension `.sdstest` **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 file. +3. Add the Safe-DS code that you want to test to the files. 4. Surround **the name** of any declaration that you want to reference with test markers, e.g. `class »C«`. Add a comment in the preceding line with the following format (replace `` with some unique identifier): ```ts diff --git a/docs/development/typing-testing.md b/docs/development/typing-testing.md index 7adf3d687..82af528f5 100644 --- a/docs/development/typing-testing.md +++ b/docs/development/typing-testing.md @@ -15,7 +15,7 @@ test. 2. Add files with the extension `.sdstest` **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 file. +3. Add the Safe-DS code that you want to test to the files. 4. Surround entire nodes whose type you want to check with test markers, e.g. `1 + 2`. For declarations, it is also possible to surround only their name, e.g. `class »C«`. 5. For each pair of test markers, add a test comment with one of the formats listed below. Test comments and test diff --git a/docs/development/validation-testing.md b/docs/development/validation-testing.md index b37e9b7c1..280865350 100644 --- a/docs/development/validation-testing.md +++ b/docs/development/validation-testing.md @@ -15,7 +15,7 @@ validation test. 2. Add files with the extension `.sdstest`, `.sdspipe`, or `.sdsstub` **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 file. +3. Add the Safe-DS code that you want to test to the files. 4. Specify the expected validation results using test comments (see [below](#format-of-test-comments)) and test markers (e.g. `fun »F«()`). The test comments are used to specify * the presence or absence of an issue, diff --git a/mkdocs.yml b/mkdocs.yml index 0681bfac7..ba38c6fe9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -41,6 +41,7 @@ nav: - Typing Testing: development/typing-testing.md - Partial Evaluation Testing: development/partial-evaluation-testing.md - Validation Testing: development/validation-testing.md + - Generation Testing: development/generation-testing.md - Formatting Testing: development/formatting-testing.md - Langium Quickstart: development/langium-quickstart.md diff --git a/src/cli/cli-util.ts b/src/cli/cli-util.ts index 50db9e224..19f0b723c 100644 --- a/src/cli/cli-util.ts +++ b/src/cli/cli-util.ts @@ -3,6 +3,14 @@ import path from 'path'; import fs from 'fs'; import { AstNode, LangiumDocument, LangiumServices, URI } from 'langium'; +/* c8 ignore start */ +export const extractAstNode = async function ( + fileName: string, + services: LangiumServices, +): Promise { + return (await extractDocument(fileName, services)).parseResult?.value as T; +}; + export const extractDocument = async function (fileName: string, services: LangiumServices): Promise { const extensions = services.LanguageMetaData.fileExtensions; if (!extensions.includes(path.extname(fileName))) { @@ -20,11 +28,11 @@ export const extractDocument = async function (fileName: string, services: Langi const document = services.shared.workspace.LangiumDocuments.getOrCreateDocument(URI.file(path.resolve(fileName))); await services.shared.workspace.DocumentBuilder.build([document], { validation: true }); - const validationErrors = (document.diagnostics ?? []).filter((e) => e.severity === 1); - if (validationErrors.length > 0) { + const errors = (document.diagnostics ?? []).filter((e) => e.severity === 1); + if (errors.length > 0) { // eslint-disable-next-line no-console - console.error(chalk.red('There are validation errors:')); - for (const validationError of validationErrors) { + console.error(chalk.red(`The document ${fileName} has errors:`)); + for (const validationError of errors) { // eslint-disable-next-line no-console console.error( chalk.red( @@ -39,13 +47,7 @@ export const extractDocument = async function (fileName: string, services: Langi return document; }; - -export const extractAstNode = async function ( - fileName: string, - services: LangiumServices, -): Promise { - return (await extractDocument(fileName, services)).parseResult?.value as T; -}; +/* c8 ignore stop */ interface FilePathData { destination: string; diff --git a/src/cli/generator.ts b/src/cli/generator.ts index 37c3f53e2..c1de486d2 100644 --- a/src/cli/generator.ts +++ b/src/cli/generator.ts @@ -7,6 +7,7 @@ import chalk from 'chalk'; import { createSafeDsServices } from '../language/safe-ds-module.js'; import { NodeFileSystem } from 'langium/node'; +/* c8 ignore start */ export const generateAction = async (fileName: string, opts: GenerateOptions): Promise => { const services = createSafeDsServices(NodeFileSystem).SafeDs; const module = await extractAstNode(fileName, services); @@ -14,12 +15,17 @@ export const generateAction = async (fileName: string, opts: GenerateOptions): P // eslint-disable-next-line no-console console.log(chalk.green(`Python code generated successfully: ${generatedFilePath}`)); }; +/* c8 ignore stop */ export type GenerateOptions = { destination?: string; }; -export const generatePython = function (module: SdsModule, filePath: string, destination: string | undefined): string { +export const generatePython = function ( + module: SdsModule, + filePath: string, + destination: string | undefined, +): string[] { const data = extractDestinationAndName(filePath, destination); const generatedFilePath = `${path.join(data.destination, data.name)}.py`; @@ -31,5 +37,5 @@ export const generatePython = function (module: SdsModule, filePath: string, des fs.mkdirSync(data.destination, { recursive: true }); } fs.writeFileSync(generatedFilePath, toString(fileNode)); - return generatedFilePath; + return [generatedFilePath]; }; diff --git a/tests/helpers/diagnostics.ts b/tests/helpers/diagnostics.ts index 6fa62e42e..891aa7c32 100644 --- a/tests/helpers/diagnostics.ts +++ b/tests/helpers/diagnostics.ts @@ -12,12 +12,8 @@ let nextId = 0; * @returns The syntax errors. */ export const getSyntaxErrors = async (services: LangiumServices, code: string): Promise => { - const diagnostics = await getDiagnostics(services, code); - return diagnostics.filter( - (d) => - d.severity === DiagnosticSeverity.Error && - (d.data?.code === 'lexing-error' || d.data?.code === 'parsing-error'), - ); + const diagnostics = await getErrors(services, code); + return diagnostics.filter((d) => d.data?.code === 'lexing-error' || d.data?.code === 'parsing-error'); }; /** @@ -28,8 +24,20 @@ export const getSyntaxErrors = async (services: LangiumServices, code: string): * @returns The errors. */ export const getLinkingErrors = async (services: LangiumServices, code: string): Promise => { + const diagnostics = await getErrors(services, code); + return diagnostics.filter((d) => d.data?.code === 'linking-error'); +}; + +/** + * Get all errors from a code snippet. + * + * @param services The language services. + * @param code The code snippet to check. + * @returns The errors. + */ +export const getErrors = async (services: LangiumServices, code: string): Promise => { const diagnostics = await getDiagnostics(services, code); - return diagnostics.filter((d) => d.severity === DiagnosticSeverity.Error && d.data?.code === 'linking-error'); + return diagnostics.filter((d) => d.severity === DiagnosticSeverity.Error); }; /** @@ -53,8 +61,19 @@ const getDiagnostics = async (services: LangiumServices, code: string): Promise< */ export class SyntaxErrorsInCodeError extends Error { constructor(readonly syntaxErrors: Diagnostic[]) { - const syntaxErrorsAsString = syntaxErrors.map((e) => `- ${e.message}`).join(`\n`); + const syntaxErrorsAsString = syntaxErrors.map((e) => ` - ${e.message}`).join(`\n`); super(`Code has syntax errors:\n${syntaxErrorsAsString}`); } } + +/** + * The code contains syntax errors. + */ +export class ErrorsInCodeError extends Error { + constructor(readonly errors: Diagnostic[]) { + const syntaxErrorsAsString = errors.map((e) => ` - ${e.message}`).join(`\n`); + + super(`Code has errors:\n${syntaxErrorsAsString}`); + } +} diff --git a/tests/helpers/testDescription.ts b/tests/helpers/testDescription.ts new file mode 100644 index 000000000..8a9620a4e --- /dev/null +++ b/tests/helpers/testDescription.ts @@ -0,0 +1,14 @@ +/** + * A description of a test. This interface should be extended to describe tests of specific components. + */ +export interface TestDescription { + /** + * The name of the test. + */ + testName: string; + + /** + * An error that occurred while creating the test. If this is undefined, the test is valid. + */ + error?: Error; +} diff --git a/tests/helpers/testResources.test.ts b/tests/helpers/testResources.test.ts index 89bd4c004..b5090ce4c 100644 --- a/tests/helpers/testResources.test.ts +++ b/tests/helpers/testResources.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest'; -import { listTestResources, listTestsResourcesGroupedByParentDirectory } from './testResources.js'; +import { listSafeDSResources, listTestsResourcesGroupedByParentDirectory } from './testResources.js'; describe('listTestResources', () => { it('should yield all Safe-DS files in a directory that are not skipped', () => { - const result = listTestResources('helpers/listTestResources'); + const result = listSafeDSResources('helpers/listTestResources'); const expected = [ 'pipeline file.sdspipe', 'stub file.sdsstub', diff --git a/tests/helpers/testResources.ts b/tests/helpers/testResources.ts index 831b877df..7d8c86c84 100644 --- a/tests/helpers/testResources.ts +++ b/tests/helpers/testResources.ts @@ -1,6 +1,6 @@ import path from 'path'; import { globSync } from 'glob'; -import { SAFE_DS_FILE_EXTENSIONS } from '../../src/language/helpers/fileExtensions'; +import { SAFE_DS_FILE_EXTENSIONS } from '../../src/language/helpers/fileExtensions.js'; import { group } from 'radash'; const resourcesPath = path.join(__dirname, '..', 'resources'); @@ -21,13 +21,26 @@ export const resolvePathRelativeToResources = (pathRelativeToResources: string) * @param pathRelativeToResources The root directory relative to `tests/resources/`. * @return Paths to the Safe-DS files relative to `pathRelativeToResources`. */ -export const listTestResources = (pathRelativeToResources: string): string[] => { +export const listSafeDSResources = (pathRelativeToResources: string): string[] => { const pattern = `**/*.{${SAFE_DS_FILE_EXTENSIONS.join(',')}}`; const cwd = resolvePathRelativeToResources(pathRelativeToResources); return globSync(pattern, { cwd, nodir: true }).filter(isNotSkipped); }; +/** + * Lists all Python files in the given directory relative to `tests/resources/`. + * + * @param pathRelativeToResources The root directory relative to `tests/resources/`. + * @return Paths to the Python files relative to `pathRelativeToResources`. + */ +export const listPythonResources = (pathRelativeToResources: string): string[] => { + const pattern = `**/*.py`; + const cwd = resolvePathRelativeToResources(pathRelativeToResources); + + return globSync(pattern, { cwd, nodir: true }); +}; + /** * Lists all Safe-DS files in the given directory relative to `tests/resources/` that are not skipped. The result is * grouped by the parent directory. @@ -38,7 +51,7 @@ export const listTestResources = (pathRelativeToResources: string): string[] => export const listTestsResourcesGroupedByParentDirectory = ( pathRelativeToResources: string, ): Record => { - const paths = listTestResources(pathRelativeToResources); + const paths = listSafeDSResources(pathRelativeToResources); return group(paths, (p) => path.dirname(p)) as Record; }; diff --git a/tests/language/formatting/creator.ts b/tests/language/formatting/creator.ts index 59b051985..3c5d38851 100644 --- a/tests/language/formatting/creator.ts +++ b/tests/language/formatting/creator.ts @@ -1,17 +1,18 @@ -import { listTestResources, resolvePathRelativeToResources } from '../../helpers/testResources.js'; +import { listSafeDSResources, resolvePathRelativeToResources } from '../../helpers/testResources.js'; import path from 'path'; import fs from 'fs'; import { Diagnostic } from 'vscode-languageserver-types'; import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; import { EmptyFileSystem } from 'langium'; import { getSyntaxErrors } from '../../helpers/diagnostics.js'; +import { TestDescription } from '../../helpers/testDescription.js'; const services = createSafeDsServices(EmptyFileSystem).SafeDs; const root = 'formatting'; const separator = '// -----------------------------------------------------------------------------'; export const createFormattingTests = async (): Promise => { - const testCases = listTestResources(root).map(createFormattingTest); + const testCases = listSafeDSResources(root).map(createFormattingTest); return Promise.all(testCases); }; @@ -53,12 +54,12 @@ const createFormattingTest = async (relativeResourcePath: string): Promise { +const invalidTest = (relativeResourcePath: string, error: Error): FormattingTest => { return { - testName: `INVALID TEST FILE [${pathRelativeToResources}]`, + testName: `INVALID TEST FILE [${relativeResourcePath}]`, originalCode: '', expectedFormattedCode: '', error, @@ -78,12 +79,7 @@ const normalizeLineBreaks = (code: string): string => { /** * A description of a formatting test. */ -interface FormattingTest { - /** - * The name of the test. - */ - testName: string; - +interface FormattingTest extends TestDescription { /** * The original code before formatting. */ @@ -93,11 +89,6 @@ interface FormattingTest { * The expected formatted code. */ expectedFormattedCode: string; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/language/generation/creator.ts b/tests/language/generation/creator.ts new file mode 100644 index 000000000..b34d80b29 --- /dev/null +++ b/tests/language/generation/creator.ts @@ -0,0 +1,200 @@ +import { + listPythonResources, + listTestsResourcesGroupedByParentDirectory, + resolvePathRelativeToResources, +} from '../../helpers/testResources.js'; +import path from 'path'; +import fs from 'fs'; +import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { ErrorsInCodeError, getErrors } from '../../helpers/diagnostics.js'; +import { URI } from 'vscode-uri'; +import { findTestChecks } from '../../helpers/testChecks.js'; +import { Location } from 'vscode-languageserver'; +import { NodeFileSystem } from 'langium/node'; +import { TestDescription } from '../../helpers/testDescription.js'; +import { locationToString } from '../../helpers/location.js'; + +const services = createSafeDsServices(NodeFileSystem).SafeDs; +await services.shared.workspace.WorkspaceManager.initializeWorkspace([]); +const root = 'generation'; + +export const createGenerationTests = async (): Promise => { + const pathsGroupedByParentDirectory = listTestsResourcesGroupedByParentDirectory(root); + const testCases = Object.entries(pathsGroupedByParentDirectory).map(([dirname, paths]) => + createGenerationTest(dirname, paths), + ); + + return Promise.all(testCases); +}; + +const createGenerationTest = async ( + relativeParentDirectoryPath: string, + relativeResourcePaths: string[], +): Promise => { + const inputUris: string[] = []; + const expectedOutputRoot = path.join(root, relativeParentDirectoryPath, 'output'); + const actualOutputRoot = resolvePathRelativeToResources(path.join(root, relativeParentDirectoryPath, 'generated')); + const expectedOutputFiles = readExpectedOutputFiles(expectedOutputRoot, actualOutputRoot); + let runUntil: Location | undefined; + + for (const relativeResourcePath of relativeResourcePaths) { + const absolutePath = resolvePathRelativeToResources(path.join(root, relativeResourcePath)); + const uri = URI.file(absolutePath).toString(); + inputUris.push(uri); + + const code = fs.readFileSync(absolutePath).toString(); + + // File must not contain any errors + const errors = await getErrors(services, code); + if (errors.length > 0) { + return invalidTest(`INVALID TEST FILE [${relativeResourcePath}]`, new ErrorsInCodeError(errors)); + } + + const checksResult = findTestChecks(code, uri, { failIfFewerRangesThanComments: true }); + + // Something went wrong when finding test checks + if (checksResult.isErr) { + return invalidTest(`INVALID TEST FILE [${relativeResourcePath}]`, checksResult.error); + } + + // Must contain at most one comment + if (checksResult.value.length > 1) { + return invalidTest( + `INVALID TEST FILE [${relativeResourcePath}]`, + new MultipleChecksError(checksResult.value.length), + ); + } + + // Comment must match the expected format + if (checksResult.value.length === 1) { + const check = checksResult.value[0]; + + // Expected unresolved reference + if (check.comment !== 'run_until') { + return invalidTest( + `INVALID TEST FILE [${relativeResourcePath}]`, + new InvalidCommentError(check.comment), + ); + } + } + + // Must not contain multiple run_until locations in various files + const newRunUntil = checksResult.value[0]?.location; + if (runUntil && newRunUntil) { + return invalidTest( + `INVALID TEST SUITE [${relativeParentDirectoryPath}]`, + new MultipleRunUntilLocationsError([runUntil, newRunUntil]), + ); + } + + runUntil = newRunUntil; + } + + return { + testName: `[${relativeParentDirectoryPath}] should be generated correctly`, + inputUris, + actualOutputRoot, + expectedOutputFiles, + runUntil, + }; +}; + +const readExpectedOutputFiles = (expectedOutputRoot: string, actualOutputRoot: string): ExpectedOutputFile[] => { + const relativeResourcePaths = listPythonResources(expectedOutputRoot); + const expectedOutputFiles: ExpectedOutputFile[] = []; + + for (const relativeResourcePath of relativeResourcePaths) { + const absolutePath = resolvePathRelativeToResources(path.join(expectedOutputRoot, relativeResourcePath)); + const code = fs.readFileSync(absolutePath).toString(); + expectedOutputFiles.push({ + absolutePath: path.join(actualOutputRoot, relativeResourcePath), + content: code, + }); + } + + return expectedOutputFiles; +}; + +/** + * Report a test that has errors. + * + * @param testName The name of the test. + * @param error The error that occurred. + */ +const invalidTest = (testName: string, error: Error): GenerationTest => { + return { + testName, + inputUris: [], + actualOutputRoot: '', + expectedOutputFiles: [], + error, + }; +}; + +/** + * A description of a generation test. + */ +interface GenerationTest extends TestDescription { + /** + * The original code. + */ + inputUris: string[]; + + /** + * The directory, where actual output files should be temporarily stored. + */ + actualOutputRoot: string; + + /** + * The expected generated code. + */ + expectedOutputFiles: ExpectedOutputFile[]; + + /** + * Location after which execution should be stopped. + */ + runUntil?: Location; +} + +/** + * A file containing the expected output. + */ +interface ExpectedOutputFile { + /** + * Absolute path to the output file. + */ + absolutePath: string; + + /** + * Content of the output file. + */ + content: string; +} + +/** + * Found multiple test checks. + */ +class MultipleChecksError extends Error { + constructor(readonly count: number) { + super(`Found ${count} test checks (generation tests expect none or one).`); + } +} + +/** + * A test comment did not match the expected format. + */ +class InvalidCommentError extends Error { + constructor(readonly comment: string) { + super(`Invalid test comment (valid values 'run_until'): ${comment}`); + } +} + +/** + * Multiple files have a run_until locations. + */ +class MultipleRunUntilLocationsError extends Error { + constructor(readonly locations: Location[]) { + const locationsString = locations.map((it) => `\n - ${locationToString(it)}`).join(''); + super(`Found multiple run_until locations:${locationsString}`); + } +} diff --git a/tests/language/generation/testGeneration.test.ts b/tests/language/generation/testGeneration.test.ts new file mode 100644 index 000000000..29c5a9d17 --- /dev/null +++ b/tests/language/generation/testGeneration.test.ts @@ -0,0 +1,59 @@ +import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { clearDocuments } from 'langium/test'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { URI } from 'langium'; +import { NodeFileSystem } from 'langium/node'; +import { createGenerationTests } from './creator.js'; +import { SdsModule } from '../../../src/language/generated/ast.js'; +import { generatePython } from '../../../src/cli/generator.js'; +import fs from 'fs'; + +const services = createSafeDsServices(NodeFileSystem).SafeDs; +const generationTests = createGenerationTests(); + +describe('generation', async () => { + beforeEach(async () => { + // Load the builtin library + await services.shared.workspace.WorkspaceManager.initializeWorkspace([]); + }); + + afterEach(async () => { + await clearDocuments(services); + }); + + it.each(await generationTests)('$testName', async (test) => { + // Test is invalid + if (test.error) { + throw test.error; + } + + // Load all documents + const documents = test.inputUris.map((uri) => + services.shared.workspace.LangiumDocuments.getOrCreateDocument(URI.parse(uri)), + ); + await services.shared.workspace.DocumentBuilder.build(documents); + + // Generate code for all documents + const actualOutputPaths: string[] = []; + + for (const document of documents) { + const module = document.parseResult.value as SdsModule; + const fileName = document.uri.fsPath; + const generatedFilePaths = generatePython(module, fileName, test.actualOutputRoot); + actualOutputPaths.push(...generatedFilePaths); + } + + // File paths must match + const expectedOutputPaths = test.expectedOutputFiles.map((file) => file.absolutePath).sort(); + expect(actualOutputPaths.sort()).toStrictEqual(expectedOutputPaths); + + // File contents must match + for (const expectedOutputFile of test.expectedOutputFiles) { + const actualCode = fs.readFileSync(expectedOutputFile.absolutePath).toString(); + expect(actualCode).toBe(expectedOutputFile.content); + } + + // Remove generated files (if the test fails, the files are kept for debugging) + fs.rmSync(test.actualOutputRoot, { recursive: true, force: true }); + }); +}); diff --git a/tests/language/grammar/creator.ts b/tests/language/grammar/creator.ts index 8941b8ea5..528050fb5 100644 --- a/tests/language/grammar/creator.ts +++ b/tests/language/grammar/creator.ts @@ -1,13 +1,14 @@ -import { listTestResources, resolvePathRelativeToResources } from '../../helpers/testResources.js'; +import { listSafeDSResources, resolvePathRelativeToResources } from '../../helpers/testResources.js'; import path from 'path'; import fs from 'fs'; import { findTestComments } from '../../helpers/testComments.js'; import { NoCommentsError } from '../../helpers/testChecks.js'; +import { TestDescription } from '../../helpers/testDescription.js'; const root = 'grammar'; export const createGrammarTests = (): GrammarTest[] => { - return listTestResources(root).map(createGrammarTest); + return listSafeDSResources(root).map(createGrammarTest); }; const createGrammarTest = (relativeResourcePath: string): GrammarTest => { @@ -49,12 +50,12 @@ const createGrammarTest = (relativeResourcePath: string): GrammarTest => { /** * Report a test that has errors. * - * @param pathRelativeToResources The path to the test file relative to the resources directory. + * @param relativeResourcePath The path to the test file relative to the `resources` directory. * @param error The error that occurred. */ -const invalidTest = (pathRelativeToResources: string, error: Error): GrammarTest => { +const invalidTest = (relativeResourcePath: string, error: Error): GrammarTest => { return { - testName: `INVALID TEST FILE [${pathRelativeToResources}]`, + testName: `INVALID TEST FILE [${relativeResourcePath}]`, code: '', expectedResult: 'invalid', error, @@ -64,12 +65,7 @@ const invalidTest = (pathRelativeToResources: string, error: Error): GrammarTest /** * A description of a grammar test. */ -interface GrammarTest { - /** - * The name of the test. - */ - testName: string; - +interface GrammarTest extends TestDescription { /** * The code to parse. */ @@ -79,11 +75,6 @@ interface GrammarTest { * The expected result after parsing the program. */ expectedResult: 'syntax_error' | 'no_syntax_error' | 'invalid'; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/language/partialEvaluation/creator.ts b/tests/language/partialEvaluation/creator.ts index af6255edd..db58539f1 100644 --- a/tests/language/partialEvaluation/creator.ts +++ b/tests/language/partialEvaluation/creator.ts @@ -10,6 +10,7 @@ import { URI } from 'vscode-uri'; import { getSyntaxErrors, SyntaxErrorsInCodeError } from '../../helpers/diagnostics.js'; import { EmptyFileSystem } from 'langium'; import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { TestDescription } from '../../helpers/testDescription.js'; const services = createSafeDsServices(EmptyFileSystem).SafeDs; const root = 'partial evaluation'; @@ -129,12 +130,7 @@ const invalidTest = (testName: string, error: Error): PartialEvaluationTest => { /** * A description of a partial evaluation test. */ -interface PartialEvaluationTest { - /** - * The name of the test. - */ - testName: string; - +interface PartialEvaluationTest extends TestDescription { /** * The URIs of the files that should be loaded into the workspace. */ @@ -154,11 +150,6 @@ interface PartialEvaluationTest { * The node should not evaluate to a constant expression. */ undefinedAssertions: UndefinedAssertion[]; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/language/scoping/creator.ts b/tests/language/scoping/creator.ts index 12f6e2295..ab64a47d7 100644 --- a/tests/language/scoping/creator.ts +++ b/tests/language/scoping/creator.ts @@ -10,6 +10,7 @@ import { URI } from 'vscode-uri'; import { getSyntaxErrors, SyntaxErrorsInCodeError } from '../../helpers/diagnostics.js'; import { EmptyFileSystem } from 'langium'; import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { TestDescription } from '../../helpers/testDescription.js'; const services = createSafeDsServices(EmptyFileSystem).SafeDs; const root = 'scoping'; @@ -135,12 +136,7 @@ const invalidTest = (testName: string, error: Error): ScopingTest => { /** * A description of a scoping test. */ -interface ScopingTest { - /** - * The name of the test. - */ - testName: string; - +interface ScopingTest extends TestDescription { /** * The URIs of the files that should be loaded into the workspace. */ @@ -151,11 +147,6 @@ interface ScopingTest { * checked. */ expectedReferences: ExpectedReference[]; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/language/typing/creator.ts b/tests/language/typing/creator.ts index c541e5657..f1ee8e5ed 100644 --- a/tests/language/typing/creator.ts +++ b/tests/language/typing/creator.ts @@ -10,6 +10,7 @@ import { URI } from 'vscode-uri'; import { getSyntaxErrors, SyntaxErrorsInCodeError } from '../../helpers/diagnostics.js'; import { EmptyFileSystem } from 'langium'; import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; +import { TestDescription } from '../../helpers/testDescription.js'; const services = createSafeDsServices(EmptyFileSystem).SafeDs; const root = 'typing'; @@ -117,12 +118,7 @@ const invalidTest = (testName: string, error: Error): TypingTest => { /** * A description of a typing test. */ -interface TypingTest { - /** - * The name of the test. - */ - testName: string; - +interface TypingTest extends TestDescription { /** * The URIs of the files that should be loaded into the workspace. */ @@ -137,11 +133,6 @@ interface TypingTest { * The serialized type of a node should match the expected type. */ serializationAssertions: SerializationAssertion[]; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/language/validation/creator.ts b/tests/language/validation/creator.ts index 0de3fd37c..a81860fd8 100644 --- a/tests/language/validation/creator.ts +++ b/tests/language/validation/creator.ts @@ -10,6 +10,7 @@ import { getSyntaxErrors, SyntaxErrorsInCodeError } from '../../helpers/diagnost import { EmptyFileSystem } from 'langium'; import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; import { DocumentUri, Range } from 'vscode-languageserver-types'; +import { TestDescription } from '../../helpers/testDescription.js'; const services = createSafeDsServices(EmptyFileSystem).SafeDs; const root = 'validation'; @@ -98,12 +99,12 @@ const createValidationTest = async ( /** * Report a test that has errors. * - * @param testName The name of the test. + * @param relativeResourcePath The path to the test file relative to the `resources` directory. * @param error The error that occurred. */ -const invalidTest = (testName: string, error: Error): ValidationTest => { +const invalidTest = (relativeResourcePath: string, error: Error): ValidationTest => { return { - testName, + testName: `INVALID TEST FILE [${relativeResourcePath}]`, uris: [], expectedIssues: [], error, @@ -113,12 +114,7 @@ const invalidTest = (testName: string, error: Error): ValidationTest => { /** * A description of a validation test. */ -interface ValidationTest { - /** - * The name of the test. - */ - testName: string; - +interface ValidationTest extends TestDescription { /** * The URIs of the files that should be loaded into the workspace. */ @@ -128,11 +124,6 @@ interface ValidationTest { * The issues we expect to find in the workspace. */ expectedIssues: ExpectedIssue[]; - - /** - * An error that occurred while creating the test. If this is undefined, the test is valid. - */ - error?: Error; } /** diff --git a/tests/resources/generation/dummy/output/test.py b/tests/resources/generation/dummy/output/test.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/resources/generation/dummy/test.sdstest b/tests/resources/generation/dummy/test.sdstest new file mode 100644 index 000000000..8e2774107 --- /dev/null +++ b/tests/resources/generation/dummy/test.sdstest @@ -0,0 +1,6 @@ +package tests.generation.dummy + +pipeline myPipeline { + // $TEST$ run_until + val »a« = 1; +} diff --git a/tests/resources/generation/skip-declarations/empty pipeline/input.sdstest b/tests/resources/generation/skip-declarations/empty pipeline/input.sdstest new file mode 100644 index 000000000..bae28156d --- /dev/null +++ b/tests/resources/generation/skip-declarations/empty pipeline/input.sdstest @@ -0,0 +1,3 @@ +package tests.generator.emptyPipeline + +pipeline test {} diff --git a/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input.py b/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input.py new file mode 100644 index 000000000..a90185019 --- /dev/null +++ b/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + pass diff --git a/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input_test.py b/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-declarations/empty pipeline/output/tests/generator/emptyPipeline/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-declarations/empty step/input.sdstest b/tests/resources/generation/skip-declarations/empty step/input.sdstest new file mode 100644 index 000000000..663eb41d6 --- /dev/null +++ b/tests/resources/generation/skip-declarations/empty step/input.sdstest @@ -0,0 +1,3 @@ +package tests.generator.emptyStep + +segment test() {} diff --git a/tests/resources/generation/skip-declarations/empty step/output/tests/generator/emptyStep/gen_input.py b/tests/resources/generation/skip-declarations/empty step/output/tests/generator/emptyStep/gen_input.py new file mode 100644 index 000000000..7a62d7d3c --- /dev/null +++ b/tests/resources/generation/skip-declarations/empty step/output/tests/generator/emptyStep/gen_input.py @@ -0,0 +1,4 @@ +# Steps ------------------------------------------------------------------------ + +def test(): + pass diff --git a/tests/resources/generation/skip-declarations/parameter with python name/input.sdstest b/tests/resources/generation/skip-declarations/parameter with python name/input.sdstest new file mode 100644 index 000000000..860e98ece --- /dev/null +++ b/tests/resources/generation/skip-declarations/parameter with python name/input.sdstest @@ -0,0 +1,14 @@ +package tests.generator.parameterWithPythonName + +fun f1(param: (a: Int, b: Int, c: Int) -> r: Int) +fun f2(param: (a: Int, b: Int, c: Int) -> ()) + +segment test1(param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_3") param3: Int = 0) { + f1((param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_3") param3: Int = 0) -> 1); + f2((param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_3") param3: Int = 0) {}); +} + +segment test2(param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_4") vararg param4: Int) { + f1((param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_4") vararg param4: Int) -> 1); + f2((param1: Int, @PythonName("param_2") param2: Int, @PythonName("param_4") vararg param4: Int) {}); +} diff --git a/tests/resources/generation/skip-declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py b/tests/resources/generation/skip-declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py new file mode 100644 index 000000000..5a04fef8f --- /dev/null +++ b/tests/resources/generation/skip-declarations/parameter with python name/output/tests/generator/parameterWithPythonName/gen_input.py @@ -0,0 +1,13 @@ +# Steps ------------------------------------------------------------------------ + +def test1(param1, param_2, param_3=0): + f1(lambda param1, param_2, param_3=0: 1) + def __block_lambda_0(param1, param_2, param_3=0): + pass + f2(__block_lambda_0) + +def test2(param1, param_2, *param_4): + f1(lambda param1, param_2, *param_4: 1) + def __block_lambda_0(param1, param_2, *param_4): + pass + f2(__block_lambda_0) diff --git a/tests/resources/generation/skip-declarations/pipeline with python name/input.sdstest b/tests/resources/generation/skip-declarations/pipeline with python name/input.sdstest new file mode 100644 index 000000000..785110a0e --- /dev/null +++ b/tests/resources/generation/skip-declarations/pipeline with python name/input.sdstest @@ -0,0 +1,8 @@ +package tests.generator.pipelineWithPythonName + +fun f() + +@PythonName("test_pipeline") +pipeline testPipeline { + f(); +} diff --git a/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input.py b/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input.py new file mode 100644 index 000000000..209629e85 --- /dev/null +++ b/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def test_pipeline(): + f() diff --git a/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input_test_pipeline.py b/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input_test_pipeline.py new file mode 100644 index 000000000..dd260d08e --- /dev/null +++ b/tests/resources/generation/skip-declarations/pipeline with python name/output/tests/generator/pipelineWithPythonName/gen_input_test_pipeline.py @@ -0,0 +1,4 @@ +from gen_input import test_pipeline + +if __name__ == '__main__': + test_pipeline() diff --git a/tests/resources/generation/skip-declarations/step with python name/input.sdstest b/tests/resources/generation/skip-declarations/step with python name/input.sdstest new file mode 100644 index 000000000..a58e4b5b0 --- /dev/null +++ b/tests/resources/generation/skip-declarations/step with python name/input.sdstest @@ -0,0 +1,8 @@ +package tests.generator.stepWithPythonName + +fun f() + +@PythonName("test_step") +segment testStep() { + f(); +} diff --git a/tests/resources/generation/skip-declarations/step with python name/output/tests/generator/stepWithPythonName/gen_input.py b/tests/resources/generation/skip-declarations/step with python name/output/tests/generator/stepWithPythonName/gen_input.py new file mode 100644 index 000000000..26cbaeb4d --- /dev/null +++ b/tests/resources/generation/skip-declarations/step with python name/output/tests/generator/stepWithPythonName/gen_input.py @@ -0,0 +1,4 @@ +# Steps ------------------------------------------------------------------------ + +def test_step(): + f() diff --git a/tests/resources/generation/skip-declarations/two pipelines/input.sdstest b/tests/resources/generation/skip-declarations/two pipelines/input.sdstest new file mode 100644 index 000000000..1c275d268 --- /dev/null +++ b/tests/resources/generation/skip-declarations/two pipelines/input.sdstest @@ -0,0 +1,11 @@ +package tests.generator.twoPipelines + +fun f() + +pipeline test1 { + f(); +} + +pipeline test2 { + f(); +} diff --git a/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input.py b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input.py new file mode 100644 index 000000000..a8efe6ddd --- /dev/null +++ b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input.py @@ -0,0 +1,7 @@ +# Pipelines -------------------------------------------------------------------- + +def test1(): + f() + +def test2(): + f() diff --git a/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test1.py b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test1.py new file mode 100644 index 000000000..d4cb15745 --- /dev/null +++ b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test1.py @@ -0,0 +1,4 @@ +from gen_input import test1 + +if __name__ == '__main__': + test1() diff --git a/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test2.py b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test2.py new file mode 100644 index 000000000..96daa0217 --- /dev/null +++ b/tests/resources/generation/skip-declarations/two pipelines/output/tests/generator/twoPipelines/gen_input_test2.py @@ -0,0 +1,4 @@ +from gen_input import test2 + +if __name__ == '__main__': + test2() diff --git a/tests/resources/generation/skip-declarations/two steps/input.sdstest b/tests/resources/generation/skip-declarations/two steps/input.sdstest new file mode 100644 index 000000000..8c21e4602 --- /dev/null +++ b/tests/resources/generation/skip-declarations/two steps/input.sdstest @@ -0,0 +1,11 @@ +package tests.generator.twoSteps + +fun f() + +segment test1(a: Int, b: Int = 0) { + f(); +} + +segment test2(a: Int, vararg c: Int) { + f(); +} diff --git a/tests/resources/generation/skip-declarations/two steps/output/tests/generator/twoSteps/gen_input.py b/tests/resources/generation/skip-declarations/two steps/output/tests/generator/twoSteps/gen_input.py new file mode 100644 index 000000000..bb0c1f51b --- /dev/null +++ b/tests/resources/generation/skip-declarations/two steps/output/tests/generator/twoSteps/gen_input.py @@ -0,0 +1,7 @@ +# Steps ------------------------------------------------------------------------ + +def test1(a, b=0): + f() + +def test2(a, *c): + f() diff --git a/tests/resources/generation/skip-expressions/block lambda/input.sdstest b/tests/resources/generation/skip-expressions/block lambda/input.sdstest new file mode 100644 index 000000000..6105b6ad0 --- /dev/null +++ b/tests/resources/generation/skip-expressions/block lambda/input.sdstest @@ -0,0 +1,17 @@ +package tests.generator.blockLambda + +fun f1(param: (a: Int, b: Int) -> r: Int) +fun f2(param: (a: Int, vararg b: Int) -> r: Int) +fun f3(param: () -> ()) + +fun g() -> a: Int + +pipeline test { + f1((a: Int, b: Int = 2) { + yield d = g(); + }); + f2((a: Int, vararg c: Int) { + yield d = g(); + }); + f3(() {}); +} diff --git a/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input.py b/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input.py new file mode 100644 index 000000000..57e2b1fcf --- /dev/null +++ b/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input.py @@ -0,0 +1,14 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + def __block_lambda_0(a, b=2): + d = g() + return d + f1(__block_lambda_0) + def __block_lambda_1(a, *c): + d = g() + return d + f2(__block_lambda_1) + def __block_lambda_2(): + pass + f3(__block_lambda_2) diff --git a/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input_test.py b/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/block lambda/output/tests/generator/blockLambda/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/call/input.sdstest b/tests/resources/generation/skip-expressions/call/input.sdstest new file mode 100644 index 000000000..655b2e2a7 --- /dev/null +++ b/tests/resources/generation/skip-expressions/call/input.sdstest @@ -0,0 +1,32 @@ +package tests.generator.call + +fun f(param: Any?) + +fun g1( + param1: Int, + param2: Int = 0 +) -> result: Boolean + +fun g2( + param1: Int, + vararg param3: Int +) -> result: Boolean + +fun h1( + @PythonName("param_1") param1: Int, + @PythonName("param_2") param2: Int = 0 +) -> result: Boolean + +fun h2( + @PythonName("param_1") param1: Int, + @PythonName("param_3") vararg param3: Int +) -> result: Boolean + +pipeline test { + f((g1(1, 2))); + f((g1(param2 = 1, param1 = 2))); + f((g2(2, 3, 4))); + f((h1(1, 2))); + f((h1(param2 = 1, param1 = 2))); + f((h2(2, 3, 4))); +} diff --git a/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input.py b/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input.py new file mode 100644 index 000000000..37634f44a --- /dev/null +++ b/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input.py @@ -0,0 +1,9 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(g1(1, param2=2)) + f(g1(2, param2=1)) + f(g2(2, 3, 4)) + f(h1(1, param_2=2)) + f(h1(2, param_2=1)) + f(h2(2, 3, 4)) diff --git a/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input_test.py b/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/call/output/tests/generator/call/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/constant/input.sdstest b/tests/resources/generation/skip-expressions/constant/input.sdstest new file mode 100644 index 000000000..3b4e0e978 --- /dev/null +++ b/tests/resources/generation/skip-expressions/constant/input.sdstest @@ -0,0 +1,11 @@ +package tests.generator.constant + +fun f(param: Any?) + +pipeline test { + f(1 < 2); + f(1.0 - 1.0); + f(1 + 1); + f(null); + f("person: {{ "me" }}"); +} diff --git a/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input.py b/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input.py new file mode 100644 index 000000000..6f2601b01 --- /dev/null +++ b/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input.py @@ -0,0 +1,8 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(True) + f(0.0) + f(2) + f(None) + f('person: me') diff --git a/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input_test.py b/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/constant/output/tests/generator/constant/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/enum variant call/input.sdstest b/tests/resources/generation/skip-expressions/enum variant call/input.sdstest new file mode 100644 index 000000000..d113a4972 --- /dev/null +++ b/tests/resources/generation/skip-expressions/enum variant call/input.sdstest @@ -0,0 +1,16 @@ +// Related to https://github.com/lars-reimann/Safe-DS/issues/118 + +package tests.generator.enumVariantCall + +fun f(p: Any) + +enum MyEnum { + Variant1 + Variant2(counter: Int) +} + +pipeline test { + f(MyEnum.Variant1); + f(MyEnum.Variant1()); + f(MyEnum.Variant2(1)); +} diff --git a/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input.py b/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input.py new file mode 100644 index 000000000..1a9a4f9d8 --- /dev/null +++ b/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input.py @@ -0,0 +1,6 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(MyEnum.Variant1()) + f(MyEnum.Variant1()) + f(MyEnum.Variant2(1)) diff --git a/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input_test.py b/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/enum variant call/output/tests/generator/enumVariantCall/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/expression lambda/input.sdstest b/tests/resources/generation/skip-expressions/expression lambda/input.sdstest new file mode 100644 index 000000000..6d49a6ce7 --- /dev/null +++ b/tests/resources/generation/skip-expressions/expression lambda/input.sdstest @@ -0,0 +1,9 @@ +package tests.generator.expressionLambda + +fun f1(param: (a: Int, b: Int) -> r: Int) +fun f2(param: (a: Int, vararg c: Int) -> r: Int) + +pipeline test { + f1((a, b = 2) -> 1); + f2((a, vararg c) -> 1); +} diff --git a/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py b/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py new file mode 100644 index 000000000..9399f7d79 --- /dev/null +++ b/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input.py @@ -0,0 +1,5 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f1(lambda a, b=2: 1) + f2(lambda a, *c: 1) diff --git a/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input_test.py b/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/expression lambda/output/tests/generator/expressionLambda/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/indexed access/input.sdstest b/tests/resources/generation/skip-expressions/indexed access/input.sdstest new file mode 100644 index 000000000..4532ca536 --- /dev/null +++ b/tests/resources/generation/skip-expressions/indexed access/input.sdstest @@ -0,0 +1,7 @@ +package tests.generator.indexedAccess + +fun f(param: Any?) + +segment test(vararg params: Int) { + f(params[0]); +} diff --git a/tests/resources/generation/skip-expressions/indexed access/output/tests/generator/indexedAccess/gen_input.py b/tests/resources/generation/skip-expressions/indexed access/output/tests/generator/indexedAccess/gen_input.py new file mode 100644 index 000000000..2673de5a6 --- /dev/null +++ b/tests/resources/generation/skip-expressions/indexed access/output/tests/generator/indexedAccess/gen_input.py @@ -0,0 +1,4 @@ +# Steps ------------------------------------------------------------------------ + +def test(*params): + f(params[0]) diff --git a/tests/resources/generation/skip-expressions/infix operation/input.sdstest b/tests/resources/generation/skip-expressions/infix operation/input.sdstest new file mode 100644 index 000000000..db73c3389 --- /dev/null +++ b/tests/resources/generation/skip-expressions/infix operation/input.sdstest @@ -0,0 +1,31 @@ +package tests.generator.infixOperation + +fun f(param: Any?) + +fun g() -> result: Boolean + +fun h() -> result: Int + +fun i() -> result: Int? + +pipeline test { + f(g() or g()); + f(g() and g()); + + f(h() == h()); + f(h() != h()); + f(h() === h()); + f(h() !== h()); + + f(h() < h()); + f(h() <= h()); + f(h() >= h()); + f(h() > h()); + + f(h() + h()); + f(h() - h()); + f(h() * h()); + f(h() / h()); + + f(i() ?: i()); +} diff --git a/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input.py b/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input.py new file mode 100644 index 000000000..b9d770db1 --- /dev/null +++ b/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input.py @@ -0,0 +1,22 @@ +# Imports ---------------------------------------------------------------------- + +import safeds_runner.codegen + +# Pipelines -------------------------------------------------------------------- + +def test(): + f(safeds_runner.codegen.eager_or(g(), g())) + f(safeds_runner.codegen.eager_and(g(), g())) + f((h()) == (h())) + f((h()) != (h())) + f((h()) is (h())) + f((h()) is not (h())) + f((h()) < (h())) + f((h()) <= (h())) + f((h()) >= (h())) + f((h()) > (h())) + f((h()) + (h())) + f((h()) - (h())) + f((h()) * (h())) + f((h()) / (h())) + f(safeds_runner.codegen.eager_elvis(i(), i())) diff --git a/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input_test.py b/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/infix operation/output/tests/generator/infixOperation/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/literals/input.sdstest b/tests/resources/generation/skip-expressions/literals/input.sdstest new file mode 100644 index 000000000..175fcf838 --- /dev/null +++ b/tests/resources/generation/skip-expressions/literals/input.sdstest @@ -0,0 +1,14 @@ +package tests.generator.literals + +fun f(param: Any?) + +pipeline test { + f(true); + f(false); + f(1.0); + f(1); + f(null); + f(""); + f("multi +line"); +} diff --git a/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input.py b/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input.py new file mode 100644 index 000000000..71832fd6d --- /dev/null +++ b/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input.py @@ -0,0 +1,10 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(True) + f(False) + f(1.0) + f(1) + f(None) + f('') + f('multi\nline') diff --git a/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input_test.py b/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/literals/output/tests/generator/literals/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/member access/input.sdstest b/tests/resources/generation/skip-expressions/member access/input.sdstest new file mode 100644 index 000000000..2c8f26592 --- /dev/null +++ b/tests/resources/generation/skip-expressions/member access/input.sdstest @@ -0,0 +1,24 @@ +package tests.generator.memberAccess + +fun f(param: Any?) + +fun g() -> result: Boolean + +fun h() -> (result1: Boolean, result2: Boolean) + +class C() { + attr a: Int + @PythonName("c") attr b: Int +} + +fun factory() -> instance: C? + +pipeline test { + f(g().result); + f(h().result1); + f(h().result2); + f(C().a); + f(C().b); + f(factory()?.a); + f(factory()?.b); +} diff --git a/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input.py b/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input.py new file mode 100644 index 000000000..2d8cbe6ac --- /dev/null +++ b/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input.py @@ -0,0 +1,14 @@ +# Imports ---------------------------------------------------------------------- + +import safeds_runner.codegen + +# Pipelines -------------------------------------------------------------------- + +def test(): + f(g()) + f(h()[0]) + f(h()[1]) + f(C().a) + f(C().c) + f(safeds_runner.codegen.safe_access(factory(), 'a')) + f(safeds_runner.codegen.safe_access(factory(), 'c')) diff --git a/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input_test.py b/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/member access/output/tests/generator/memberAccess/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/parenthesized expression/input.sdstest b/tests/resources/generation/skip-expressions/parenthesized expression/input.sdstest new file mode 100644 index 000000000..1b4b0ebad --- /dev/null +++ b/tests/resources/generation/skip-expressions/parenthesized expression/input.sdstest @@ -0,0 +1,9 @@ +package tests.generator.parenthesizedExpression + +fun f(param: Any?) + +fun g() -> result: Boolean + +pipeline test { + f((g())); +} diff --git a/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input.py b/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input.py new file mode 100644 index 000000000..00162f3cf --- /dev/null +++ b/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(g()) diff --git a/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input_test.py b/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/parenthesized expression/output/tests/generator/parenthesizedExpression/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/prefix operation/input.sdstest b/tests/resources/generation/skip-expressions/prefix operation/input.sdstest new file mode 100644 index 000000000..fa66e2cff --- /dev/null +++ b/tests/resources/generation/skip-expressions/prefix operation/input.sdstest @@ -0,0 +1,12 @@ +package tests.generator.prefixOperation + +fun f(param: Any?) + +fun g() -> result: Boolean + +fun h() -> result: Int + +pipeline test { + f(not g()); + f(-h()); +} diff --git a/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input.py b/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input.py new file mode 100644 index 000000000..138c6bf3f --- /dev/null +++ b/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input.py @@ -0,0 +1,5 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(not (g())) + f(-(h())) diff --git a/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input_test.py b/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/prefix operation/output/tests/generator/prefixOperation/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/reference/input.sdstest b/tests/resources/generation/skip-expressions/reference/input.sdstest new file mode 100644 index 000000000..78979c9ad --- /dev/null +++ b/tests/resources/generation/skip-expressions/reference/input.sdstest @@ -0,0 +1,10 @@ +package tests.generator.reference + +fun f(param: Any?) + +@PythonName("explain_model") +fun explainModel() -> result: Int + +pipeline test { + f(explainModel()); +} diff --git a/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input.py b/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input.py new file mode 100644 index 000000000..149d8bb65 --- /dev/null +++ b/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(explain_model()) diff --git a/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input_test.py b/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/reference/output/tests/generator/reference/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-expressions/template string/input.sdstest b/tests/resources/generation/skip-expressions/template string/input.sdstest new file mode 100644 index 000000000..2c4348f8c --- /dev/null +++ b/tests/resources/generation/skip-expressions/template string/input.sdstest @@ -0,0 +1,12 @@ +package tests.generator.templateString + +fun f(param: Any?) + +fun g() -> result: Int + +pipeline test { + f("start +{{ g() }} +inner {{ g() }} +end"); +} diff --git a/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input.py b/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input.py new file mode 100644 index 000000000..7756f36ad --- /dev/null +++ b/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input.py @@ -0,0 +1,4 @@ +# Pipelines -------------------------------------------------------------------- + +def test(): + f(f'start\n{ g() }\ninner { g() }\nend') diff --git a/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input_test.py b/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-expressions/template string/output/tests/generator/templateString/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-imports/context different package.sdsstub b/tests/resources/generation/skip-imports/context different package.sdsstub new file mode 100644 index 000000000..fd7d34dd4 --- /dev/null +++ b/tests/resources/generation/skip-imports/context different package.sdsstub @@ -0,0 +1,4 @@ +package tests.generator.differentPackage + +fun function1InDifferentPackage() -> result: Int +fun function2InDifferentPackage() -> result: Int diff --git a/tests/resources/generation/skip-imports/context package with python module.sdsstub b/tests/resources/generation/skip-imports/context package with python module.sdsstub new file mode 100644 index 000000000..adc1112f6 --- /dev/null +++ b/tests/resources/generation/skip-imports/context package with python module.sdsstub @@ -0,0 +1,6 @@ +@PythonModule("special_location") + +package tests.generator.withPythonModule + +fun function1InCompilationUnitWithPythonModule() -> result: Int +fun function2InCompilationUnitWithPythonModule() -> result: Int diff --git a/tests/resources/generation/skip-imports/context same package.sdstest b/tests/resources/generation/skip-imports/context same package.sdstest new file mode 100644 index 000000000..6cde20255 --- /dev/null +++ b/tests/resources/generation/skip-imports/context same package.sdstest @@ -0,0 +1,11 @@ +package tests.generator.imports + +fun impureFunction() -> result: Int + +segment step1InSamePackage() -> result: Int { + yield result = impureFunction(); +} + +segment step2InSamePackage() -> result: Int { + yield result = impureFunction(); +} diff --git a/tests/resources/generation/skip-imports/input.sdstest b/tests/resources/generation/skip-imports/input.sdstest new file mode 100644 index 000000000..bd19aeb47 --- /dev/null +++ b/tests/resources/generation/skip-imports/input.sdstest @@ -0,0 +1,25 @@ +package tests.generator.imports + +from tests.generator.differentPackage import function1InDifferentPackage +from tests.generator.differentPackage import function2InDifferentPackage as g +from tests.generator.withPythonModule import function1InCompilationUnitWithPythonModule +from tests.generator.withPythonModule import function2InCompilationUnitWithPythonModule as h + +fun f(param: Any?) + +pipeline test { + f(step1InSamePackage()); + f(step1InSamePackage()); + f(step2InSamePackage()); + f(step2InSamePackage()); + + f(function1InDifferentPackage()); + f(function1InDifferentPackage()); + f(g()); + f(g()); + + f(function1InCompilationUnitWithPythonModule()); + f(function1InCompilationUnitWithPythonModule()); + f(h()); + f(h()); +} diff --git a/tests/resources/generation/skip-imports/output/tests/generator/imports/gen__skip__context_same_package.py b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen__skip__context_same_package.py new file mode 100644 index 000000000..4f69c70b4 --- /dev/null +++ b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen__skip__context_same_package.py @@ -0,0 +1,9 @@ +# Steps ------------------------------------------------------------------------ + +def step1InSamePackage(): + result = impureFunction() + return result + +def step2InSamePackage(): + result = impureFunction() + return result diff --git a/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input.py b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input.py new file mode 100644 index 000000000..1010e1898 --- /dev/null +++ b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input.py @@ -0,0 +1,21 @@ +# Imports ---------------------------------------------------------------------- + +from special_location import function1InCompilationUnitWithPythonModule, function2InCompilationUnitWithPythonModule as h +from tests.generator.differentPackage import function1InDifferentPackage, function2InDifferentPackage as g +from tests.generator.imports.gen__skip__context_same_package import step1InSamePackage, step2InSamePackage + +# Pipelines -------------------------------------------------------------------- + +def test(): + f(step1InSamePackage()) + f(step1InSamePackage()) + f(step2InSamePackage()) + f(step2InSamePackage()) + f(function1InDifferentPackage()) + f(function1InDifferentPackage()) + f(g()) + f(g()) + f(function1InCompilationUnitWithPythonModule()) + f(function1InCompilationUnitWithPythonModule()) + f(h()) + f(h()) diff --git a/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input_test.py b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input_test.py new file mode 100644 index 000000000..30abe031d --- /dev/null +++ b/tests/resources/generation/skip-imports/output/tests/generator/imports/gen_input_test.py @@ -0,0 +1,4 @@ +from gen_input import test + +if __name__ == '__main__': + test() diff --git a/tests/resources/generation/skip-python module/input.sdstest b/tests/resources/generation/skip-python module/input.sdstest new file mode 100644 index 000000000..adc8e2fe5 --- /dev/null +++ b/tests/resources/generation/skip-python module/input.sdstest @@ -0,0 +1,9 @@ +@PythonModule("special_module") + +package tests.generator.pythonModule + +fun f() + +segment test() { + f(); +} diff --git a/tests/resources/generation/skip-python module/output/special_module/gen_input.py b/tests/resources/generation/skip-python module/output/special_module/gen_input.py new file mode 100644 index 000000000..5c10c6069 --- /dev/null +++ b/tests/resources/generation/skip-python module/output/special_module/gen_input.py @@ -0,0 +1,4 @@ +# Steps ------------------------------------------------------------------------ + +def test(): + f() diff --git a/tests/resources/generation/skip-statements/assignment/input.sdstest b/tests/resources/generation/skip-statements/assignment/input.sdstest new file mode 100644 index 000000000..3f7bc5afe --- /dev/null +++ b/tests/resources/generation/skip-statements/assignment/input.sdstest @@ -0,0 +1,30 @@ +package tests.generator.assignment + +fun f1(param: Any?) +fun f2(param: () -> r: Int?) + +fun g() -> (a: Int, b: Int, c: Int) + +pipeline testPipeline { + _, _ ,_ = g(); + val a, _, _ = g(); + val x = g(); + f1(a); + f1(x); + + f2(() { + _, _ ,_ = g(); + val a, _, yield c = g(); + val x = g(); + f1(a); + f1(x); + }); +} + +segment testStep() -> c: Int { + _, _ ,_ = g(); + val a, _, yield c = g(); + val x = g(); + f1(a); + f1(x); +} diff --git a/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input.py b/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input.py new file mode 100644 index 000000000..8c24c2309 --- /dev/null +++ b/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input.py @@ -0,0 +1,32 @@ +# Imports ---------------------------------------------------------------------- + +import runtimeBridge + +# Steps ------------------------------------------------------------------------ + +def testStep(): + g() + a, _, c = g() + x, _, _ = g() + f1(a) + f1(x) + return c + +# Pipelines -------------------------------------------------------------------- + +def testPipeline(): + g() + a, _, _ = g() + runtimeBridge.save_placeholder('a', a) + x, _, _ = g() + runtimeBridge.save_placeholder('x', x) + f1(a) + f1(x) + def __block_lambda_0(): + g() + a, _, c = g() + x, _, _ = g() + f1(a) + f1(x) + return c + f2(__block_lambda_0) diff --git a/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input_testPipeline.py b/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input_testPipeline.py new file mode 100644 index 000000000..7a825d09d --- /dev/null +++ b/tests/resources/generation/skip-statements/assignment/output/tests/generator/assignment/gen_input_testPipeline.py @@ -0,0 +1,4 @@ +from gen_input import testPipeline + +if __name__ == '__main__': + testPipeline() diff --git a/tests/resources/generation/skip-statements/expression statement/input.sdstest b/tests/resources/generation/skip-statements/expression statement/input.sdstest new file mode 100644 index 000000000..27b87e6ff --- /dev/null +++ b/tests/resources/generation/skip-statements/expression statement/input.sdstest @@ -0,0 +1,17 @@ +package tests.generator.expressionStatement + +fun f(param: () -> ()) + +fun g() -> result: Int + +pipeline testPipeline { + g(); + + f(() { + g(); + }); +} + +segment testStep() { + g(); +} diff --git a/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input.py b/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input.py new file mode 100644 index 000000000..f77b73f00 --- /dev/null +++ b/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input.py @@ -0,0 +1,12 @@ +# Steps ------------------------------------------------------------------------ + +def testStep(): + g() + +# Pipelines -------------------------------------------------------------------- + +def testPipeline(): + g() + def __block_lambda_0(): + g() + f(__block_lambda_0) diff --git a/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input_testPipeline.py b/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input_testPipeline.py new file mode 100644 index 000000000..7a825d09d --- /dev/null +++ b/tests/resources/generation/skip-statements/expression statement/output/tests/generator/expressionStatement/gen_input_testPipeline.py @@ -0,0 +1,4 @@ +from gen_input import testPipeline + +if __name__ == '__main__': + testPipeline() diff --git a/tests/resources/generation/skip-statements/statement without effect/input.sdstest b/tests/resources/generation/skip-statements/statement without effect/input.sdstest new file mode 100644 index 000000000..cf9d06e4c --- /dev/null +++ b/tests/resources/generation/skip-statements/statement without effect/input.sdstest @@ -0,0 +1,18 @@ +package tests.generator.statementWithoutEffect + +fun f(param: () -> ()) + +pipeline testPipeline { + 1; + _ = 1; + + f(() { + 1; + _ = 1; + }); +} + +segment testStep() { + 1; + _ = 1; +} diff --git a/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input.py b/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input.py new file mode 100644 index 000000000..85e9e98ee --- /dev/null +++ b/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input.py @@ -0,0 +1,11 @@ +# Steps ------------------------------------------------------------------------ + +def testStep(): + pass + +# Pipelines -------------------------------------------------------------------- + +def testPipeline(): + def __block_lambda_0(): + pass + f(__block_lambda_0) diff --git a/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input_testPipeline.py b/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input_testPipeline.py new file mode 100644 index 000000000..7a825d09d --- /dev/null +++ b/tests/resources/generation/skip-statements/statement without effect/output/tests/generator/statementWithoutEffect/gen_input_testPipeline.py @@ -0,0 +1,4 @@ +from gen_input import testPipeline + +if __name__ == '__main__': + testPipeline()