Skip to content

Commit d819b4e

Browse files
committed
Adding tests for "What's so complex about
Mandelbrot?".
1 parent 7605878 commit d819b4e

File tree

10 files changed

+126
-0
lines changed

10 files changed

+126
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Tests for "IPv6 shortener".
2525
- Tests for "Zhiwei Sun squares".
2626
- Tests for "Stall tilt".
27+
- Tests for "What's so complex about Mandelbrot?".
2728

2829
## [1.9.0] - 2022-06-01
2930
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* The "What's so complex about Mandelbrot?" puzzle.
3+
* @see {@link https://www.codingame.com/ide/puzzle/whats-so-complex-about-mandelbrot}
4+
*/
5+
function execute(readline) {
6+
const c = readline();
7+
const m = parseInt(readline());
8+
9+
// Write an answer using console.log()
10+
// To debug: console.error('Debug messages...');
11+
12+
console.log('answer');
13+
}
14+
15+
export { execute };
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { execute } from '../../../../../lib/community/training/easy/whatsSoComplexAboutMandelbrot/whatsSoComplexAboutMandelbrot.js';
5+
6+
const __dirname = new URL('.', import.meta.url).pathname;
7+
8+
suite("What's so complex about Mandelbrot?", 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("Real out", function() {
21+
let inputFile = new File(__dirname + 'input/01 - real out.txt');
22+
23+
execute(inputFile.readline.bind(inputFile));
24+
25+
assert.strictEqual(
26+
console.log.getCall(0).args[0],
27+
1
28+
);
29+
});
30+
31+
test("Imaginary out", function() {
32+
let inputFile = new File(__dirname + 'input/02 - imaginary out.txt');
33+
34+
execute(inputFile.readline.bind(inputFile));
35+
36+
assert.strictEqual(
37+
console.log.getCall(0).args[0],
38+
1
39+
);
40+
});
41+
42+
test("Real in", function() {
43+
let inputFile = new File(__dirname + 'input/03 - real in.txt');
44+
45+
execute(inputFile.readline.bind(inputFile));
46+
47+
assert.strictEqual(
48+
console.log.getCall(0).args[0],
49+
45
50+
);
51+
});
52+
53+
test("Imaginary in", function() {
54+
let inputFile = new File(__dirname + 'input/04 - imaginary in.txt');
55+
56+
execute(inputFile.readline.bind(inputFile));
57+
58+
assert.strictEqual(
59+
console.log.getCall(0).args[0],
60+
11
61+
);
62+
});
63+
64+
test("Complex out", function() {
65+
let inputFile = new File(__dirname + 'input/05 - complex out.txt');
66+
67+
execute(inputFile.readline.bind(inputFile));
68+
69+
assert.strictEqual(
70+
console.log.getCall(0).args[0],
71+
124
72+
);
73+
});
74+
75+
test("Complex in", function() {
76+
let inputFile = new File(__dirname + 'input/06 - complex in.txt');
77+
78+
execute(inputFile.readline.bind(inputFile));
79+
80+
assert.strictEqual(
81+
console.log.getCall(0).args[0],
82+
124
83+
);
84+
});
85+
86+
test("Check your absolute value", function() {
87+
let inputFile = new File(__dirname + 'input/07 - check your absolute value.txt');
88+
89+
execute(inputFile.readline.bind(inputFile));
90+
91+
assert.strictEqual(
92+
console.log.getCall(0).args[0],
93+
12
94+
);
95+
});
96+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
4.5+0i
2+
10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0+4.2i
2+
100
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-1.1+0i
2+
45
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0+0.2i
2+
11
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-0.65812-0.452i
2+
275
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0.15658-0.5745i
2+
822
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0.465+0.354i
2+
50

0 commit comments

Comments
 (0)