Add test for fromRdf using with native types flag based on 0002.
authorGregg Kellogg <gregg@kellogg-assoc.com>
Sat, 31 Aug 2013 15:41:51 -0700
changeset 1953 61d8b02625bb
parent 1952 8e830a278a54
child 1954 2dc1b06f333b
Add test for fromRdf using with native types flag based on 0002.
Change results for fromRdf-0002, and -0018 to not use native types.
test-suite/tests/fromRdf-0002-out.jsonld
test-suite/tests/fromRdf-0007-out.jsonld
test-suite/tests/fromRdf-0017-out.jsonld
test-suite/tests/fromRdf-0018-in.nq
test-suite/tests/fromRdf-0018-out.jsonld
test-suite/tests/fromRdf-manifest.jsonld
test-suite/vocab.ttl
--- a/test-suite/tests/fromRdf-0002-out.jsonld	Sat Aug 31 15:26:05 2013 -0700
+++ b/test-suite/tests/fromRdf-0002-out.jsonld	Sat Aug 31 15:41:51 2013 -0700
@@ -2,11 +2,26 @@
   {
     "@id": "http://example.com/Subj1",
     "http://example.com/prop": [
-      { "@value": true },
-      { "@value": false },
-      { "@value": 1 },
-      { "@value": "1.1", "@type": "http://www.w3.org/2001/XMLSchema#decimal"},
-      { "@value": 0.11 }
+      {
+        "@value": "true",
+        "@type": "http://www.w3.org/2001/XMLSchema#boolean"
+      },
+      {
+        "@value": "false",
+        "@type": "http://www.w3.org/2001/XMLSchema#boolean"
+      },
+      {
+        "@value": "1",
+        "@type": "http://www.w3.org/2001/XMLSchema#integer"
+      },
+      {
+        "@value": "1.1",
+        "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+      },
+      {
+        "@value": "1.1E-01",
+        "@type": "http://www.w3.org/2001/XMLSchema#double"
+      }
     ]
   }
 ]
--- a/test-suite/tests/fromRdf-0007-out.jsonld	Sat Aug 31 15:26:05 2013 -0700
+++ b/test-suite/tests/fromRdf-0007-out.jsonld	Sat Aug 31 15:41:51 2013 -0700
@@ -18,7 +18,8 @@
       {
         "@id": "http://en.wikipedia.org/wiki/Berlin",
         "http://data.wikipedia.org/vocab#population": [{
-          "@value": 3499879
+          "@value": "3499879",
+          "@type": "http://www.w3.org/2001/XMLSchema#integer"
         }]
       }
     ]
--- a/test-suite/tests/fromRdf-0017-out.jsonld	Sat Aug 31 15:26:05 2013 -0700
+++ b/test-suite/tests/fromRdf-0017-out.jsonld	Sat Aug 31 15:41:51 2013 -0700
@@ -3,7 +3,10 @@
     "@id": "http://example.com/nodeA",
     "http://example.com/property": [
       { "@value": "1" },
-      { "@value": 2 },
+      {
+        "@value": "2",
+        "@type": "http://www.w3.org/2001/XMLSchema#integer"
+      },
       { "@id": "http://example.com/nodeB" }
     ],
     "@type": [ "http://example.com/TypeA" ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/fromRdf-0018-in.nq	Sat Aug 31 15:41:51 2013 -0700
@@ -0,0 +1,5 @@
+<http://example.com/Subj1> <http://example.com/prop> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
+<http://example.com/Subj1> <http://example.com/prop> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
+<http://example.com/Subj1> <http://example.com/prop> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://example.com/Subj1> <http://example.com/prop> "1.1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://example.com/Subj1> <http://example.com/prop> "1.1E-1"^^<http://www.w3.org/2001/XMLSchema#double> .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/fromRdf-0018-out.jsonld	Sat Aug 31 15:41:51 2013 -0700
@@ -0,0 +1,12 @@
+[
+  {
+    "@id": "http://example.com/Subj1",
+    "http://example.com/prop": [
+      { "@value": true },
+      { "@value": false },
+      { "@value": 1 },
+      { "@value": "1.1", "@type": "http://www.w3.org/2001/XMLSchema#decimal"},
+      { "@value": 0.11 }
+    ]
+  }
+]
--- a/test-suite/tests/fromRdf-manifest.jsonld	Sat Aug 31 15:26:05 2013 -0700
+++ b/test-suite/tests/fromRdf-manifest.jsonld	Sat Aug 31 15:41:51 2013 -0700
@@ -17,7 +17,7 @@
       "@id": "#t0002",
       "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],
       "name": "Native Types",
-      "purpose": "Use native datatypes, where possible.",
+      "purpose": "Do not use native datatypes for xsd:boolean, xsd:integer, and xsd:double by default.",
       "input": "fromRdf-0002-in.nq",
       "expect": "fromRdf-0002-out.jsonld"
     }, {
@@ -125,6 +125,16 @@
       "purpose": "Equivalent triples are used only once",
       "input": "fromRdf-0017-in.nq",
       "expect": "fromRdf-0017-out.jsonld"
+    }, {
+      "@id": "#t0018",
+      "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],
+      "name": "use native types flat",
+      "purpose": "Literals with datatype xsd:boolean, xsd:integer, and xsd:double are serialized using native scalar values",
+      "option": {
+        "useNativeTypes": true
+      },
+      "input": "fromRdf-0018-in.nq",
+      "expect": "fromRdf-0018-out.jsonld"
     }
   ]
 }
--- a/test-suite/vocab.ttl	Sat Aug 31 15:26:05 2013 -0700
+++ b/test-suite/vocab.ttl	Sat Aug 31 15:41:51 2013 -0700
@@ -236,8 +236,8 @@
 :useNativeTypes a rdfs:Property ;
   rdfs:label "use native types";
   rdfs:comment """
-    If the _use native types_ flag is set to `true`, RDF literals with a datatype IRI tha
-    equals `xsd:integer` or `xsd:double` are converted to a JSON numbers and RDF literals
+    If the _use native types_ flag is set to `true`, RDF literals with a datatype IRI that
+    equal `xsd:integer` or `xsd:double` are converted to a JSON numbers and RDF literals
     with a datatype IRI that equals `xsd:boolean` are converted to `true` or `false` based
     on their lexical form.
     """ ;