-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var vows=require('vows'); | ||
var assert=require('assert'); | ||
var sparqlParser=require('./../sparql.js'); | ||
|
||
var p = sparqlParser.parse; | ||
|
||
|
||
vows.describe('js3 Equality tests').addBatch( | ||
{ 'Resolve "sp:path"': function(){ assert.equal("sp:path".resolve(), "http://spinrdf.org/sp#path"); } | ||
, 'Resolve "path"': | ||
{ topic: {path: "abc"}.ref('_:test') | ||
, 'toNT()': function(t){ assert.equal(t.toNT(), '_:test <http://spinrdf.org/sp#path> "abc" .'); } | ||
} | ||
} | ||
).export(module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var vows=require('vows'); | ||
var assert=require('assert'); | ||
var sparqlParser=require('./../sparql.js'); | ||
|
||
var p = sparqlParser.parse; | ||
|
||
|
||
vows.describe('js3 Equality tests').addBatch({ | ||
'SELECT * {?x a ?z}': | ||
{ topic: p("SELECT * {?x a ?z}").ref('_:query') | ||
//, 'Output structure': function(t){ console.log(t); } | ||
//, 'Output NT': function(t){ console.log(t.toNT()); } | ||
, 'Variable list empty 1': function(t){ assert.isUndefined(t["http://spinrdf.org/sp#resultVariables"]); } | ||
, 'Variable list empty 2': function(t){ assert.isEmpty(t["sp:resultVariables"]); } | ||
, 'a == "http://spinrdf.org/sp#Select"': function(t){ assert.equal(t.a.resolve(), "http://spinrdf.org/sp#Select"); } | ||
, 'a == "sp:Select"': function(t){ assert.equal(t.a, "sp:Select"); } | ||
, 'has sp:where': function(t){ assert.ok(t["sp:where"]); } | ||
, 'Graph:': | ||
{ topic: function(t){return t.graphify();} | ||
, 'Has index': function(graph){assert.isObject(graph.index); } | ||
, 'Has _:query': function(graph){assert.isObject(graph.index['_:query']); } | ||
, 'Has _:query / sp:where': function(graph){assert.isArray(graph.index['_:query']['sp:where']); } | ||
, '_:query / sp:where': | ||
{ topic: function(graph){ return {graph:graph, subject:graph.index['_:query']['sp:where'][0]}; } | ||
, '...exists': function(t){ assert.isObject(t.graph.index[t.subject]); } | ||
, 'Has /sp:path': function(t){ assert.isArray(t.graph.index[t.subject]['sp:path']); } | ||
, 'Single /sp:path': function(t){ assert.strictEqual(t.graph.index[t.subject]['sp:path'].length, 1); } | ||
, '/ sp:path': | ||
{ topic: function(t){ return {graph:t.graph, subject:t.graph.index[t.subject]['sp:path'][0]}; } | ||
, '...exists': function(t){ assert.isObject(t.graph.index[t.subject]); } | ||
, 'Has /rdf:first': function(t){ assert.isArray(t.graph.index[t.subject]['rdf:first'.resolve()]); } | ||
, 'Single /rdf:first': function(t){ assert.strictEqual(t.graph.index[t.subject]['rdf:first'.resolve()].length, 1); } | ||
, '/rdf:first == "a"': function(t){ assert.strictEqual(t.graph.index[t.subject]['rdf:first'.resolve()][0], "a"); } | ||
, 'Has /rdf:rest': function(t){ assert.isArray(t.graph.index[t.subject]['rdf:rest'.resolve()]); } | ||
, 'Single /rdf:rest': function(t){ assert.strictEqual(t.graph.index[t.subject]['rdf:rest'.resolve()].length, 1); } | ||
, '/rdf:rest == rdf:nil': function(t){ assert.strictEqual(t.graph.index[t.subject]['rdf:rest'.resolve()][0], "rdf:nil".resolve()); } | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); |