Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/gigasecond/.meta/hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It is possible to return a correct value for this exercise by mutating the solution function argument. Although there are legitimate use cases for mutating function arguments, this is usually undesirable, and in the case of this exercise, clearly unexpected. For this reason, the test suite has a test that fails in case the argument has been modified after the function execution.
3 changes: 3 additions & 0 deletions exercises/gigasecond/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ has passed.

A gigasecond is 10^9 (1,000,000,000) seconds.

It is possible to return a correct value for this exercise by mutating the solution function argument. Although there are legitimate use cases for mutating function arguments, this is usually undesirable, and in the case of this exercise, clearly unexpected. For this reason, the test suite has a test that fails in case the argument has been modified after the function execution.


## Setup

Go through the setup instructions for Javascript to install the necessary
Expand Down
6 changes: 6 additions & 0 deletions exercises/gigasecond/gigasecond.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ describe('Gigasecond', () => {
const expectedDate = new Date(Date.parse('2046-10-03T01:46:39Z'));
expect(gs).toEqual(expectedDate);
});

xtest('does not mutate the input', () => {
const input = new Date(Date.UTC(2020, 0, 4, 20, 28, 30));
gigasecond(input);
expect(input).toEqual(new Date(Date.UTC(2020, 0, 4, 20, 28, 30)));
});
});