Add blank prefix tests, update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Thu, 03 May 2012 15:35:08 -0400
changeset 619 47c6b95254e4
parent 618 b069b6961456
child 620 afcd956fd963
Add blank prefix tests, update to latest jsonld.js.
playground/jsonld.js
test-suite/tests/compact-0019-context.jsonld
test-suite/tests/compact-0019-in.jsonld
test-suite/tests/compact-0019-out.jsonld
test-suite/tests/compact-manifest.jsonld
test-suite/tests/expand-0027-in.jsonld
test-suite/tests/expand-0028-in.jsonld
test-suite/tests/expand-0028-out.jsonld
test-suite/tests/expand-manifest.jsonld
--- a/playground/jsonld.js	Fri May 04 02:59:58 2012 +0800
+++ b/playground/jsonld.js	Thu May 03 15:35:08 2012 -0400
@@ -1597,15 +1597,9 @@
       continue;
     }
 
-    // if graph is not the default graph
-    if(name !== '') {
-      // add graph subject to default graph as needed
-      if(!(name in defaultGraph.subjects)) {
-        defaultGraph.subjects[name] = {'@id': name};
-      }
-      else {
-        defaultGraph.subjects[name];
-      }
+    // add graph subject to default graph as needed
+    if(name !== '' && !(name in defaultGraph.subjects)) {
+      defaultGraph.subjects[name] = {'@id': name};
     }
 
     // add subject to graph as needed
@@ -1775,32 +1769,33 @@
     // recurse over subject properties in order
     var props = Object.keys(element).sort();
     for(var pi in props) {
-      var prop = p = props[pi];
+      var prop = props[pi];
+      var e = element[prop];
 
       // convert @type to rdf:type
       if(prop === '@type') {
-        p = RDF_TYPE;
+        prop = RDF_TYPE;
       }
 
       // recurse into @graph
       if(prop === '@graph') {
-        this.toRDF(element[prop], namer, null, null, subject, callback);
+        this.toRDF(e, namer, null, null, subject, callback);
         continue;
       }
 
       // skip keywords
-      if(_isKeyword(p)) {
+      if(_isKeyword(prop)) {
         continue;
       }
 
       // create new active property
       property = {
-        nominalValue: p,
+        nominalValue: prop,
         interfaceName: 'IRI'
       };
 
       // recurse into value
-      this.toRDF(element[prop], namer, subject, property, graph, callback);
+      this.toRDF(e, namer, subject, property, graph, callback);
     }
 
     return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0019-context.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -0,0 +1,3 @@
+{
+  "@context": {"": "http://example.com/default#"}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0019-in.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -0,0 +1,5 @@
+[
+  {
+    "http://example.com/default#foo": ["bar"]
+  }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0019-out.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -0,0 +1,4 @@
+{
+  "@context": {"": "http://example.com/default#"},
+  ":foo": "bar"
+}
--- a/test-suite/tests/compact-manifest.jsonld	Fri May 04 02:59:58 2012 +0800
+++ b/test-suite/tests/compact-manifest.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -113,5 +113,11 @@
     "input": "compact-0018-in.jsonld",
     "context": "compact-0018-context.jsonld",
     "expect": "compact-0018-out.jsonld"
+  }, {
+    "@type": ["test:TestCase", "jld:CompactTest"],
+    "name": "Blank prefix",
+    "input": "compact-0019-in.jsonld",
+    "context": "compact-0019-context.jsonld",
+    "expect": "compact-0019-out.jsonld"
   }]
 }
--- a/test-suite/tests/expand-0027-in.jsonld	Fri May 04 02:59:58 2012 +0800
+++ b/test-suite/tests/expand-0027-in.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -6,5 +6,6 @@
     }
   },
   "@id": "http://example.org/",
-  "": "http://example.org/blank"
+  "": "http://example.org/blank",
+  "_empty_": "drop me"
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0028-in.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -0,0 +1,4 @@
+{
+  "@context": {"": "http://example.com/default#"},
+  ":foo": "bar"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0028-out.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -0,0 +1,5 @@
+[
+  {
+    "http://example.com/default#foo": ["bar"]
+  }
+]
--- a/test-suite/tests/expand-manifest.jsonld	Fri May 04 02:59:58 2012 +0800
+++ b/test-suite/tests/expand-manifest.jsonld	Thu May 03 15:35:08 2012 -0400
@@ -139,6 +139,11 @@
     "name": "Blank term",
     "input": "expand-0027-in.jsonld",
     "expect": "expand-0027-out.jsonld"
+  }, {
+    "@type": ["test:TestCase", "jld:ExpandTest"],
+    "name": "Blank prefix",
+    "input": "expand-0028-in.jsonld",
+    "expect": "expand-0028-out.jsonld"
   }
   ]
 }