Fix normalization test output, update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Sun, 22 Apr 2012 20:26:51 -0400
changeset 563 52c8ffbae3d2
parent 562 ab64343c078a
child 564 56087134ddc6
Fix normalization test output, update to latest jsonld.js.
playground/jsonld.js
test-suite/tests/normalize-0044-out.jsonld
test-suite/tests/normalize-0045-out.jsonld
test-suite/tests/normalize-0046-out.jsonld
--- a/playground/jsonld.js	Sun Apr 22 00:57:38 2012 -0400
+++ b/playground/jsonld.js	Sun Apr 22 20:26:51 2012 -0400
@@ -1251,7 +1251,7 @@
 
   // frame the subjects
   var framed = [];
-  _frame(state, state.subjects, frame, framed, null);
+  _frame(state, Object.keys(state.subjects), frame, framed, null);
   return framed;
 };
 
@@ -1871,10 +1871,9 @@
 
       // build adjacent path
       var path = '';
-      var recurse;
+      var recurse = [];
       for(var n in permutation) {
         var bnode = permutation[n];
-        recurse = [];
 
         // use canonical name if available
         if(namer.isNamed(bnode)) {
@@ -2160,9 +2159,7 @@
               o = src[n];
               // recurse into subject reference
               if(_isSubjectReference(o)) {
-                var _subjects = {};
-                _subjects[o['@id']] = o;
-                _frame(state, _subjects, frame[prop], list, '@list');
+                _frame(state, [o['@id']], frame[prop], list, '@list');
               }
               // include other values automatically
               else {
@@ -2174,9 +2171,7 @@
 
           // recurse into subject reference
           if(_isSubjectReference(o)) {
-            var _subjects = {};
-            _subjects[o['@id']] = o;
-            _frame(state, _subjects, frame[prop], output, prop);
+            _frame(state, [o['@id']], frame[prop], output, prop);
           }
           // include other values automatically
           else {
@@ -2254,9 +2249,9 @@
 function _filterSubjects(state, subjects, frame) {
   // filter subjects in @id order
   var rval = {};
-  var ids = Object.keys(subjects).sort();
-  for(var i in ids) {
-    var id = ids[i];
+  subjects.sort();
+  for(var i in subjects) {
+    var id = subjects[i];
     var subject = state.subjects[id];
     if(_filterSubject(subject, frame)) {
       rval[id] = subject;
--- a/test-suite/tests/normalize-0044-out.jsonld	Sun Apr 22 00:57:38 2012 -0400
+++ b/test-suite/tests/normalize-0044-out.jsonld	Sun Apr 22 20:26:51 2012 -0400
@@ -31,10 +31,10 @@
     "@id": "_:c14n10",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n7"
       },
       {
-        "@id": "_:c14n8"
+        "@id": "_:c14n9"
       },
       {
         "@id": "_:c14n11"
@@ -45,13 +45,13 @@
     "@id": "_:c14n11",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n7"
-      },
-      {
         "@id": "_:c14n8"
       },
       {
         "@id": "_:c14n10"
+      },
+      {
+        "@id": "_:c14n9"
       }
     ]
   },
@@ -132,10 +132,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n11"
+        "@id": "_:c14n8"
       }
     ]
   },
@@ -143,13 +143,13 @@
     "@id": "_:c14n8",
     "http://example.org/vocab#p": [
       {
+        "@id": "_:c14n7"
+      },
+      {
         "@id": "_:c14n6"
       },
       {
         "@id": "_:c14n11"
-      },
-      {
-        "@id": "_:c14n10"
       }
     ]
   },
@@ -160,10 +160,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n7"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n10"
+        "@id": "_:c14n11"
       }
     ]
   }
--- a/test-suite/tests/normalize-0045-out.jsonld	Sun Apr 22 00:57:38 2012 -0400
+++ b/test-suite/tests/normalize-0045-out.jsonld	Sun Apr 22 20:26:51 2012 -0400
@@ -31,10 +31,10 @@
     "@id": "_:c14n10",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n7"
       },
       {
-        "@id": "_:c14n8"
+        "@id": "_:c14n9"
       },
       {
         "@id": "_:c14n11"
@@ -45,13 +45,13 @@
     "@id": "_:c14n11",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n7"
-      },
-      {
         "@id": "_:c14n8"
       },
       {
         "@id": "_:c14n10"
+      },
+      {
+        "@id": "_:c14n9"
       }
     ]
   },
@@ -132,10 +132,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n11"
+        "@id": "_:c14n8"
       }
     ]
   },
@@ -143,13 +143,13 @@
     "@id": "_:c14n8",
     "http://example.org/vocab#p": [
       {
+        "@id": "_:c14n7"
+      },
+      {
         "@id": "_:c14n6"
       },
       {
         "@id": "_:c14n11"
-      },
-      {
-        "@id": "_:c14n10"
       }
     ]
   },
@@ -160,10 +160,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n7"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n10"
+        "@id": "_:c14n11"
       }
     ]
   }
--- a/test-suite/tests/normalize-0046-out.jsonld	Sun Apr 22 00:57:38 2012 -0400
+++ b/test-suite/tests/normalize-0046-out.jsonld	Sun Apr 22 20:26:51 2012 -0400
@@ -31,10 +31,10 @@
     "@id": "_:c14n10",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n7"
       },
       {
-        "@id": "_:c14n8"
+        "@id": "_:c14n9"
       },
       {
         "@id": "_:c14n11"
@@ -45,13 +45,13 @@
     "@id": "_:c14n11",
     "http://example.org/vocab#p": [
       {
-        "@id": "_:c14n7"
-      },
-      {
         "@id": "_:c14n8"
       },
       {
         "@id": "_:c14n10"
+      },
+      {
+        "@id": "_:c14n9"
       }
     ]
   },
@@ -132,10 +132,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n9"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n11"
+        "@id": "_:c14n8"
       }
     ]
   },
@@ -143,13 +143,13 @@
     "@id": "_:c14n8",
     "http://example.org/vocab#p": [
       {
+        "@id": "_:c14n7"
+      },
+      {
         "@id": "_:c14n6"
       },
       {
         "@id": "_:c14n11"
-      },
-      {
-        "@id": "_:c14n10"
       }
     ]
   },
@@ -160,10 +160,10 @@
         "@id": "_:c14n6"
       },
       {
-        "@id": "_:c14n7"
+        "@id": "_:c14n10"
       },
       {
-        "@id": "_:c14n10"
+        "@id": "_:c14n11"
       }
     ]
   }