Fix normalize test for removing duplicates, update jsonld.js.
--- a/playground/jsonld.js Thu Jan 12 13:31:11 2012 -0500
+++ b/playground/jsonld.js Mon Jan 16 15:53:19 2012 -0500
@@ -1644,16 +1644,11 @@
{
if(parent.constructor === Array)
{
- // do not add duplicate IRIs for the same property
- var duplicate = false;
- if(flattened.constructor === Object && '@id' in flattened)
+ // do not add duplicates for the same property
+ var duplicate = (parent.filter(function(e)
{
- duplicate = (parent.filter(function(e)
- {
- return (e.constructor === Object && '@id' in e &&
- e['@id'] === flattened['@id']);
- }).length > 0);
- }
+ return (_compareObjects(e, flattened) === 0);
+ }).length > 0);
if(!duplicate)
{
parent.push(flattened);
--- a/test-suite/tests/normalize-0012-out.jsonld Thu Jan 12 13:31:11 2012 -0500
+++ b/test-suite/tests/normalize-0012-out.jsonld Mon Jan 16 15:53:19 2012 -0500
@@ -1,1 +1,1 @@
-[{"@id":"http://example.org/test#example","http://example.org/vocab#date":[{"@value":"2011-01-25T00:00:00Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},{"@value":"2011-01-25T00:00:00Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}]}]
\ No newline at end of file
+[{"@id":"http://example.org/test#example","http://example.org/vocab#date":{"@value":"2011-01-25T00:00:00Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}}]
--- a/test-suite/tests/normalize-manifest.jsonld Thu Jan 12 13:31:11 2012 -0500
+++ b/test-suite/tests/normalize-manifest.jsonld Mon Jan 16 15:53:19 2012 -0500
@@ -61,7 +61,7 @@
"expect": "normalize-0011-out.jsonld"
}, {
"@type": ["test:TestCase", "jld:NormalizeTest"],
- "name": "type-coerced type, double reference",
+ "name": "type-coerced type, remove duplicate reference",
"input": "normalize-0012-in.jsonld",
"expect": "normalize-0012-out.jsonld"
}, {