Skip to content

Commit 3872ad5

Browse files
committed
Use rdf-canonize to compare n-quads.
- Avoids issues with expected output n-quad ordering and blank node labels.
1 parent c07ddf6 commit 3872ad5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# jsonld ChangeLog
22

3+
### Fixed
4+
- Use rdf-canonize to compare n-quads test results.
5+
36
### Changed
47
- Use JSON-LD WG tests.
58

tests/test-common.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
const EarlReport = require('./earl-report');
1010
const benchmark = require('benchmark');
1111
const join = require('join-path-js');
12+
const rdfCanonize = require('rdf-canonize');
1213

1314
module.exports = function(options) {
1415

@@ -562,7 +563,12 @@ async function compareExpectedNQuads(test, result) {
562563
let expect;
563564
try {
564565
expect = await readTestNQuads(_getExpectProperty(test))(test);
565-
assert.strictEqual(result, expect);
566+
let opts = {algorithm: 'URDNA2015'};
567+
let expectDataset = rdfCanonize.NQuads.parse(expect);
568+
let expectCmp = await rdfCanonize.canonize(expectDataset, opts);
569+
let resultDataset = rdfCanonize.NQuads.parse(result);
570+
let resultCmp = await rdfCanonize.canonize(resultDataset, opts);
571+
assert.strictEqual(resultCmp, expectCmp);
566572
} catch(err) {
567573
if(options.bailOnError) {
568574
console.log('\nTEST FAILED\n');

0 commit comments

Comments
 (0)