Skip to content

Commit e2838e5

Browse files
committed
Adding tests for "Die handedness".
1 parent 46a44ec commit e2838e5

File tree

13 files changed

+177
-1
lines changed

13 files changed

+177
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [1.7.0] - 2022-03-31
88
### Added
99
- Tests for "Credit card verifier (Luhn’s algorithm)".
1010
- Tests for "Van Eck's sequence".
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Tests for "Mountain map".
2323
- Tests for "Create the longest sequence of 1s".
2424
- Tests for "Reverse Minesweeper".
25+
- Tests for "Die handedness".
2526

2627
## [1.6.0] - 2022-03-11
2728
### Added
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Die handedness" puzzle.
3+
*/
4+
function execute(readline) {
5+
for (let i = 0; i < 3; i++) {
6+
const line = readline(); // One line out of three in the string describing the arrangement of the numbers.
7+
}
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
// Output one of "right-handed", "left-handed" and "degenerate".
13+
console.log('handedness');
14+
}
15+
16+
export { execute };
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/dieHandedness/dieHandedness.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Die handedness", function() {
9+
const sandbox = sinon.createSandbox();
10+
11+
setup(function () {
12+
sandbox.stub(console, "log");
13+
});
14+
15+
teardown(function () {
16+
sandbox.restore();
17+
});
18+
19+
20+
test("Test 1", function() {
21+
let inputFile = new File(__dirname + 'input/01 - test 1.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"right-handed"
28+
);
29+
});
30+
31+
test("Test 2", function() {
32+
let inputFile = new File(__dirname + 'input/02 - test 2.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"degenerate"
39+
);
40+
});
41+
42+
test("Test 3", function() {
43+
let inputFile = new File(__dirname + 'input/03 - test 3.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"left-handed"
50+
);
51+
});
52+
53+
test("Test 4", function() {
54+
let inputFile = new File(__dirname + 'input/04 - test 4.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"degenerate"
61+
);
62+
});
63+
64+
test("Test 5", function() {
65+
let inputFile = new File(__dirname + 'input/05 - test 5.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"right-handed"
72+
);
73+
});
74+
75+
test("Test 6", function() {
76+
let inputFile = new File(__dirname + 'input/06 - test 6.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"degenerate"
83+
);
84+
});
85+
86+
test("Test 7", function() {
87+
let inputFile = new File(__dirname + 'input/07 - test 7.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"left-handed"
94+
);
95+
});
96+
97+
test("Test 8", function() {
98+
let inputFile = new File(__dirname + 'input/08 - test 8.txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"right-handed"
105+
);
106+
});
107+
108+
test("Test 9", function() {
109+
let inputFile = new File(__dirname + 'input/09 - test 9.txt');
110+
111+
execute(inputFile.readline.bind(inputFile));
112+
113+
assert.strictEqual(
114+
console.log.getCall(0).args[0],
115+
"degenerate"
116+
);
117+
});
118+
119+
test("Test 10", function() {
120+
let inputFile = new File(__dirname + 'input/10 - test 10.txt');
121+
122+
execute(inputFile.readline.bind(inputFile));
123+
124+
assert.strictEqual(
125+
console.log.getCall(0).args[0],
126+
"degenerate"
127+
);
128+
});
129+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
2354
3+
6
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
4256
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
6512
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
5612
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4
2+
1562
3+
3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
2561
3+
4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
2156
3+
4

0 commit comments

Comments
 (0)