From afad36769bf7292b8022848930c3e6991de0879b Mon Sep 17 00:00:00 2001 From: danielromeo Date: Wed, 20 Nov 2024 07:50:59 +0200 Subject: [PATCH 1/3] added a few tests --- package.json | 1 + src/romeo.ts | 4 ++-- src/typechecker.test.ts | 16 +++++++++++++++- yarn.lock | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e5f9a10..d4f14e3 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ }, "homepage": "https://github.com/DanielRomeo/jackscript-js#readme", "dependencies": { + "@nestjs/throttler": "^6.2.1", "@types/jest": "^29.5.12", "jest": "^29.7.0", "ts-jest": "^29.2.4" diff --git a/src/romeo.ts b/src/romeo.ts index 371fbcd..201bcec 100644 --- a/src/romeo.ts +++ b/src/romeo.ts @@ -74,8 +74,8 @@ let codfalse = [1,1]; //console.log(isCoordinate(codfalse)) // returns false -// console.log(coordinatesEqual(cod, reflexiveTest[0])); -// console.log(reflexiveTest.entries().next()); +console.log(coordinatesEqual(cod, reflexiveTest.values().next())); +// console.log(reflexiveTest.values().next()); // const func = () => { // reflexiveTest.forEach(element => { diff --git a/src/typechecker.test.ts b/src/typechecker.test.ts index 471cbfc..66e1079 100644 --- a/src/typechecker.test.ts +++ b/src/typechecker.test.ts @@ -9,12 +9,17 @@ describe('Coordinates typechecker methods.', () => { let coordinate3 : Coordinate; let coordinate4 : Coordinate; let coordinate5fake = [1,1,2]; + let cod : Coordinate; + let testJackscriptSet = new JackscriptSet>([[1,1],[2,2],[3,3]]); beforeEach(() => { coordinate1 = [1,1]; coordinate2 = [2,2]; coordinate3 = ["a",1]; coordinate4 = ["a", "b"]; + cod = [1,1]; + + }); // test if variables are valide coordinates or not: @@ -33,8 +38,17 @@ describe('Coordinates typechecker methods.', () => { it('Value is NOT a coordinate.', () => { expect(isCoordinate(coordinate5fake)).toBe(false); }) - + + // test the coordinatesEqual() function: + it('Two coordinates are equal.', () => { + expect(coordinatesEqual(coordinate1, [1,1])).toBe(true); + }) + // it('Two coordinates are equal.', () => { + // expect(coordinatesEqual(coordinate1, testJackscriptSet[0])).toBe(true); + // }) }); + + diff --git a/yarn.lock b/yarn.lock index 6d635b9..05d386f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -510,6 +510,11 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@nestjs/throttler@^6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@nestjs/throttler/-/throttler-6.2.1.tgz#c241788a8b195e6c7c0cf94b1808c4cb940ac2fd" + integrity sha512-vdt6VjhKC6vcLBJRUb97IuR6Htykn5kokZzmT8+S5XFOLLjUF7rzRpr+nUOhK9pi1L0hhbzSf2v2FJl4v64EJA== + "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" From 176068fdb0ec7a12183a855e5fa03df6a791c4c9 Mon Sep 17 00:00:00 2001 From: danielromeo Date: Wed, 20 Nov 2024 08:06:13 +0200 Subject: [PATCH 2/3] written tests for the typechecker methods --- src/romeo.ts | 2 -- src/typechecker.test.ts | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/romeo.ts b/src/romeo.ts index 201bcec..78b0d49 100644 --- a/src/romeo.ts +++ b/src/romeo.ts @@ -73,8 +73,6 @@ let codfalse = [1,1]; // console.log(isCoordinate(cod3)) // returns //console.log(isCoordinate(codfalse)) // returns false - -console.log(coordinatesEqual(cod, reflexiveTest.values().next())); // console.log(reflexiveTest.values().next()); // const func = () => { diff --git a/src/typechecker.test.ts b/src/typechecker.test.ts index 66e1079..36e9c38 100644 --- a/src/typechecker.test.ts +++ b/src/typechecker.test.ts @@ -8,6 +8,8 @@ describe('Coordinates typechecker methods.', () => { let coordinate2 : Coordinate; let coordinate3 : Coordinate; let coordinate4 : Coordinate; + + let coordinate5 : Coordinate; let coordinate5fake = [1,1,2]; let cod : Coordinate; let testJackscriptSet = new JackscriptSet>([[1,1],[2,2],[3,3]]); @@ -18,8 +20,7 @@ describe('Coordinates typechecker methods.', () => { coordinate3 = ["a",1]; coordinate4 = ["a", "b"]; cod = [1,1]; - - + coordinate5 = [3,3]; }); // test if variables are valide coordinates or not: @@ -43,9 +44,17 @@ describe('Coordinates typechecker methods.', () => { it('Two coordinates are equal.', () => { expect(coordinatesEqual(coordinate1, [1,1])).toBe(true); }) - // it('Two coordinates are equal.', () => { - // expect(coordinatesEqual(coordinate1, testJackscriptSet[0])).toBe(true); - // }) + it('Two coordinates are equal.', () => { + expect(coordinatesEqual(coordinate1, testJackscriptSet.values().next().value)).toBe(true); + }) + // loop through identical arrays that are created differently and compare elems in each array + it('Two coordinates are equal.', () => { + let JacksriptElement = testJackscriptSet.values(); + [coordinate1,coordinate2, coordinate5].forEach(element => { + expect(coordinatesEqual(element, JacksriptElement.next().value)).toBe(true); + }); + + }) }); From 05c4a08fc90e703d6b24efdf8d254a35de0473c2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 19 Nov 2024 22:19:37 -0800 Subject: [PATCH 3/3] Update restrict-prs.yml --- .github/workflows/restrict-prs.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/restrict-prs.yml b/.github/workflows/restrict-prs.yml index 9414c5f..664ba77 100644 --- a/.github/workflows/restrict-prs.yml +++ b/.github/workflows/restrict-prs.yml @@ -1,16 +1,16 @@ -name: Restrict PRs to Main +# name: Restrict PRs to Main -on: - pull_request: - branches: - - main +# on: +# pull_request: +# branches: +# - main -jobs: - restrict-pr: - runs-on: ubuntu-latest - steps: - - name: Check if PR is from development branch - if: github.event.pull_request.head.ref != 'development' - run: | - echo "Only pull requests from the 'development' branch are allowed." - exit 1 +# jobs: +# restrict-pr: +# runs-on: ubuntu-latest +# steps: +# - name: Check if PR is from development branch +# if: github.event.pull_request.head.ref != 'development' +# run: | +# echo "Only pull requests from the 'development' branch are allowed." +# exit 1