Skip to content

Commit 3e30206

Browse files
test: node:test
Migrate from `vitest` to `node:test`
1 parent b91a99c commit 3e30206

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+439
-2312
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22
1+
v23

2015/day/1/index.test.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
3-
import { getInput } from '../../../utils/file';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { part1, part2 } from './index.ts';
45

5-
const input = await getInput(__dirname);
6+
const input = await getInput(import.meta.dirname);
67

78
describe('2015', () => {
89
describe('Day 1', () => {
910
describe('Part 1', () => {
1011
it('should return floor number', () => {
11-
expect(part1('(())')).toBe(0);
12-
expect(part1('()()')).toBe(0);
13-
expect(part1('(((')).toBe(3);
14-
expect(part1('(()(()(')).toBe(3);
15-
expect(part1('))(((((')).toBe(3);
16-
expect(part1('())')).toBe(-1);
17-
expect(part1('))(')).toBe(-1);
18-
expect(part1(')))')).toBe(-3);
19-
expect(part1(')())())')).toBe(-3);
20-
expect(part1(input)).toBe(280);
12+
assert.strictEqual(part1('(())'), 0);
13+
assert.strictEqual(part1('()()'), 0);
14+
assert.strictEqual(part1('((('), 3);
15+
assert.strictEqual(part1('(()(()('), 3);
16+
assert.strictEqual(part1('))((((('), 3);
17+
assert.strictEqual(part1('())'), -1);
18+
assert.strictEqual(part1('))('), -1);
19+
assert.strictEqual(part1(')))'), -3);
20+
assert.strictEqual(part1(')())())'), -3);
21+
assert.strictEqual(part1(input), 280);
2122
});
2223
});
2324

2425
describe('Part 2', () => {
2526
it('should return index of the first character to enter the basement', () => {
26-
expect(part2(')')).toBe(1);
27-
expect(part2('()())')).toBe(5);
28-
expect(part2(input)).toBe(1797);
27+
assert.strictEqual(part2(')'), 1);
28+
assert.strictEqual(part2('()())'), 5);
29+
assert.strictEqual(part2(input), 1797);
2930
});
3031
});
3132
});

2015/day/10/index.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { part1, part2 } from './index.ts';
34

45
const input = '1113122113';
56

67
describe('Day 10', () => {
78
describe('Part 1', () => {
89
it('should process 40 iterations', () => {
9-
expect.assertions(1);
10-
11-
expect(part1(input)).toStrictEqual(360154);
10+
assert.strictEqual(part1(input), 360154);
1211
});
1312
});
1413

1514
describe('Part 2', () => {
1615
it('should process 50 iterations', () => {
17-
expect.assertions(1);
18-
19-
expect(part2(input)).toStrictEqual(5103798);
16+
assert.strictEqual(part2(input), 5103798);
2017
});
2118
});
2219
});

2015/day/12/index.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import assert from 'node:assert/strict';
12
import { readFile } from 'node:fs/promises';
2-
import { describe, expect, it } from 'vitest';
3-
import { part1 } from '.';
3+
import { describe, it } from 'node:test';
4+
import { part1 } from './index.ts';
45

5-
const input = await readFile(`${__dirname}/input`, 'utf-8');
6+
const input = await readFile(`${import.meta.dirname}/input`, 'utf-8');
67

78
describe('Day 12', () => {
89
describe('Part 1', () => {
910
it('should sum up app numbers in JSON object', () => {
10-
expect.assertions(1);
11-
12-
expect(part1(input)).toStrictEqual(119433);
11+
assert.strictEqual(part1(input), 119433);
1312
});
1413
});
1514
});

2015/day/14/index.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import assert from 'node:assert/strict';
12
import { readFile } from 'node:fs/promises';
2-
import { describe, expect, it } from 'vitest';
3-
import { part1 } from '.';
3+
import { describe, it } from 'node:test';
4+
import { part1 } from './index.ts';
45

5-
const input = (await readFile(`${__dirname}/input`, 'utf-8')).split('\n');
6+
const input = (await readFile(`${import.meta.dirname}/input`, 'utf-8')).split('\n');
67

78
describe('Day 14', () => {
89
describe('Part 1', () => {
910
it('should return the max distance', () => {
10-
expect.assertions(1);
11-
12-
expect(part1(input)).toStrictEqual(2660);
11+
assert.strictEqual(part1(input), 2660);
1312
});
1413
});
1514
});

2015/day/15/index.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1 } from '.';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { part1 } from './index.ts';
34

45
describe('Day 15', () => {
56
describe('Part 1', () => {
67
it('should', () => {
7-
expect.assertions(1);
8-
9-
expect(part1()).toStrictEqual(0);
8+
assert.strictEqual(part1(), 0);
109
});
1110
});
1211
});

2015/day/16/index.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
import assert from 'node:assert/strict';
12
import { readFile } from 'node:fs/promises';
2-
import { describe, expect, it } from 'vitest';
3-
import { part1 } from '.';
3+
import { describe, it } from 'node:test';
4+
import { part1 } from './index.ts';
45

5-
const input = (await readFile(`${__dirname}/input`, 'utf-8')).split('\n');
6+
const input = (await readFile(`${import.meta.dirname}/input`, 'utf-8')).split('\n');
67

78
describe('Day 16', () => {
89
describe('Part 1', () => {
910
it('should find the number of the Sue that got you the gift ', () => {
10-
expect.assertions(1);
11-
12-
expect(part1(input)).toStrictEqual(373);
11+
assert.strictEqual(part1(input), 373);
1312
});
1413
});
1514
});

2015/day/2/index.test.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
3-
import { getInput } from '../../../utils/file';
4-
import { NEWLINE } from '../../../utils/string';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { NEWLINE } from '../../../utils/string.ts';
5+
import { part1, part2 } from './index.ts';
56

6-
const input = (await getInput(__dirname)).split(NEWLINE);
7+
const input = (await getInput(import.meta.dirname)).split(NEWLINE);
78

89
describe('2015', () => {
910
describe('Day 1', () => {
1011
describe('Part 1', () => {
1112
it('should return total square feet of wrapping paper', () => {
12-
expect(part1(['2x3x4'])).toBe(58);
13-
expect(part1(['1x1x10'])).toBe(43);
14-
expect(part1(input)).toBe(1598415);
13+
assert.strictEqual(part1(['2x3x4']), 58);
14+
assert.strictEqual(part1(['1x1x10']), 43);
15+
assert.strictEqual(part1(input), 1598415);
1516
});
1617
});
1718

1819
describe('Part 2', () => {
1920
it('should return total feet of ribbon', () => {
20-
expect(part2(['2x3x4'])).toBe(34);
21-
expect(part2(['1x1x10'])).toBe(14);
22-
expect(part2(input)).toBe(3812909);
21+
assert.strictEqual(part2(['2x3x4']), 34);
22+
assert.strictEqual(part2(['1x1x10']), 14);
23+
assert.strictEqual(part2(input), 3812909);
2324
});
2425
});
2526
});

2015/day/2/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RADIX, sum } from '../../../utils/math';
1+
import { RADIX, sum } from '../../../utils/math.ts';
22

33
function getArea(length: number, width: number): number {
44
return length * width;

2015/day/3/index.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
3-
import { getInput } from '../../../utils/file';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { part1, part2 } from './index.ts';
45

5-
const input = await getInput(__dirname);
6+
const input = await getInput(import.meta.dirname);
67

78
describe('2015', () => {
89
describe('Day 3', () => {
910
describe('Part 1', () => {
1011
it('should return number of unique locations visited', () => {
11-
expect(part1('>')).toBe(2);
12-
expect(part1('^>v<')).toBe(4);
13-
expect(part1('^v^v^v^v^v')).toBe(2);
14-
expect(part1(input)).toBe(2081);
12+
assert.strictEqual(part1('>'), 2);
13+
assert.strictEqual(part1('^>v<'), 4);
14+
assert.strictEqual(part1('^v^v^v^v^v'), 2);
15+
assert.strictEqual(part1(input), 2081);
1516
});
1617
});
1718

1819
describe('Part 2', () => {
1920
it('should return number of unique locations visited by santa and robo-santa', () => {
20-
expect(part2('^v')).toBe(3);
21-
expect(part2('^>v<')).toBe(3);
22-
expect(part2('^v^v^v^v^v')).toBe(11);
23-
expect(part2(input)).toBe(2341);
21+
assert.strictEqual(part2('^v'), 3);
22+
assert.strictEqual(part2('^>v<'), 3);
23+
assert.strictEqual(part2('^v^v^v^v^v'), 11);
24+
assert.strictEqual(part2(input), 2341);
2425
});
2526
});
2627
});

2015/day/4/index.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { part1, part2 } from './index.ts';
34

45
const input = 'ckczppom';
56

67
describe('2015', () => {
78
describe('Day 4', () => {
89
describe('Part 1', () => {
910
it('should find a hash which starts with five zeros', () => {
10-
expect(part1('abcdef')).toBe(609043);
11-
expect(part1('pqrstuv')).toBe(1048970);
12-
expect(part1(input)).toBe(117946);
11+
assert.strictEqual(part1('abcdef'), 609043);
12+
assert.strictEqual(part1('pqrstuv'), 1048970);
13+
assert.strictEqual(part1(input), 117946);
1314
});
1415
});
1516

1617
describe('Part 2', () => {
1718
it('should find a hash which starts with six zeros', () => {
18-
expect(part2(input)).toBe(3938038);
19+
assert.strictEqual(part2(input), 3938038);
1920
});
2021
});
2122
});

2015/day/5/index.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
3-
import { getInput } from '../../../utils/file';
4-
import { NEWLINE } from '../../../utils/string';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { NEWLINE } from '../../../utils/string.ts';
5+
import { part1, part2 } from './index.ts';
56

6-
const input = (await getInput(__dirname)).split(NEWLINE);
7+
const input = (await getInput(import.meta.dirname)).split(NEWLINE);
78

89
describe('2015', () => {
910
describe('Day 5', () => {
1011
describe('Part 1', () => {
1112
it('should filter out nice words', () => {
12-
expect(
13+
assert.strictEqual(
1314
part1([
1415
'ugknbfddgicrmopn',
1516
'aaa',
1617
'jchzalrnumimnmhp',
1718
'haegwjzuvuyypxyu',
1819
'dvszwmarrgswjxmb',
1920
]),
20-
).toBe(2);
21-
expect(part1(input)).toBe(255);
21+
2,
22+
);
23+
assert.strictEqual(part1(input), 255);
2224
});
2325
});
2426

2527
describe('Part 2', () => {
2628
it('should filter out nice words', () => {
27-
expect(part2(['qjhvhtzxzqqjkmpb', 'xxyxx', 'uurcxstgmygtbstg', 'ieodomkazucvgmuy'])).toBe(
29+
assert.strictEqual(
30+
part2(['qjhvhtzxzqqjkmpb', 'xxyxx', 'uurcxstgmygtbstg', 'ieodomkazucvgmuy']),
2831
2,
2932
);
30-
expect(part2(input)).toBe(55);
33+
assert.strictEqual(part2(input), 55);
3134
});
3235
});
3336
});

2015/day/6/index.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1, part2 } from '.';
3-
import { getInput } from '../../../utils/file';
4-
import { NEWLINE } from '../../../utils/string';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { NEWLINE } from '../../../utils/string.ts';
5+
import { part1, part2 } from './index.ts';
56

6-
const input = (await getInput(__dirname)).split(NEWLINE);
7+
const input = (await getInput(import.meta.dirname)).split(NEWLINE);
78

89
describe('2015', () => {
910
describe('Day 6', () => {
1011
describe('Part 1', () => {
1112
it('should could could lit lights', () => {
12-
expect(part1(input)).toBe(377891);
13+
assert.strictEqual(part1(input), 377891);
1314
});
1415
});
1516

1617
describe('Part 2', () => {
1718
it('should return the total brightness', () => {
18-
expect(part2(input)).toBe(14110788);
19+
assert.strictEqual(part2(input), 14110788);
1920
});
2021
});
2122
});

2015/day/6/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RADIX, sum } from '../../../utils/math';
1+
import { RADIX, sum } from '../../../utils/math.ts';
22

33
const BASE = 1000;
44

2015/day/8/index.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { describe, expect, it } from 'vitest';
2-
import { part1 } from '.';
3-
import { getInput } from '../../../utils/file';
4-
import { NEWLINE } from '../../../utils/string';
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { getInput } from '../../../utils/file.ts';
4+
import { NEWLINE } from '../../../utils/string.ts';
5+
import { part1 } from './index.ts';
56

6-
const input = (await getInput(__dirname)).split(NEWLINE);
7+
const input = (await getInput(import.meta.dirname)).split(NEWLINE);
78

89
describe('2015', () => {
910
describe('Day 8', () => {
1011
describe('Part 1', () => {
1112
it('should return the number of characters', () => {
12-
expect(part1(['""', '"abc"', '"aaa\\"aaa"', '"\\x27"'])).toBe(12);
13-
expect(part1(input)).toBe(1350);
13+
assert.strictEqual(part1(['""', '"abc"', '"aaa\\"aaa"', '"\\x27"']), 12);
14+
assert.strictEqual(part1(input), 1350);
1415
});
1516
});
1617
});

2015/day/8/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sum } from '../../../utils/math';
1+
import { sum } from '../../../utils/math.ts';
22

33
function mapString(str: string): number {
44
const { length: totalCharacters } = str;

0 commit comments

Comments
 (0)