Skip to content

Commit

Permalink
fix lint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
lgassman committed Dec 30, 2024
1 parent a976788 commit 6db4e94
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import validate from './validator'
import print from './printer/print'
import WRE from './wre/wre.json'
import WRENatives from './wre/wre.natives'
import natives from './wre/natives'

export type FileContent = {
name: string,
Expand Down Expand Up @@ -49,4 +50,5 @@ export {
print,
WRE,
WRENatives,
natives,
}
4 changes: 2 additions & 2 deletions src/interpreter/interpreter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { linkSentenceInNode } from '../linker'
import { Entity, Environment, Import, Method, Module, Name, Node, Reference, Sentence } from '../model'
import WRENatives from '../wre/wre.natives'
import natives from '../wre/natives'
import { Evaluation, Execution, ExecutionDefinition, Natives, RuntimeObject, RuntimeValue, WollokException } from './runtimeModel'
import * as parse from '../parser'
import { notEmpty } from '../extensions'
Expand Down Expand Up @@ -178,7 +178,7 @@ export class DirectedInterpreter extends AbstractInterpreter {
}

export const executionFor = (environment: Environment): DirectedInterpreter =>
new DirectedInterpreter(Evaluation.build(environment, WRENatives))
new DirectedInterpreter(Evaluation.build(environment, natives()))

// TODO:
// - track history
Expand Down
10 changes: 6 additions & 4 deletions test/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ declare global {
pass<N extends Node>(validation: Validation<N>): Assertion

anyType(): Assertion

deepEquals(excepted: any): Assertion
}

interface ArrayAssertion {
Expand Down Expand Up @@ -184,18 +186,18 @@ export const validatorAssertions: Chai.ChaiPlugin = ({ Assertion }) => {
// ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
export const compareAssertions: Chai.ChaiPlugin = ({ Assertion }) => {

const comparePrimitives = (obj1: unknown, obj2: unknown): boolean => obj1 === obj2;
const comparePrimitives = (obj1: unknown, obj2: unknown): boolean => obj1 === obj2

const compareObjects = (obj1: unknown, obj2: unknown): boolean =>
obj1 !== null && obj2 !== null &&
typeof obj1 === 'object' && typeof obj2 === 'object' &&
Object.keys(obj1).length === Object.keys(obj2).length &&
Object.keys(obj1).every(key => deepCompare((obj1 as Record<string, unknown>)[key], (obj2 as Record<string, unknown>)[key]));
Object.keys(obj1).every(key => deepCompare((obj1 as Record<string, unknown>)[key], (obj2 as Record<string, unknown>)[key]))

const compareArrays = (arr1: unknown, arr2: unknown): boolean =>
Array.isArray(arr1) && Array.isArray(arr2) &&
arr1.length === arr2.length &&
arr1.every((elem, index) => deepCompare(elem, arr2[index]));
arr1.every((elem, index) => deepCompare(elem, arr2[index]))

const compareMaps = (map1: unknown, map2: unknown): boolean =>
map1 instanceof Map && map2 instanceof Map &&
Expand All @@ -207,7 +209,7 @@ export const compareAssertions: Chai.ChaiPlugin = ({ Assertion }) => {
const compareSets = (set1: unknown, set2: unknown): boolean =>
set1 instanceof Set && set2 instanceof Set &&
set1.size === set2.size &&
[...set1].every(elem => set2.has(elem));
[...set1].every(elem => set2.has(elem))

const deepCompare = (obj1: unknown, obj2: unknown): boolean =>
comparePrimitives(obj1, obj2) ||
Expand Down
17 changes: 6 additions & 11 deletions test/natives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { expect, should, use } from 'chai'
import { restore } from 'sinon'
import sinonChai from 'sinon-chai'
import { REPL, Evaluation, WRENatives, buildEnvironment } from '../src'
import { interprete, Interpreter } from '../src/interpreter/interpreter';
import { interprete, Interpreter } from '../src/interpreter/interpreter'
import natives from '../src/wre/natives'
import { compareAssertions } from './assertions'
import link from '../src/linker'
import { Package } from '../src/model'




use(sinonChai)
use(compareAssertions)
Expand All @@ -18,8 +13,8 @@ should()
const myModelNative = {
model: {
myModel: {
*nativeOne(self: any) : any {
return yield* this.reify(1)
*nativeOne(_self: any): any {
return yield* (this as any).reify(1)
},
},
},
Expand Down Expand Up @@ -50,7 +45,7 @@ describe('Native functions', () => {
method listSize() {
return [1,2].size()
}
}`
}`,
},
{
name: REPL, content: `
Expand All @@ -61,7 +56,7 @@ describe('Native functions', () => {
}
`,
}])
interpreter = new Interpreter(Evaluation.build(replEnvironment, natives())) //No me gusta tener que pasar WRENatives acá, me gustaría que quede dentro del modelo
interpreter = new Interpreter(Evaluation.build(replEnvironment, natives()))
})

it('Using wre native method return ok', () => {
Expand Down Expand Up @@ -95,7 +90,7 @@ describe('Native functions', () => {
}
`,
}])
interpreter = new Interpreter(Evaluation.build(replEnvironment, natives([myModelNative]))) //No me gusta tener que pasar WRENatives acá, me gustaría que quede dentro del modelo
interpreter = new Interpreter(Evaluation.build(replEnvironment, natives([myModelNative])))
})

it('Using wre native method return ok', () => {
Expand Down

0 comments on commit 6db4e94

Please sign in to comment.