Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created April 8, 2021 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/b2d4969662851d56bdb0a01a1120cfca to your computer and use it in GitHub Desktop.
Save BruJu/b2d4969662851d56bdb0a01a1120cfca to your computer and use it in GitHub Desktop.
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