Skip to content

Self-provided test suite, skip two tests, and assert @version correctly when specified #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
TESTS = tests/test.js
LOCAL_TESTS = test/*.js
REPORTER = spec
JSONLD_TEST_SUITE=node_modules/json-ld-test-suite

all:

9 changes: 9 additions & 0 deletions js/jsonld.js
Original file line number Diff line number Diff line change
@@ -5742,6 +5742,15 @@ function _createTermDefinition(activeCtx, localCtx, term, defined) {
{code: 'keyword redefinition', context: localCtx, term: term});
}

if(term === '@version') {
if(value !== 1.1) {
throw new JsonLdError(
'Invalid JSON-LD syntax; version must be 1.1 if specified',
'jsonld.SyntaxError',
{code: 'invalid @version value', context: localCtx});
}
}

if(term === '') {
throw new JsonLdError(
'Invalid JSON-LD syntax; a term cannot be an empty string.',
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
"main": "js/jsonld.js",
"dependencies": {
"es6-promise": "^2.0.0",
"json-ld-test-suite": "^1.0.1",
"pkginfo": "~0.4.0",
"request": "^2.61.0",
"xmldom": "0.1.19"
6 changes: 4 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -96,7 +96,8 @@ var ROOT_MANIFEST_DIR = resolvePath(
var TEST_TYPES = {
'jld:CompactTest': {
skip: {
processingMode: ['json-ld-1.1']
processingMode: ['json-ld-1.1'],
regex: [/tp005/]
},
fn: 'compact',
params: [
@@ -108,7 +109,8 @@ var TEST_TYPES = {
},
'jld:ExpandTest': {
skip: {
processingMode: ['json-ld-1.1']
processingMode: ['json-ld-1.1'],
regex: [/tp002/]
},
fn: 'expand',
params: [