-
Notifications
You must be signed in to change notification settings - Fork 0
Test #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Test #50
Changes from all commits
7b2c005
2dcf515
0d0f947
c7df3fe
dae5cbf
d67608d
46ef55f
e7e51f3
5d3f399
e5c42a7
45d075a
433aacf
3c1cab5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "docker-images", | ||
"version": "3.3.1-rc.2", | ||
"version": "3.3.1-rc.3", | ||
"packageManager": "[email protected]", | ||
"private": true, | ||
"repository": { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import * as Challenges from '@lehungio/typescript'; | ||
import { greet, wordCount } from '@lehungio/typescript'; | ||
|
||
describe('Challenges Module', () => { | ||
describe('Challenges output', () => { | ||
test('greet function should return correct greeting', () => { | ||
const helloAll = Challenges.greet('All'); | ||
expect(helloAll).toBe('Hello, All!'); | ||
|
@@ -23,4 +23,64 @@ describe('Challenges Module', () => { | |
const expectedCount = new Map([['hello', 1], ['world', 1]]); | ||
expect(count).toEqual(expectedCount); | ||
}); | ||
|
||
test('differenceOfSquares function should return correct difference of squares', () => { | ||
const squares = new Challenges.Squares(5); | ||
expect(squares.squareOfSum).toBe(225); | ||
expect(squares.sumOfSquares).toBe(55); | ||
expect(squares.difference).toBe(170); | ||
}); | ||
Comment on lines
+27
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider additional edge case checks. Testing |
||
|
||
}); | ||
|
||
describe('Challenge #27 - Gigasecond output test', () => { | ||
test('Gigasecond function should return correct gigasecond date', () => { | ||
const gigasecond = new Challenges.Gigasecond(new Date('2013-01-07')); | ||
expect(gigasecond.date().toISOString()).toBe("2044-09-15T01:46:40.000Z"); | ||
}); | ||
}); | ||
|
||
describe('Challenge #28 - Reverse String output test', () => { | ||
test('reverse function should return correct reversed string', () => { | ||
const reversed = Challenges.reverse('hello'); | ||
expect(reversed).toBe('olleh'); | ||
}); | ||
|
||
test('reverse function should return correct reversed string', () => { | ||
const reversed = Challenges.reverse('aloha'); | ||
expect(reversed).toBe('ahola'); | ||
}); | ||
}); | ||
lehungio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
describe('Challenge #29 - Triangle output test', () => { | ||
test('Triangle class should return correct triangle type', () => { | ||
const triangle = new Challenges.Triangle(3, 4, 5); | ||
expect(triangle.isEquilateral).toBe(false); | ||
expect(triangle.isIsosceles).toBe(false); | ||
expect(triangle.isScalene).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Challenge #30 - Collatz Conjecture output test', () => { | ||
test('steps function should return correct number of steps', () => { | ||
expect(Challenges.steps(16)).toBe(4); | ||
expect(Challenges.steps(12)).toBe(9); | ||
expect(Challenges.steps(1000000)).toBe(152); | ||
}); | ||
}); | ||
|
||
describe('Challenge #42 - ETL output test', () => { | ||
test('transform function should return correct transformed data', () => { | ||
const oldSystem = { 1: ['A'] }; | ||
const newSystem = Challenges.transform(oldSystem); | ||
expect(newSystem).toEqual({ a: 1 }); | ||
}); | ||
}); | ||
|
||
describe('Challenge #43 - Protein Translation output test', () => { | ||
test('translateRNA function should return correct translated RNA', () => { | ||
const rnaInput = 'AUGUUUUGG'; | ||
const translated = Challenges.translateRNA(rnaInput); | ||
expect(translated).toEqual(['Methionine', 'Phenylalanine', 'Tryptophan']); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,4 +22,89 @@ try { | |||||||||||||||||||||||||
* Demonstrates the word counting functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
const count = Challenges.wordCount('Hello, World!'); // Output: 2 | ||||||||||||||||||||||||||
console.log('Word count result:', count); | ||||||||||||||||||||||||||
console.log('Word count result:', count); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 26: Difference of Squares | ||||||||||||||||||||||||||
* Demonstrates the difference of squares functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
const squares = new Challenges.Squares(5); | ||||||||||||||||||||||||||
console.log('Square of sum:', squares.squareOfSum); | ||||||||||||||||||||||||||
console.log('Sum of squares:', squares.sumOfSquares); | ||||||||||||||||||||||||||
console.log('Difference:', squares.difference); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+27
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider tests for multiple inputs. |
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 27: Gigasecond | ||||||||||||||||||||||||||
* Demonstrates the gigasecond functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
const gigasecond = new Challenges.Gigasecond(new Date('2013-01-07')); | ||||||||||||||||||||||||||
console.log('Gigasecond date from 2013-01-07:', gigasecond.date()); | ||||||||||||||||||||||||||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the gigasecond calculation. The test is failing because it expects a different date than what's being calculated. Ensure the Gigasecond class correctly adds 10^9 seconds to the input date. 🌐 Web query:
💡 Result: One gigasecond is equivalent to approximately 11,574.07 days. This conversion is derived by dividing (10^9) seconds (one gigasecond) by the number of seconds in a day (86,400), resulting in ( \frac{1{,}000{,}000{,}000}{86{,}400} \approx 11{,}574.07 ) days[2][3][5]. The exact value extends as a repeating decimal ((11{,}574.\overline{074})), reflecting the precise mathematical relationship between these units[2][3]. This duration highlights how large-scale time measurements translate into more familiar daily terms[1][4]. Citations:
Action: Revise Gigasecond Calculation for Accurate Date Arithmetic The current implementation is not adding 1,000,000,000 seconds correctly. Recall that one gigasecond is approximately 11,574.07 days—which means you need to add 11,574 full days plus an extra 1 hour, 46 minutes, and 40 seconds. This discrepancy is causing the test failure. Please verify and adjust your Gigasecond class so that it:
|
||||||||||||||||||||||||||
const target = new Date('2025-02-28'); | ||||||||||||||||||||||||||
const seconds = Challenges.Gigasecond.secondsToDate(target); | ||||||||||||||||||||||||||
const days = Challenges.Gigasecond.secondsToDays(seconds); // Returns number of days from now until Dec 31, 2024 | ||||||||||||||||||||||||||
console.log('Days from now until Feb 28, 2025:', days); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
const start = new Date('2013-01-07'); | ||||||||||||||||||||||||||
const gs = new Challenges.Gigasecond(start); | ||||||||||||||||||||||||||
const target2 = new Date('2025-02-28'); | ||||||||||||||||||||||||||
const seconds2 = gs.secondsBetweenDates(target2); // Returns seconds between Jan 1 and Feb 1 | ||||||||||||||||||||||||||
console.log('Seconds between 2013-01-07 and 2025-02-28:', seconds2); | ||||||||||||||||||||||||||
console.log('Days between 2013-01-07 and 2025-02-28:', Challenges.Gigasecond.secondsToDays(seconds2)); | ||||||||||||||||||||||||||
Comment on lines
+47
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Inconsistent inline comment in secondsBetweenDates usage. The comment on line 50 states "Returns seconds between Jan 1 and Feb 1" but the actual code calculates seconds between Jan 7, 2013 and Feb 28, 2025. -const seconds2 = gs.secondsBetweenDates(target2); // Returns seconds between Jan 1 and Feb 1
+const seconds2 = gs.secondsBetweenDates(target2); // Returns seconds between Jan 7, 2013 and Feb 28, 2025 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 28: Reverse String | ||||||||||||||||||||||||||
* Demonstrates the reverse string functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
const reverseStringInput = 'hello'; | ||||||||||||||||||||||||||
console.log(`Challenge 28 - Reverse String: reverse('${reverseStringInput}') => ${Challenges.reverse(reverseStringInput)}`); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 29: Triangle | ||||||||||||||||||||||||||
* Demonstrates the triangle functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
console.log('Challenge 29 - Triangle Check'); | ||||||||||||||||||||||||||
const triangle = new Challenges.Triangle(3, 4, 5); | ||||||||||||||||||||||||||
console.log(`Challenge 29 - Triangle: triangle.isEquilateral => ${triangle.isEquilateral}`); | ||||||||||||||||||||||||||
console.log(`Challenge 29 - Triangle: triangle.isIsosceles => ${triangle.isIsosceles}`); | ||||||||||||||||||||||||||
console.log(`Challenge 29 - Triangle: triangle.isScalene => ${triangle.isScalene}`); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 30: Collatz Conjecture | ||||||||||||||||||||||||||
* Demonstrates the collatz conjecture functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
console.log('Challenge 30 - Collatz Conjecture'); | ||||||||||||||||||||||||||
const collatzConjectureInput = 16; | ||||||||||||||||||||||||||
console.log(`Challenge 30 - Collatz Conjecture: steps(${collatzConjectureInput}) => ${Challenges.steps(collatzConjectureInput)}`); | ||||||||||||||||||||||||||
const collatzConjectureInput2 = 12; | ||||||||||||||||||||||||||
console.log(`Challenge 30 - Collatz Conjecture: steps(${collatzConjectureInput2}) => ${Challenges.steps(collatzConjectureInput2)}`); | ||||||||||||||||||||||||||
const collatzConjectureInput3 = 1000000; | ||||||||||||||||||||||||||
console.log(`Challenge 30 - Collatz Conjecture: steps(${collatzConjectureInput3}) => ${Challenges.steps(collatzConjectureInput3)}`); | ||||||||||||||||||||||||||
const collatzConjectureInput4 = 2025; | ||||||||||||||||||||||||||
console.log(`Challenge 30 - Collatz Conjecture: steps(${collatzConjectureInput4}) => ${Challenges.steps(collatzConjectureInput4)}`); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+71
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Collatz Conjecture demonstration. |
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 42: ETL | ||||||||||||||||||||||||||
* Demonstrates the etl functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
console.log('Challenge 42 - ETL'); | ||||||||||||||||||||||||||
const oldSystem = { | ||||||||||||||||||||||||||
1: ['L'], | ||||||||||||||||||||||||||
2: ['E', 'H', 'U'], | ||||||||||||||||||||||||||
3: ['I', 'O'] | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
const newSystem = Challenges.transform(oldSystem); | ||||||||||||||||||||||||||
console.log(`Challenge 42 - ETL: transform(${JSON.stringify(oldSystem)}) => ${JSON.stringify(newSystem)}`); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Challenge 43: Protein Translation | ||||||||||||||||||||||||||
* Demonstrates the protein translation functionality | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
console.log('Challenge #43 - Protein Translation'); | ||||||||||||||||||||||||||
const rnaInput = 'AUGUUUUGG'; | ||||||||||||||||||||||||||
console.log(`Challenge #43 - Protein Translation: translateRNA('${rnaInput}') => ${JSON.stringify(Challenges.translateRNA(rnaInput))}`); | ||||||||||||||||||||||||||
const rnaInput2 = 'AUGUUUUAA'; | ||||||||||||||||||||||||||
console.log(`Challenge #43 - Protein Translation: translateRNA('${rnaInput2}') => ${JSON.stringify(Challenges.translateRNA(rnaInput2))}`); | ||||||||||||||||||||||||||
const rnaInput3 = 'AUGUUUUAG'; | ||||||||||||||||||||||||||
console.log(`Challenge #43 - Protein Translation: translateRNA('${rnaInput3}') => ${JSON.stringify(Challenges.translateRNA(rnaInput3))}`); | ||||||||||||||||||||||||||
const rnaInput4 = 'AUGUUUUAGUGG'; | ||||||||||||||||||||||||||
console.log(`Challenge #43 - Protein Translation: translateRNA('${rnaInput4}') => ${JSON.stringify(Challenges.translateRNA(rnaInput4))}`); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"name": "challenges", | ||
"version": "1.0.0", | ||
"version": "1.3.0-rc.5", | ||
"packageManager": "[email protected]", | ||
"main": "index.js", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"build": "tsc index.ts", | ||
"start": "node index.js", | ||
"test": "node index.js", | ||
"execute": "node index.js --report-compact ", | ||
"test:node": "node index.js", | ||
"test:jest": "jest --coverage" | ||
"build": "tsc", | ||
"start": "node dist/index.js", | ||
"test": "node dist/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Potential Test Script Ambiguity |
||
"execute": "node dist/index.js --report-compact ", | ||
"test:node": "node dist/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Review Test:Node Script
Comment on lines
+9
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consolidate or clarify repetitive script commands. |
||
"test:jest": "jest" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Optional coverage flag. |
||
}, | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
"description": "Typescript Programming challenges", | ||
"dependencies": { | ||
"@lehungio/typescript": "^1.3.0-rc.0" | ||
"@lehungio/typescript": "^1.3.0-rc.5" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.14", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Potential Redundant Build Step
The
npm run build
command added in the "Run tests - TypeScript Challenges (NPM)" step might be redundant since a similar build step is executed earlier in the workflow. Please verify if the rebuild is necessary—for example, to pick up any changes made after the first build—or if it can be safely removed to streamline the workflow.