Skip to content

Test suite update (Dec 2018) #12

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

Merged
merged 8 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ The [original library](https://github.com/kazarena/json-gold) was written by Sta

## Testing & Compliance ##

As of December 1, 2017:
As of December 26, 2018:

* all JSON-LD 1.0 tests from the [official JSON-LD test suite](https://github.com/json-ld/json-ld.org/tree/master/test-suite) pass
* all JSON-LD 1.0 tests from the [official JSON-LD test suite](https://github.com/json-ld/json-ld.org/tree/master/test-suite) pass, with one exception: [framing test #tg010](https://github.com/melville-wiley/json-ld.org/blob/3461fd0005cd8e338cd3729c4714163e9217e619/test-suite/tests/frame-manifest.jsonld#L530). See the discussion [here](https://github.com/json-ld/json-ld.org/pull/663). It appears that while it's meant to be a 1.0 test, the fix in pyLD was implemented in the 1.1 section of the framing code. This needs further investigation.
* all RDF Dataset Normalisation tests from the [current test suite](https://json-ld.github.io/normalization/tests/index.html) pass
* JSON-LD 1.1 spec is not currenty supported

Expand Down
33 changes: 22 additions & 11 deletions ld/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ func (c *Context) parse(localContext interface{}, remoteContexts []string) (*Con
} else if vocabString, isString := vocabValue.(string); isString {
if IsAbsoluteIri(vocabString) {
result.values["@vocab"] = vocabValue
} else if vocabString == "" {
if baseVal, hasBase := result.values["@base"]; hasBase {
result.values["@vocab"] = baseVal
} else {
return nil, NewJsonLdError(InvalidVocabMapping, "@vocab is empty but @base is not specified")
}
} else {
return nil, NewJsonLdError(InvalidVocabMapping, "@vocab must be an absolute IRI")
}
Expand Down Expand Up @@ -1012,22 +1018,27 @@ func (c *Context) ExpandValue(activeProperty string, value interface{}) (interfa
td := c.GetTermDefinition(activeProperty)
// 1)
if td != nil && td["@type"] == "@id" {
// TODO: i'm pretty sure value should be a string if the @type is
// @id
var err error
rval["@id"], err = c.ExpandIri(value.(string), true, false, nil, nil)
if err != nil {
return nil, err
if strVal, isString := value.(string); isString {
var err error
rval["@id"], err = c.ExpandIri(strVal, true, false, nil, nil)
if err != nil {
return nil, err
}
} else {
rval["@value"] = value
}
return rval, nil
}
// 2)
if td != nil && td["@type"] == "@vocab" {
// TODO: same as above
var err error
rval["@id"], err = c.ExpandIri(value.(string), true, true, nil, nil)
if err != nil {
return nil, err
if strVal, isString := value.(string); isString {
var err error
rval["@id"], err = c.ExpandIri(strVal, true, true, nil, nil)
if err != nil {
return nil, err
}
} else {
rval["@value"] = value
}
return rval, nil
}
Expand Down
9 changes: 7 additions & 2 deletions ld/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ func TestSuite(t *testing.T) {
expectedFileName = testMap["result"].(string)
}

testName := testId
if strings.HasPrefix(testName, "#") {
testName = manifestURI + testName
}

td := &TestDefinition{
Id: testId,
Name: manifestURI + testId,
Name: testName,
Type: testType,
EvaluationType: testEvaluationType,
InputURL: inputURL,
Expand Down Expand Up @@ -402,7 +407,7 @@ func TestSuite(t *testing.T) {
options.Algorithm = "URGNA2012"
result, opError = proc.Normalize(input, options)
case "rdfn:Urdna2015EvalTest":
log.Println("Running URDNA2015 test", td.Id, ":", td.Name)
log.Println("Running URDNA2015 test", td.Name)

inputBytes, err := ioutil.ReadFile(td.InputFileName)
assert.NoError(t, err)
Expand Down
44 changes: 41 additions & 3 deletions ld/serialize_nquads.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,47 @@ func escape(str string) string {
}

const (
wso = "[ \\t]*"
iri = "(?:<([^>]*)>)"
bnode = "(_:(?:[A-Za-z][A-Za-z0-9]*))"
wso = "[ \\t]*"
iri = "(?:<([^:]+:[^>]*)>)"

// https://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL

pnCharsBase = "A-Z" + "a-z" +
"\u00C0-\u00D6" +
"\u00D8-\u00F6" +
"\u00F8-\u02FF" +
"\u0370-\u037D" +
"\u037F-\u1FFF" +
"\u200C-\u200D" +
"\u2070-\u218F" +
"\u2C00-\u2FEF" +
"\u3001-\uD7FF" +
"\uF900-\uFDCF" +
"\uFDF0-\uFFFD"
// TODO:
//"\u10000-\uEFFFF"

pnCharsU = pnCharsBase + "_"

pnChars = pnCharsU +
"0-9" +
"-" +
"\u00B7" +
"\u0300-\u036F" +
"\u203F-\u2040"

blankNodeLabel = "(_:" +
"(?:[" + pnCharsU + "0-9])" +
"(?:(?:[" + pnChars + ".])*(?:[" + pnChars + "]))?" +
")"

// '(_:' +
// '(?:[' + PN_CHARS_U + '0-9])' +
// '(?:(?:[' + PN_CHARS + '.])*(?:[' + PN_CHARS + ']))?' +
// ')';

bnode = blankNodeLabel

plain = "\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\""
datatype = "(?:\\^\\^" + iri + ")"
language = "(?:@([a-z]+(?:-[a-zA-Z0-9]+)*))"
Expand Down
7 changes: 7 additions & 0 deletions ld/testdata/compact-0077-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": {
"@version": 1.1,
"input": {"@id": "foo:input", "@container": "@graph"},
"value": "foo:value"
}
}
10 changes: 10 additions & 0 deletions ld/testdata/compact-0077-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"@context": {
"@version": 1.1,
"input": {"@id": "foo:input", "@container": "@graph"},
"value": "foo:value"
},
"input": {
"value": "x"
}
}
13 changes: 13 additions & 0 deletions ld/testdata/compact-0077-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": {
"@version": 1.1,
"input": {
"@id": "foo:input",
"@container": "@graph"
},
"value": "foo:value"
},
"input": {
"value": "x"
}
}
7 changes: 7 additions & 0 deletions ld/testdata/compact-0078-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": {
"@version": 1.1,
"input": {"@id": "foo:input", "@container": ["@graph", "@set"]},
"value": "foo:value"
}
}
10 changes: 10 additions & 0 deletions ld/testdata/compact-0078-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"@context": {
"@version": 1.1,
"input": {"@id": "foo:input", "@container": "@graph"},
"value": "foo:value"
},
"input": {
"value": "x"
}
}
13 changes: 13 additions & 0 deletions ld/testdata/compact-0078-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"@context": {
"@version": 1.1,
"input": {
"@id": "foo:input",
"@container": ["@graph", "@set"]
},
"value": "foo:value"
},
"input": [{
"value": "x"
}]
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0079-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
}
}
8 changes: 8 additions & 0 deletions ld/testdata/compact-0079-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"http://example.org/input": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}],
"@index": "ndx"
}]
}]
9 changes: 9 additions & 0 deletions ld/testdata/compact-0079-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"value": "x"
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0080-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
}
}
8 changes: 8 additions & 0 deletions ld/testdata/compact-0080-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"http://example.org/input": [{
"@id": "http://example.org/gid",
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}]
}]
}]
10 changes: 10 additions & 0 deletions ld/testdata/compact-0080-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": "@graph"}
},
"input": {
"@id": "http://example.org/gid",
"@graph": {"value": "x"}
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0081-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index"]}
}
}
8 changes: 8 additions & 0 deletions ld/testdata/compact-0081-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"http://example.org/input": [{
"@index": "g1",
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}]
}]
}]
9 changes: 9 additions & 0 deletions ld/testdata/compact-0081-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index"]}
},
"input": {
"g1": {"value": "x"}
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0082-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index", "@set"]}
}
}
8 changes: 8 additions & 0 deletions ld/testdata/compact-0082-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"http://example.org/input": [{
"@index": "g1",
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}]
}]
}]
9 changes: 9 additions & 0 deletions ld/testdata/compact-0082-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index", "@set"]}
},
"input": {
"g1": [{"value": "x"}]
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0083-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index"]}
}
}
9 changes: 9 additions & 0 deletions ld/testdata/compact-0083-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[{
"http://example.org/input": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}],
"@index": "g1",
"@id": "http://example.org/id"
}]
}]
11 changes: 11 additions & 0 deletions ld/testdata/compact-0083-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@index"]}
},
"input": {
"@id": "http://example.org/id",
"@index": "g1",
"@graph": {"value": "x"}
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0084-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@id"]}
}
}
7 changes: 7 additions & 0 deletions ld/testdata/compact-0084-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[{
"http://example.org/input": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}]
}]
}]
9 changes: 9 additions & 0 deletions ld/testdata/compact-0084-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@id"]}
},
"input": {
"@none": {"value": "x"}
}
}
6 changes: 6 additions & 0 deletions ld/testdata/compact-0085-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"@vocab": "http://example.org/",
"input": {"@container": ["@graph", "@id"]}
}
}
8 changes: 8 additions & 0 deletions ld/testdata/compact-0085-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[{
"http://example.org/input": [{
"@graph": [{
"http://example.org/value": [{"@value": "x"}]
}],
"@id": "http://example.org/id"
}]
}]
Loading