From 2697b7be65f4ffc8527ca840be3168c9027771b0 Mon Sep 17 00:00:00 2001 From: ivojawer Date: Mon, 30 Dec 2024 02:18:34 -0300 Subject: [PATCH] definition.wlk var --- test/dynamicDiagram.test.ts | 18 +++++++++--------- test/interpreter.test.ts | 26 +++++++++++++------------- test/utils.ts | 5 +++-- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/test/dynamicDiagram.test.ts b/test/dynamicDiagram.test.ts index 0d3e42cc..e6281077 100644 --- a/test/dynamicDiagram.test.ts +++ b/test/dynamicDiagram.test.ts @@ -3,7 +3,7 @@ import { BOOLEAN_MODULE, buildEnvironment, CLOSURE_MODULE, DATE_MODULE, DICTIONA import { DynamicDiagramElement, DynamicDiagramNode, DynamicDiagramReference } from '../src/interpreter/dynamicDiagram' import { interprete, Interpreter } from '../src/interpreter/interpreter' import linker from '../src/linker' -import { environmentWithREPLInitializedFile, INIT_FILE, WREEnvironment } from './utils' +import { environmentWithREPLInitializedFile, INIT_PACKAGE_NAME, WREEnvironment } from './utils' describe('Dynamic diagram', () => { @@ -263,23 +263,23 @@ describe('Dynamic diagram', () => { referenceLabel: 'pepona', targetLabel: 'Ave', targetType: 'object', - targetModule: INIT_FILE + '.Ave', + targetModule: INIT_PACKAGE_NAME + '.Ave', }) checkConnection(elements, { sourceLabel: 'Ave', referenceLabel: 'amigue', targetLabel: 'pepita', targetType: 'object', - sourceModule: INIT_FILE + '.Ave', - targetModule: INIT_FILE + '.pepita', + sourceModule: INIT_PACKAGE_NAME + '.Ave', + targetModule: INIT_PACKAGE_NAME + '.pepita', }) checkConnection(elements, { sourceLabel: 'pepita', referenceLabel: 'amigue', targetLabel: 'Ave', targetType: 'object', - sourceModule: INIT_FILE + '.pepita', - targetModule: INIT_FILE + '.Ave', + sourceModule: INIT_PACKAGE_NAME + '.pepita', + targetModule: INIT_PACKAGE_NAME + '.Ave', }) checkNoConnectionToREPL(elements, 'pepita') }) @@ -299,15 +299,15 @@ describe('Dynamic diagram', () => { referenceLabel: 'pepita', targetLabel: 'Ave', targetType: 'object', - targetModule: INIT_FILE + '.Ave', + targetModule: INIT_PACKAGE_NAME + '.Ave', }) checkConnection(elements, { sourceLabel: 'Ave', referenceLabel: 'amigue', targetLabel: 'Ave', targetType: 'object', - sourceModule: INIT_FILE + '.Ave', - targetModule: INIT_FILE + '.Ave', + sourceModule: INIT_PACKAGE_NAME + '.Ave', + targetModule: INIT_PACKAGE_NAME + '.Ave', }) }) diff --git a/test/interpreter.test.ts b/test/interpreter.test.ts index 5bec5f19..43d992d6 100644 --- a/test/interpreter.test.ts +++ b/test/interpreter.test.ts @@ -5,7 +5,7 @@ import { buildEnvironment, Evaluation, EXCEPTION_MODULE, REPL, WRENatives } from import { DirectedInterpreter, getStackTraceSanitized, interprete, Interpreter } from '../src/interpreter/interpreter' import link from '../src/linker' import { Body, Class, Field, Literal, Method, Package, ParameterizedType, Reference, Return, Send, Singleton, SourceIndex, SourceMap } from '../src/model' -import { environmentWithREPLInitializedFile, WREEnvironment } from './utils' +import { environmentWithREPLInitializedFile, INIT_FILE, INIT_PACKAGE_NAME, WREEnvironment } from './utils' use(sinonChai) should() @@ -312,7 +312,7 @@ describe('Wollok Interpreter', () => { } `, }, { - name: 'definitions.wlk', content: ` + name: INIT_FILE, content: ` import medico.* object testit { @@ -320,7 +320,7 @@ describe('Wollok Interpreter', () => { } `, }]) - replEnvironment.scope.register([REPL, replEnvironment.getNodeByFQN('definitions')!]) + replEnvironment.scope.register([REPL, replEnvironment.getNodeByFQN(INIT_PACKAGE_NAME)!]) interpreter = new Interpreter(Evaluation.build(replEnvironment, WRENatives)) const { error, result } = interprete(interpreter, 'testit.test()') expect(error).to.be.undefined @@ -382,7 +382,7 @@ describe('Wollok Interpreter', () => { } `, }, { - name: 'definitions.wlk', content: ` + name: INIT_PACKAGE_NAME, content: ` import pediatra.* object testit { @@ -391,7 +391,7 @@ describe('Wollok Interpreter', () => { `, }]) - replEnvironment.scope.register([REPL, replEnvironment.getNodeByFQN('definitions')!]) + replEnvironment.scope.register([REPL, replEnvironment.getNodeByFQN(INIT_PACKAGE_NAME)!]) interpreter = new Interpreter(Evaluation.build(replEnvironment, WRENatives)) const { error, result } = interprete(interpreter, 'testit.test()') expect(error).to.be.undefined @@ -505,7 +505,7 @@ describe('Wollok Interpreter', () => { expect(getStackTraceSanitized(error)).to.deep.equal( [ 'wollok.lang.EvaluationError: RangeError: super call for message fly/1: parameter #1 produces no value, cannot use it', - ' at definitions.MockingBird.fly(minutes) [definitions.wlk:11]', + ` at ${INIT_PACKAGE_NAME}.MockingBird.fly(minutes) [${INIT_PACKAGE_NAME}.wlk:11]`, ] ) }) @@ -527,7 +527,7 @@ describe('Wollok Interpreter', () => { expect(getStackTraceSanitized(error)).to.deep.equal( [ 'wollok.lang.EvaluationError: RangeError: Message fly - if condition produces no value, cannot use it', - ' at definitions.Bird.fly(minutes) [definitions.wlk:5]', + ` at ${INIT_PACKAGE_NAME}.Bird.fly(minutes) [${INIT_PACKAGE_NAME}.wlk:5]`, ] ) }) @@ -643,8 +643,8 @@ describe('Wollok Interpreter', () => { } `) interpreter = new Interpreter(Evaluation.build(replEnvironment, WRENatives)) - expectError('new Bird(energy = void)', 'wollok.lang.EvaluationError: RangeError: new definitions.Bird: value of parameter \'energy\' produces no value, cannot use it') - expectError('new Bird(energy = 150, name = [1].add(2))', 'wollok.lang.EvaluationError: RangeError: new definitions.Bird: value of parameter \'name\' produces no value, cannot use it') + expectError('new Bird(energy = void)', `wollok.lang.EvaluationError: RangeError: new ${INIT_PACKAGE_NAME}.Bird: value of parameter 'energy' produces no value, cannot use it`) + expectError('new Bird(energy = 150, name = [1].add(2))', `wollok.lang.EvaluationError: RangeError: new ${INIT_PACKAGE_NAME}.Bird: value of parameter 'name' produces no value, cannot use it`) }) it('should show Wollok stack', () => { @@ -672,9 +672,9 @@ describe('Wollok Interpreter', () => { assertBasicError(error) expect(getStackTraceSanitized(error)).to.deep.equal([ 'wollok.lang.EvaluationError: TypeError: Message plusDays: parameter "wollok.lang.Date" should be a number', - ' at definitions.comun.despegar() [definitions.wlk:8]', - ' at definitions.comun.volar() [definitions.wlk:4]', - ' at definitions.Ave.volar() [definitions.wlk:17]', + ` at ${INIT_PACKAGE_NAME}.comun.despegar() [${INIT_PACKAGE_NAME}.wlk:8]`, + ` at ${INIT_PACKAGE_NAME}.comun.volar() [${INIT_PACKAGE_NAME}.wlk:4]`, + ` at ${INIT_PACKAGE_NAME}.Ave.volar() [${INIT_PACKAGE_NAME}.wlk:17]`, ]) }) @@ -691,7 +691,7 @@ describe('Wollok Interpreter', () => { assertBasicError(error) expect(getStackTraceSanitized(error)).to.deep.equal([ 'wollok.lang.EvaluationError: RangeError: Cannot send message +, receiver is an expression that produces no value.', - ' at definitions.pepita.unMetodo() [definitions.wlk:4]', + ` at ${INIT_PACKAGE_NAME}.pepita.unMetodo() [${INIT_PACKAGE_NAME}.wlk:4]`, ]) }) diff --git a/test/utils.ts b/test/utils.ts index 566f055f..fc782563 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -6,7 +6,8 @@ import { Annotation, buildEnvironment, Class, Environment, FileContent, fromJSON import { divideOn, List, notEmpty } from '../src/extensions' import wre from '../src/wre/wre.json' -export const INIT_FILE = 'definitions' +export const INIT_PACKAGE_NAME = 'definitions' +export const INIT_FILE = INIT_PACKAGE_NAME + '.wlk' export function buildEnvironmentForEachFile(folderPath: string, iterator: (filePackage: Package, fileContent: FileContent) => void): void { const files = globby.sync(`**/*.@(${WOLLOK_FILE_EXTENSION}|${TEST_FILE_EXTENSION}|${PROGRAM_FILE_EXTENSION})`, { cwd: folderPath }).map(name => ({ @@ -85,7 +86,7 @@ export const validateExpectationProblem = (expectedProblem: Annotation, nodeProb return effectiveProblem } -export const environmentWithREPLInitializedFile = (content: string, name = INIT_FILE): Environment => { +export const environmentWithREPLInitializedFile = (content: string, name = INIT_PACKAGE_NAME): Environment => { const environment = buildEnvironment([{ name: name + '.wlk', content }]) const initPackage = environment.getNodeByFQN(name) environment.scope.register([REPL, initPackage])