Skip to content

Commit

Permalink
+ Util-test += ShExUtil.getPredicateUsage()
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Prud'hommeaux committed Sep 27, 2020
1 parent abd6159 commit c5e8342
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/shex-util/shex-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ const ShExUtil = {

let predicates = { } // IRI->{ uses: [shapeLabel], commonType: shapeExpr }
Object.keys(schema.shapes).forEach(shapeLabel => {
let shapeExpr = _ShExUtil.skipDecl(schema.shapes[shapeLabel])
let shapeExpr = schema.shapes[shapeLabel]
if (shapeExpr.type === 'Shape') {
let tcs = _ShExUtil.simpleTripleConstraints(shapeExpr) || []
tcs.forEach(tc => {
Expand Down
13 changes: 13 additions & 0 deletions test/Util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,19 @@ describe('shex-util:', function () {
})
})

describe('utility function getPredicateUsage', function () {
const parser = ShExParser.construct(Base, {}, {index: false})
Tests.forEach(test => {
it (`should nest ${test.name}`, function () {
const orig = parser.parse(test.schema)
const unaltered = JSON.parse(JSON.stringify(orig))
const untyped = {}
const predicateUsage = ShExUtil.getPredicateUsage(unaltered, untyped)
expect(predicateUsage).to.deep.equal(test.predicateUsage)
})
})
})

describe('utility function getProofGraph', function () {
it (`should parse validation results`, function () {
const store = new N3.Store()
Expand Down

0 comments on commit c5e8342

Please sign in to comment.