Skip to content

Commit 2ad5eda

Browse files
authored
Merge pull request #12 from piprate/test-suite-update-dec-2018
Test suite update (Dec 2018)
2 parents d835a9c + 170f4a0 commit 2ad5eda

File tree

309 files changed

+4533
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+4533
-227
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ The [original library](https://github.com/kazarena/json-gold) was written by Sta
1616

1717
## Testing & Compliance ##
1818

19-
As of December 1, 2017:
19+
As of December 26, 2018:
2020

21-
* 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
21+
* 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.
2222
* all RDF Dataset Normalisation tests from the [current test suite](https://json-ld.github.io/normalization/tests/index.html) pass
2323
* JSON-LD 1.1 spec is not currenty supported
2424

ld/context.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ func (c *Context) parse(localContext interface{}, remoteContexts []string) (*Con
167167
} else if vocabString, isString := vocabValue.(string); isString {
168168
if IsAbsoluteIri(vocabString) {
169169
result.values["@vocab"] = vocabValue
170+
} else if vocabString == "" {
171+
if baseVal, hasBase := result.values["@base"]; hasBase {
172+
result.values["@vocab"] = baseVal
173+
} else {
174+
return nil, NewJsonLdError(InvalidVocabMapping, "@vocab is empty but @base is not specified")
175+
}
170176
} else {
171177
return nil, NewJsonLdError(InvalidVocabMapping, "@vocab must be an absolute IRI")
172178
}
@@ -1012,22 +1018,27 @@ func (c *Context) ExpandValue(activeProperty string, value interface{}) (interfa
10121018
td := c.GetTermDefinition(activeProperty)
10131019
// 1)
10141020
if td != nil && td["@type"] == "@id" {
1015-
// TODO: i'm pretty sure value should be a string if the @type is
1016-
// @id
1017-
var err error
1018-
rval["@id"], err = c.ExpandIri(value.(string), true, false, nil, nil)
1019-
if err != nil {
1020-
return nil, err
1021+
if strVal, isString := value.(string); isString {
1022+
var err error
1023+
rval["@id"], err = c.ExpandIri(strVal, true, false, nil, nil)
1024+
if err != nil {
1025+
return nil, err
1026+
}
1027+
} else {
1028+
rval["@value"] = value
10211029
}
10221030
return rval, nil
10231031
}
10241032
// 2)
10251033
if td != nil && td["@type"] == "@vocab" {
1026-
// TODO: same as above
1027-
var err error
1028-
rval["@id"], err = c.ExpandIri(value.(string), true, true, nil, nil)
1029-
if err != nil {
1030-
return nil, err
1034+
if strVal, isString := value.(string); isString {
1035+
var err error
1036+
rval["@id"], err = c.ExpandIri(strVal, true, true, nil, nil)
1037+
if err != nil {
1038+
return nil, err
1039+
}
1040+
} else {
1041+
rval["@value"] = value
10311042
}
10321043
return rval, nil
10331044
}

ld/processor_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,14 @@ func TestSuite(t *testing.T) {
244244
expectedFileName = testMap["result"].(string)
245245
}
246246

247+
testName := testId
248+
if strings.HasPrefix(testName, "#") {
249+
testName = manifestURI + testName
250+
}
251+
247252
td := &TestDefinition{
248253
Id: testId,
249-
Name: manifestURI + testId,
254+
Name: testName,
250255
Type: testType,
251256
EvaluationType: testEvaluationType,
252257
InputURL: inputURL,
@@ -402,7 +407,7 @@ func TestSuite(t *testing.T) {
402407
options.Algorithm = "URGNA2012"
403408
result, opError = proc.Normalize(input, options)
404409
case "rdfn:Urdna2015EvalTest":
405-
log.Println("Running URDNA2015 test", td.Id, ":", td.Name)
410+
log.Println("Running URDNA2015 test", td.Name)
406411

407412
inputBytes, err := ioutil.ReadFile(td.InputFileName)
408413
assert.NoError(t, err)

ld/serialize_nquads.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,47 @@ func escape(str string) string {
132132
}
133133

134134
const (
135-
wso = "[ \\t]*"
136-
iri = "(?:<([^>]*)>)"
137-
bnode = "(_:(?:[A-Za-z][A-Za-z0-9]*))"
135+
wso = "[ \\t]*"
136+
iri = "(?:<([^:]+:[^>]*)>)"
137+
138+
// https://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL
139+
140+
pnCharsBase = "A-Z" + "a-z" +
141+
"\u00C0-\u00D6" +
142+
"\u00D8-\u00F6" +
143+
"\u00F8-\u02FF" +
144+
"\u0370-\u037D" +
145+
"\u037F-\u1FFF" +
146+
"\u200C-\u200D" +
147+
"\u2070-\u218F" +
148+
"\u2C00-\u2FEF" +
149+
"\u3001-\uD7FF" +
150+
"\uF900-\uFDCF" +
151+
"\uFDF0-\uFFFD"
152+
// TODO:
153+
//"\u10000-\uEFFFF"
154+
155+
pnCharsU = pnCharsBase + "_"
156+
157+
pnChars = pnCharsU +
158+
"0-9" +
159+
"-" +
160+
"\u00B7" +
161+
"\u0300-\u036F" +
162+
"\u203F-\u2040"
163+
164+
blankNodeLabel = "(_:" +
165+
"(?:[" + pnCharsU + "0-9])" +
166+
"(?:(?:[" + pnChars + ".])*(?:[" + pnChars + "]))?" +
167+
")"
168+
169+
// '(_:' +
170+
// '(?:[' + PN_CHARS_U + '0-9])' +
171+
// '(?:(?:[' + PN_CHARS + '.])*(?:[' + PN_CHARS + ']))?' +
172+
// ')';
173+
174+
bnode = blankNodeLabel
175+
138176
plain = "\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\""
139177
datatype = "(?:\\^\\^" + iri + ")"
140178
language = "(?:@([a-z]+(?:-[a-zA-Z0-9]+)*))"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {"@id": "foo:input", "@container": "@graph"},
5+
"value": "foo:value"
6+
}
7+
}

ld/testdata/compact-0077-in.jsonld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {"@id": "foo:input", "@container": "@graph"},
5+
"value": "foo:value"
6+
},
7+
"input": {
8+
"value": "x"
9+
}
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {
5+
"@id": "foo:input",
6+
"@container": "@graph"
7+
},
8+
"value": "foo:value"
9+
},
10+
"input": {
11+
"value": "x"
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {"@id": "foo:input", "@container": ["@graph", "@set"]},
5+
"value": "foo:value"
6+
}
7+
}

ld/testdata/compact-0078-in.jsonld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {"@id": "foo:input", "@container": "@graph"},
5+
"value": "foo:value"
6+
},
7+
"input": {
8+
"value": "x"
9+
}
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"input": {
5+
"@id": "foo:input",
6+
"@container": ["@graph", "@set"]
7+
},
8+
"value": "foo:value"
9+
},
10+
"input": [{
11+
"value": "x"
12+
}]
13+
}

0 commit comments

Comments
 (0)