Skip to content

Commit d7e9d32

Browse files
committed
Adding tests for "Brackets, extreme edition".
1 parent 0fe33be commit d7e9d32

File tree

11 files changed

+129
-0
lines changed

11 files changed

+129
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Tests for "Lumen".
1717
- Tests for "A child's play".
1818
- Tests for "Sum of spiral's diagonals".
19+
- Tests for "Brackets, extreme edition".
1920

2021
## [1.6.0] - 2022-03-11
2122
### Added
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* The "Brackets, extreme edition" puzzle.
3+
*/
4+
function execute(readline) {
5+
const expression = readline();
6+
7+
// Write an answer using console.log()
8+
// To debug: console.error('Debug messages...');
9+
10+
console.log('true/false');
11+
}
12+
13+
export { execute };
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/bracketsExtremeEdition/bracketsExtremeEdition.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("Brackets, extreme edition", 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("Example", function() {
21+
let inputFile = new File(__dirname + 'input/01 - example.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
"true"
28+
);
29+
});
30+
31+
test("{([{S}]]6K[()]}", function() {
32+
let inputFile = new File(__dirname + 'input/02 - {([{S}]]6K[()]}.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
"false"
39+
);
40+
});
41+
42+
test("{C{}[{[a]}RqhL]{y2}}", function() {
43+
let inputFile = new File(__dirname + 'input/03 - {C{}[{[a]}RqhL]{y2}}.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
"true"
50+
);
51+
});
52+
53+
test("W12{}{}L{}", function() {
54+
let inputFile = new File(__dirname + 'input/04 - W12{}{}L{}.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
"true"
61+
);
62+
});
63+
64+
test("h{Pn{GT{h}(c))}", function() {
65+
let inputFile = new File(__dirname + 'input/05 - h{Pn{GT{h}(c))}.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
"false"
72+
);
73+
});
74+
75+
test("{[{iHTSc}]}p(R)m(){q({})", function() {
76+
let inputFile = new File(__dirname + 'input/06 - {[{iHTSc}]}p(R)m(){q({}).txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
"false"
83+
);
84+
});
85+
86+
test("][", function() {
87+
let inputFile = new File(__dirname + 'input/07 - ][.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
"false"
94+
);
95+
});
96+
97+
test("{(})", function() {
98+
let inputFile = new File(__dirname + 'input/08 - {(}).txt');
99+
100+
execute(inputFile.readline.bind(inputFile));
101+
102+
assert.strictEqual(
103+
console.log.getCall(0).args[0],
104+
"false"
105+
);
106+
});
107+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{([]){}()}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{([{S}]]6K[()]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{C{}[{[a]}RqhL]{y2}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
W12{}{}L{}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
h{Pn{GT{h}(c))}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{[{iHTSc}]}p(R)m(){q({})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
][

0 commit comments

Comments
 (0)