Skip to content

Commit

Permalink
fixed windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaWise committed Feb 1, 2024
1 parent d84b077 commit 630fe7d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/toml-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const fs = require('fs');
const path = require('path');
const { EOL } = require('os');
const { expect } = require('chai');
const { SourceError } = require('super-sources');
const { parse, LocalTime, LocalDate, LocalDateTime, OffsetDateTime } = require('..');
Expand Down Expand Up @@ -41,7 +42,7 @@ describe('Official TOML test suite', function () {
let json;

if (testName.startsWith('valid/')) {
json = JSON.parse(fs.readFileSync(completePath.slice(0, -5) + '.json'), 'utf8');
json = JSON.parse(normalizeLines(fs.readFileSync(completePath.slice(0, -5) + '.json', 'utf8')));
} else if (!testName.startsWith('invalid/')) {
throw new TypeError('Unexpected test name');
}
Expand Down Expand Up @@ -103,3 +104,9 @@ function format(table) {
}
return clone;
}

function normalizeLines(str) {
if (EOL === '\n') return str;
if (EOL === '\r\n') return str.replace(/\\n/g, '\\r\\n');
throw new TypeError('Unexpected EOL');
}

0 comments on commit 630fe7d

Please sign in to comment.