Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created Apr 8, 2021
Embed
What would you like to do?
One day i'll learn how to write an issue
const assert = require('assert');
const N3 = require('n3');
const namespace = require('@rdfjs/namespace');
const ex = namespace("http://example.org/", N3.DataFactory);
const rdf = namespace("http://rdf.org/", N3.DataFactory);
describe('N3 Parser', function() {
it('should parse nested nested quad', function() {
let q = (new N3.Parser()).parse("<< << <sss> <ssp> <sso> >> <sp> <so> >> <p> <o> .")[0];
assert.ok(
q.equals(
N3.DataFactory.quad(
N3.DataFactory.quad(
N3.DataFactory.quad(
N3.DataFactory.namedNode("sss"),
N3.DataFactory.namedNode("ssp"),
N3.DataFactory.namedNode("sso"),
),
N3.DataFactory.namedNode("sp"),
N3.DataFactory.namedNode("so")
),
N3.DataFactory.namedNode("p"),
N3.DataFactory.namedNode("o")
)
)
);
});
it('N3.Store should be able to store nested quads', function() {
let q = (new N3.Parser()).parse("<< << <sss> <ssp> <sso> >> <sp> <so> >> <p> <o> .")[0];
let store = new N3.Store();
store.addQuad(q);
let quads = store.getQuads();
assert.strictEquals(quads.length, 1);
});
it('should parse nested quad in list', function() {
let q = (new N3.Parser()).parse("<a> <b> ( << <s> <p> <o> >> ).");
assert.ok(q.length >= 3);
// <a> <b> list
// list first <<s p o>>
// list rest nil
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment