rdf-n3 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.yardopts +10 -0
- data/AUTHORS +1 -0
- data/History.txt +2 -0
- data/README.rdoc +72 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/example.rb +45 -0
- data/lib/rdf/n3.rb +30 -0
- data/lib/rdf/n3/format.rb +34 -0
- data/lib/rdf/n3/patches/array_hacks.rb +131 -0
- data/lib/rdf/n3/patches/rdf_escape.rb +131 -0
- data/lib/rdf/n3/reader.rb +447 -0
- data/lib/rdf/n3/reader/n3_grammar.rb +0 -0
- data/lib/rdf/n3/reader/n3_grammar.treetop +227 -0
- data/lib/rdf/n3/version.rb +21 -0
- data/lib/rdf/n3/vocabulary.rb +3 -0
- data/lib/rdf/n3/writer.rb +0 -0
- data/rdf-n3.gemspec +638 -0
- data/spec/cwm_spec.rb +32 -0
- data/spec/n3reader_spec.rb +928 -0
- data/spec/rdf_helper.rb +200 -0
- data/spec/rdfcore/Manifest.rdf +5395 -0
- data/spec/rdfcore/amp-in-url/test001.nt +16 -0
- data/spec/rdfcore/amp-in-url/test001.rdf +40 -0
- data/spec/rdfcore/datatypes-intensional/test001.nt +18 -0
- data/spec/rdfcore/datatypes-intensional/test002.nt +18 -0
- data/spec/rdfcore/datatypes/test001.nt +15 -0
- data/spec/rdfcore/datatypes/test001.rdf +29 -0
- data/spec/rdfcore/datatypes/test002.nt +14 -0
- data/spec/rdfcore/datatypes/test002.rdf +27 -0
- data/spec/rdfcore/datatypes/test002b.nt +17 -0
- data/spec/rdfcore/datatypes/test003a.nt +16 -0
- data/spec/rdfcore/datatypes/test003b.nt +16 -0
- data/spec/rdfcore/datatypes/test005a.nt +16 -0
- data/spec/rdfcore/datatypes/test005b.nt +16 -0
- data/spec/rdfcore/datatypes/test006.nt +17 -0
- data/spec/rdfcore/datatypes/test008a.nt +15 -0
- data/spec/rdfcore/datatypes/test008b.nt +15 -0
- data/spec/rdfcore/datatypes/test009a.nt +15 -0
- data/spec/rdfcore/datatypes/test009b.nt +15 -0
- data/spec/rdfcore/datatypes/test010.nt +17 -0
- data/spec/rdfcore/datatypes/test011a.nt +17 -0
- data/spec/rdfcore/datatypes/test011b.nt +17 -0
- data/spec/rdfcore/horst-01/test001.rdf +38 -0
- data/spec/rdfcore/horst-01/test002.rdf +39 -0
- data/spec/rdfcore/horst-01/test003.rdf +40 -0
- data/spec/rdfcore/horst-01/test004.rdf +42 -0
- data/spec/rdfcore/pfps-10/test001a.nt +14 -0
- data/spec/rdfcore/pfps-10/test001b.nt +15 -0
- data/spec/rdfcore/rdf-charmod-literals/test001.nt +15 -0
- data/spec/rdfcore/rdf-charmod-literals/test001.rdf +34 -0
- data/spec/rdfcore/rdf-charmod-uris/test001.nt +14 -0
- data/spec/rdfcore/rdf-charmod-uris/test001.rdf +34 -0
- data/spec/rdfcore/rdf-charmod-uris/test002.nt +15 -0
- data/spec/rdfcore/rdf-charmod-uris/test002.rdf +33 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/error001.rdf +27 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/error002.rdf +34 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test001.nt +17 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test001.rdf +27 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test002.nt +19 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test002.rdf +37 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test003.nt +18 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test003.rdf +29 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test004.nt +29 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test004.rdf +33 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test006.nt +40 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test006.rdf +28 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test007.nt +20 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test007.rdf +32 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test008.nt +15 -0
- data/spec/rdfcore/rdf-containers-syntax-vs-schema/test008.rdf +28 -0
- data/spec/rdfcore/rdf-element-not-mandatory/test001.nt +10 -0
- data/spec/rdfcore/rdf-element-not-mandatory/test001.rdf +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0001.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0001.rdf +35 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0003.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0003.rdf +35 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0004.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0004.rdf +34 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0005.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0005.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0006.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0006.rdf +32 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0009.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0009.rdf +32 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0010.nt +14 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0010.rdf +38 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0011.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0011.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0012.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0012.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0013.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0013.rdf +40 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0014.nt +15 -0
- data/spec/rdfcore/rdf-ns-prefix-confusion/test0014.rdf +42 -0
- data/spec/rdfcore/rdfms-abouteach/error001.rdf +35 -0
- data/spec/rdfcore/rdfms-abouteach/error002.rdf +35 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/error1.rdf +25 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test1.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test1.rdf +22 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test2.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test2.rdf +22 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test3.nt +14 -0
- data/spec/rdfcore/rdfms-difference-between-ID-and-about/test3.rdf +22 -0
- data/spec/rdfcore/rdfms-duplicate-member-props/test001.nt +17 -0
- data/spec/rdfcore/rdfms-duplicate-member-props/test001.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error001.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error002.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/error003.rdf +39 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test001.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test002.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test002.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test003.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test003.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test004.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test004.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test005.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test005.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test006.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test006.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test007.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test007.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test008.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test008.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test009.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test009.rdf +32 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test010.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test010.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test011.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test011.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test012.nt +18 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test012.rdf +30 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test013.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test013.rdf +35 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test014.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test014.rdf +34 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test015.nt +15 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test015.rdf +38 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test016.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test016.rdf +31 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test017.nt +14 -0
- data/spec/rdfcore/rdfms-empty-property-elements/test017.rdf +38 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test001.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test002.nt +15 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test002.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test003.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test003.rdf +31 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test004.nt +15 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test004.rdf +33 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test005.nt +14 -0
- data/spec/rdfcore/rdfms-identity-anon-resources/test005.rdf +31 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test001.nt +19 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test002.nt +15 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test002.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test004.nt +18 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test004.rdf +29 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test005.nt +19 -0
- data/spec/rdfcore/rdfms-not-id-and-resource-attr/test005.rdf +29 -0
- data/spec/rdfcore/rdfms-para196/test001.nt +17 -0
- data/spec/rdfcore/rdfms-para196/test001.rdf +35 -0
- data/spec/rdfcore/rdfms-rdf-id/error001.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error002.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error003.rdf +29 -0
- data/spec/rdfcore/rdfms-rdf-id/error004.rdf +27 -0
- data/spec/rdfcore/rdfms-rdf-id/error005.rdf +31 -0
- data/spec/rdfcore/rdfms-rdf-id/error006.rdf +26 -0
- data/spec/rdfcore/rdfms-rdf-id/error007.rdf +29 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-002.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-003.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-004.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-005.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-006.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-007.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-008.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-009.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-010.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-011.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-012.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-013.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-014.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-015.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-016.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-017.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-018.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-019.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/error-020.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-001.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-002.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-002.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-003.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-003.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-004.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-004.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-005.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-005.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-006.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-006.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-007.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-007.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-008.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-008.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-009.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-009.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-010.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-010.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-011.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-011.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-012.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-012.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-013.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-013.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-014.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-014.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-015.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-015.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-016.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-016.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-017.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-017.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-018.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-018.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-019.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-019.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-020.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-020.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-021.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-021.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-022.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-022.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-023.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-023.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-024.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-024.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-025.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-025.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-026.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-026.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-027.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-027.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-028.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-028.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-029.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-029.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-030.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-030.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-031.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-031.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-032.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-032.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-033.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-033.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-034.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-034.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-035.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-035.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-036.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-036.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-037.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/test-037.rdf +24 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-001.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-001.rdf +23 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-002.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-002.rdf +25 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-003.nt +1 -0
- data/spec/rdfcore/rdfms-rdf-names-use/warn-003.rdf +24 -0
- data/spec/rdfcore/rdfms-reification-required/test001.nt +15 -0
- data/spec/rdfcore/rdfms-reification-required/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-seq-representation/empty.nt +13 -0
- data/spec/rdfcore/rdfms-seq-representation/test001.nt +19 -0
- data/spec/rdfcore/rdfms-seq-representation/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-seq-representation/test002.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test003a.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test003b.nt +14 -0
- data/spec/rdfcore/rdfms-seq-representation/test004.nt +14 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error001.rdf +26 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error002.rdf +26 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error003.rdf +29 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error004.rdf +25 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error005.rdf +25 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/error006.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test001.nt +14 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test001.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test002.nt +19 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test002.rdf +38 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test003.nt +17 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test003.rdf +28 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test004.nt +21 -0
- data/spec/rdfcore/rdfms-syntax-incomplete/test004.rdf +36 -0
- data/spec/rdfcore/rdfms-uri-substructure/error001.nt +18 -0
- data/spec/rdfcore/rdfms-uri-substructure/test001.nt +17 -0
- data/spec/rdfcore/rdfms-uri-substructure/test001.rdf +29 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test001.nt +13 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test001.rdf +33 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test002.nt +14 -0
- data/spec/rdfcore/rdfms-xml-literal-namespaces/test002.rdf +47 -0
- data/spec/rdfcore/rdfms-xmllang/test001.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test001.rdf +30 -0
- data/spec/rdfcore/rdfms-xmllang/test002.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test002.rdf +29 -0
- data/spec/rdfcore/rdfms-xmllang/test003.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test003.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test004.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test004.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test005.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test005.rdf +28 -0
- data/spec/rdfcore/rdfms-xmllang/test006.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test006.rdf +29 -0
- data/spec/rdfcore/rdfms-xmllang/test007a.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test007b.nt +14 -0
- data/spec/rdfcore/rdfms-xmllang/test007c.nt +14 -0
- data/spec/rdfcore/rdfs-container-membership-superProperty/not1C.rdf +13 -0
- data/spec/rdfcore/rdfs-container-membership-superProperty/not1P.rdf +14 -0
- data/spec/rdfcore/rdfs-domain-and-range/nonconclusions005.rdf +28 -0
- data/spec/rdfcore/rdfs-domain-and-range/nonconclusions006.rdf +28 -0
- data/spec/rdfcore/rdfs-domain-and-range/premises005.rdf +32 -0
- data/spec/rdfcore/rdfs-domain-and-range/premises006.rdf +32 -0
- data/spec/rdfcore/rdfs-domain-and-range/test001.nt +16 -0
- data/spec/rdfcore/rdfs-domain-and-range/test001.rdf +29 -0
- data/spec/rdfcore/rdfs-domain-and-range/test002.nt +16 -0
- data/spec/rdfcore/rdfs-domain-and-range/test002.rdf +29 -0
- data/spec/rdfcore/rdfs-entailment/test001.nt +16 -0
- data/spec/rdfcore/rdfs-entailment/test002.nt +15 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subClassOf/test001.nt +18 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subClassOf/test001.rdf +37 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subPropertyOf/test001.nt +18 -0
- data/spec/rdfcore/rdfs-no-cycles-in-subPropertyOf/test001.rdf +40 -0
- data/spec/rdfcore/rdfs-subClassOf-a-Property/test001.nt +15 -0
- data/spec/rdfcore/rdfs-subPropertyOf-semantics/test001.nt +24 -0
- data/spec/rdfcore/rdfs-subPropertyOf-semantics/test002.nt +21 -0
- data/spec/rdfcore/statement-entailment/test001a.nt +12 -0
- data/spec/rdfcore/statement-entailment/test001b.nt +2 -0
- data/spec/rdfcore/statement-entailment/test002a.nt +2 -0
- data/spec/rdfcore/statement-entailment/test002b.nt +5 -0
- data/spec/rdfcore/tex-01/test001.rdf +34 -0
- data/spec/rdfcore/tex-01/test002.rdf +33 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test001.nt +15 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test001.rdf +31 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test002.nt +14 -0
- data/spec/rdfcore/unrecognised-xml-attributes/test002.rdf +32 -0
- data/spec/rdfcore/xml-canon/test001.nt +16 -0
- data/spec/rdfcore/xml-canon/test001.rdf +28 -0
- data/spec/rdfcore/xmlbase/test001.nt +14 -0
- data/spec/rdfcore/xmlbase/test001.rdf +27 -0
- data/spec/rdfcore/xmlbase/test002.nt +14 -0
- data/spec/rdfcore/xmlbase/test002.rdf +28 -0
- data/spec/rdfcore/xmlbase/test003.nt +14 -0
- data/spec/rdfcore/xmlbase/test003.rdf +25 -0
- data/spec/rdfcore/xmlbase/test004.nt +18 -0
- data/spec/rdfcore/xmlbase/test004.rdf +27 -0
- data/spec/rdfcore/xmlbase/test006.nt +15 -0
- data/spec/rdfcore/xmlbase/test006.rdf +26 -0
- data/spec/rdfcore/xmlbase/test007.nt +14 -0
- data/spec/rdfcore/xmlbase/test007.rdf +25 -0
- data/spec/rdfcore/xmlbase/test008.nt +14 -0
- data/spec/rdfcore/xmlbase/test008.rdf +25 -0
- data/spec/rdfcore/xmlbase/test009.nt +14 -0
- data/spec/rdfcore/xmlbase/test009.rdf +26 -0
- data/spec/rdfcore/xmlbase/test010.nt +14 -0
- data/spec/rdfcore/xmlbase/test010.rdf +26 -0
- data/spec/rdfcore/xmlbase/test011.nt +14 -0
- data/spec/rdfcore/xmlbase/test011.rdf +27 -0
- data/spec/rdfcore/xmlbase/test013.nt +15 -0
- data/spec/rdfcore/xmlbase/test013.rdf +28 -0
- data/spec/rdfcore/xmlbase/test014.nt +15 -0
- data/spec/rdfcore/xmlbase/test014.rdf +28 -0
- data/spec/rdfcore/xmlsch-02/test001.rdf +34 -0
- data/spec/rdfcore/xmlsch-02/test002.rdf +34 -0
- data/spec/rdfcore/xmlsch-02/test003.rdf +37 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/swap_helper.rb +136 -0
- data/spec/swap_spec.rb +77 -0
- data/spec/swap_test/.DS_Store +0 -0
- data/spec/swap_test/animal.rdf +17 -0
- data/spec/swap_test/anon-prop.n3 +14 -0
- data/spec/swap_test/anonymous_loop.n3 +2 -0
- data/spec/swap_test/contexts.n3 +16 -0
- data/spec/swap_test/daml-pref.n3 +10 -0
- data/spec/swap_test/i18n/hiragana.n3 +22 -0
- data/spec/swap_test/i18n/n3string.n3 +4 -0
- data/spec/swap_test/list/itemType.rdf +12 -0
- data/spec/swap_test/lists-simple.n3 +40 -0
- data/spec/swap_test/lists.n3 +35 -0
- data/spec/swap_test/n3/.DS_Store +0 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10001.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10002.nt +7 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10003.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10004.nt +119 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10005.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10006.nt +225 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10007.nt +79 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10008.nt +5 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10009.nt +13 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10010.nt +21 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10011.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10012.nt +53 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10013.nt +19 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10014.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10015.nt +103 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10016.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10017.nt +151 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10018.nt +9 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10019.nt +3 -0
- data/spec/swap_test/n3/n3parser.tests_n3_10020.nt +13 -0
- data/spec/swap_test/n3parser.tests +160 -0
- data/spec/swap_test/nodeID/classes.n3 +9 -0
- data/spec/swap_test/nodeID/classes.ref.rdf +15 -0
- data/spec/swap_test/nodeID/ex1.rdf +15 -0
- data/spec/swap_test/norm/fix.rdf +33 -0
- data/spec/swap_test/owl-ex.rdf +150 -0
- data/spec/swap_test/ref/animal.n3 +11 -0
- data/spec/swap_test/ref/anon-prop-1.n3 +8 -0
- data/spec/swap_test/ref/anonymous_loop.ref +7 -0
- data/spec/swap_test/ref/bnode.n3 +6 -0
- data/spec/swap_test/ref/bnode.rdf +16 -0
- data/spec/swap_test/ref/colon-in-uri.n3 +15 -0
- data/spec/swap_test/ref/daml-ex.n3 +103 -0
- data/spec/swap_test/ref/daml-ont.n3 +289 -0
- data/spec/swap_test/ref/djb1a-out.n3 +4 -0
- data/spec/swap_test/ref/dot-dash.n3 +8 -0
- data/spec/swap_test/ref/in-xml-t.n3 +4 -0
- data/spec/swap_test/ref/itemType.n3 +9 -0
- data/spec/swap_test/ref/keywords1.n3 +11 -0
- data/spec/swap_test/ref/keywords2.n3 +11 -0
- data/spec/swap_test/ref/lists-simple-1.rdf +108 -0
- data/spec/swap_test/ref/lists.n3 +43 -0
- data/spec/swap_test/ref/lstring-out.n3 +20 -0
- data/spec/swap_test/ref/n3string.n3 +13 -0
- data/spec/swap_test/ref/no-last-nl.n3 +3 -0
- data/spec/swap_test/ref/numbers.n3 +18 -0
- data/spec/swap_test/ref/path1.n3 +8 -0
- data/spec/swap_test/ref/path2.n3 +39 -0
- data/spec/swap_test/ref/prefix1.rdf +31 -0
- data/spec/swap_test/ref/prefix3.rdf +31 -0
- data/spec/swap_test/ref/rdf-redefine.rdf +11 -0
- data/spec/swap_test/ref/reluri-1.rdf +18 -0
- data/spec/swap_test/ref/strquot.n3 +23 -0
- data/spec/swap_test/ref/strquot_a.n3 +23 -0
- data/spec/swap_test/ref/xml-base3.n3 +5 -0
- data/spec/swap_test/ref/xml-redefine.rdf +20 -0
- data/spec/swap_test/ref/xml-redefine2.rdf +23 -0
- data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +10 -0
- data/spec/swap_test/ref/xmllit.nt +3 -0
- data/spec/swap_test/regression.n3 +231 -0
- data/spec/swap_test/reluri-1.n3 +10 -0
- data/spec/swap_test/strquot.n3 +23 -0
- data/spec/swap_test/syntax/colon-in-uri.rdf +27 -0
- data/spec/swap_test/syntax/djb1a.n3 +3 -0
- data/spec/swap_test/syntax/dot-dash.n3 +15 -0
- data/spec/swap_test/syntax/equals1.n3 +1 -0
- data/spec/swap_test/syntax/equals2.n3 +1 -0
- data/spec/swap_test/syntax/keywords1.n3 +17 -0
- data/spec/swap_test/syntax/keywords2.n3 +18 -0
- data/spec/swap_test/syntax/lstring.n3 +26 -0
- data/spec/swap_test/syntax/neg-formula-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-keywords3.n3 +1 -0
- data/spec/swap_test/syntax/neg-literal-predicate.n3 +1 -0
- data/spec/swap_test/syntax/neg-single-quote.n3 +1 -0
- data/spec/swap_test/syntax/neg-thisadoc.n3 +1 -0
- data/spec/swap_test/syntax/no-last-nl.n3 +2 -0
- data/spec/swap_test/syntax/numbers.n3 +26 -0
- data/spec/swap_test/syntax/path1.n3 +23 -0
- data/spec/swap_test/syntax/path2.n3 +31 -0
- data/spec/swap_test/syntax/qvars1.n3 +19 -0
- data/spec/swap_test/syntax/qvars2.n3 +19 -0
- data/spec/swap_test/syntax/this-quantifiers.n3 +164 -0
- data/spec/swap_test/syntax/this-rules.n3 +43 -0
- data/spec/swap_test/syntax/too-nested.n3 +25 -0
- data/spec/swap_test/syntax/trailing-semicolon.n3 +12 -0
- data/spec/swap_test/syntax/zero-objects.n3 +1 -0
- data/spec/swap_test/syntax/zero-predicates.n3 +3 -0
- data/spec/swap_test/tests-work.txt +25 -0
- data/spec/swap_test/xml-syntax/basic-serialization.n3 +8 -0
- data/spec/swap_test/xml-syntax/in-xml.xml +13 -0
- data/spec/swap_test/xml-syntax/non-ascii-pred.rdf +14 -0
- data/spec/swap_test/xml-syntax/rdf_prefix.n3 +2 -0
- data/spec/swap_test/xml-syntax/xml_prefix.n3 +7 -0
- data/spec/swap_test/xml-syntax/xml_prefix2.n3 +9 -0
- data/spec/swap_test/xml-syntax/xmlbase3.rdf +10 -0
- data/spec/swap_test/xml-syntax/xmllit.rdf +33 -0
- data/spec/triple_spec.rb +236 -0
- data/spec/turtle/README.txt +20 -0
- data/spec/turtle/bad-00.ttl +2 -0
- data/spec/turtle/bad-01.ttl +3 -0
- data/spec/turtle/bad-02.ttl +3 -0
- data/spec/turtle/bad-03.ttl +3 -0
- data/spec/turtle/bad-04.ttl +3 -0
- data/spec/turtle/bad-05.ttl +4 -0
- data/spec/turtle/bad-06.ttl +3 -0
- data/spec/turtle/bad-07.ttl +4 -0
- data/spec/turtle/bad-08.ttl +2 -0
- data/spec/turtle/bad-09.ttl +3 -0
- data/spec/turtle/bad-10.ttl +3 -0
- data/spec/turtle/bad-11.ttl +3 -0
- data/spec/turtle/bad-12.ttl +3 -0
- data/spec/turtle/bad-13.ttl +3 -0
- data/spec/turtle/bad-14.ttl +6 -0
- data/spec/turtle/manifest-bad.ttl +88 -0
- data/spec/turtle/manifest.ttl +215 -0
- data/spec/turtle/rdf-schema.out +126 -0
- data/spec/turtle/rdf-schema.ttl +156 -0
- data/spec/turtle/rdfq-results.out +36 -0
- data/spec/turtle/rdfq-results.ttl +39 -0
- data/spec/turtle/rdfs-namespace.out +131 -0
- data/spec/turtle/rdfs-namespace.ttl +160 -0
- data/spec/turtle/test-00.out +1 -0
- data/spec/turtle/test-00.ttl +2 -0
- data/spec/turtle/test-01.out +3 -0
- data/spec/turtle/test-01.ttl +7 -0
- data/spec/turtle/test-02.out +3 -0
- data/spec/turtle/test-02.ttl +5 -0
- data/spec/turtle/test-03.out +3 -0
- data/spec/turtle/test-03.ttl +5 -0
- data/spec/turtle/test-04.out +2 -0
- data/spec/turtle/test-04.ttl +4 -0
- data/spec/turtle/test-05.out +4 -0
- data/spec/turtle/test-05.ttl +4 -0
- data/spec/turtle/test-06.out +1 -0
- data/spec/turtle/test-06.ttl +3 -0
- data/spec/turtle/test-07.out +5 -0
- data/spec/turtle/test-07.ttl +3 -0
- data/spec/turtle/test-08.out +1 -0
- data/spec/turtle/test-08.ttl +3 -0
- data/spec/turtle/test-09.out +4 -0
- data/spec/turtle/test-09.ttl +10 -0
- data/spec/turtle/test-10.out +5 -0
- data/spec/turtle/test-10.ttl +5 -0
- data/spec/turtle/test-11.out +4 -0
- data/spec/turtle/test-11.ttl +10 -0
- data/spec/turtle/test-12.out +4 -0
- data/spec/turtle/test-12.ttl +9 -0
- data/spec/turtle/test-13.out +2 -0
- data/spec/turtle/test-13.ttl +7 -0
- data/spec/turtle/test-14.out +10000 -0
- data/spec/turtle/test-14.ttl +10002 -0
- data/spec/turtle/test-15.out +10000 -0
- data/spec/turtle/test-15.ttl +3 -0
- data/spec/turtle/test-16.out +10000 -0
- data/spec/turtle/test-16.ttl +10002 -0
- data/spec/turtle/test-17.out +1 -0
- data/spec/turtle/test-17.ttl +6 -0
- data/spec/turtle/test-18.out +2 -0
- data/spec/turtle/test-18.ttl +9 -0
- data/spec/turtle/test-19.out +1 -0
- data/spec/turtle/test-19.ttl +4 -0
- data/spec/turtle/test-20.out +2 -0
- data/spec/turtle/test-20.ttl +6 -0
- data/spec/turtle/test-21.out +3 -0
- data/spec/turtle/test-21.ttl +4 -0
- data/spec/turtle/test-22.out +3 -0
- data/spec/turtle/test-22.ttl +4 -0
- data/spec/turtle/test-23.out +1 -0
- data/spec/turtle/test-23.ttl +3 -0
- data/spec/turtle/test-24.out +2 -0
- data/spec/turtle/test-24.ttl +3 -0
- data/spec/turtle/test-25.out +7 -0
- data/spec/turtle/test-25.ttl +14 -0
- data/spec/turtle/test-26.out +1 -0
- data/spec/turtle/test-26.ttl +4 -0
- data/spec/turtle/test-27.out +1 -0
- data/spec/turtle/test-27.ttl +5 -0
- data/spec/turtle/test-28-out.ttl +6 -0
- data/spec/turtle/test-28.out +22 -0
- data/spec/turtle/test-28.ttl +22 -0
- data/spec/turtle/test-29.out +1 -0
- data/spec/turtle/test-29.ttl +1 -0
- data/spec/turtle/test-30.out +5 -0
- data/spec/turtle/test-30.ttl +12 -0
- data/spec/turtle_serializer_spec.rb +226 -0
- data/spec/turtle_spec.rb +64 -0
- metadata +711 -0
data/spec/cwm_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
include RdfContext
|
3
|
+
|
4
|
+
describe "RDF::N3::Reader" do
|
5
|
+
describe "w3c cwm tests" do
|
6
|
+
require 'rdf_helper'
|
7
|
+
|
8
|
+
def self.test_cases
|
9
|
+
RdfHelper::TestCase.test_cases(CWM_TEST, SWAP_DIR) rescue []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Negative parser tests should raise errors.
|
13
|
+
test_cases.each do |t|
|
14
|
+
#next unless t.about.uri.to_s =~ /rdfms-rdf-names-use/
|
15
|
+
#next unless t.name =~ /11/
|
16
|
+
#puts t.inspect
|
17
|
+
specify "test #{t.name}: " + (t.description || "#{t.inputDocument} against #{t.outputDocument}") do
|
18
|
+
begin
|
19
|
+
t.run_test do |rdf_string, parser|
|
20
|
+
parser.parse(rdf_string, t.about.uri.to_s, :strict => true, :debug => [])
|
21
|
+
end
|
22
|
+
rescue #Spec::Expectations::ExpectationNotMetError => e
|
23
|
+
if t.status == "pending"
|
24
|
+
pending("Formulae not supported") { raise }
|
25
|
+
else
|
26
|
+
raise
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,928 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
+
include RdfContext
|
4
|
+
|
5
|
+
describe "RDF::N3::Reader" do
|
6
|
+
before(:each) { @parser = N3Parser.new(:strict => true) }
|
7
|
+
|
8
|
+
describe "with simple ntriples" do
|
9
|
+
it "should parse simple triple" do
|
10
|
+
n3_string = %(<http://example.org/> <http://xmlns.com/foaf/0.1/name> "Tom Morris" .)
|
11
|
+
@parser.parse(n3_string)
|
12
|
+
@parser.graph[0].subject.to_s.should == "http://example.org/"
|
13
|
+
@parser.graph[0].predicate.to_s.should == "http://xmlns.com/foaf/0.1/name"
|
14
|
+
@parser.graph[0].object.to_s.should == "Tom Morris"
|
15
|
+
@parser.graph.size.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should parse simple triple from class method" do
|
19
|
+
n3_string = "<http://example.org/> <http://xmlns.com/foaf/0.1/name> \"Tom Morris\" . "
|
20
|
+
graph = N3Parser.new(:strict => true).parse(n3_string)
|
21
|
+
graph[0].subject.to_s.should == "http://example.org/"
|
22
|
+
graph[0].predicate.to_s.should == "http://xmlns.com/foaf/0.1/name"
|
23
|
+
graph[0].object.to_s.should == "Tom Morris"
|
24
|
+
graph.size.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
# NTriple tests from http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt
|
28
|
+
describe "with blank lines" do
|
29
|
+
{
|
30
|
+
"comment" => "# comment lines",
|
31
|
+
"comment after whitespace" => " # comment after whitespace",
|
32
|
+
"empty line" => "",
|
33
|
+
"line with spaces" => " "
|
34
|
+
}.each_pair do |name, statement|
|
35
|
+
specify "test #{name}" do
|
36
|
+
@parser.parse(statement)
|
37
|
+
@parser.graph.size.should == 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "with literal encodings" do
|
43
|
+
{
|
44
|
+
'Dürst' => ':a :b "D\u00FCrst" .',
|
45
|
+
'simple literal' => ':a :b "simple literal" .',
|
46
|
+
'backslash:\\' => ':a :b "backslash:\\\\" .',
|
47
|
+
'dquote:"' => ':a :b "dquote:\"" .',
|
48
|
+
"newline:\n" => ':a :b "newline:\n" .',
|
49
|
+
"return\r" => ':a :b "return\r" .',
|
50
|
+
"tab:\t" => ':a :b "tab:\t" .',
|
51
|
+
"é" => ':a :b "\u00E9" .',
|
52
|
+
"€" => ':a :b "\u20AC" .',
|
53
|
+
}.each_pair do |contents, triple|
|
54
|
+
specify "test #{contents}" do
|
55
|
+
@parser.parse(triple, "http://a/b")
|
56
|
+
@parser.graph.should_not be_nil
|
57
|
+
@parser.graph.size.should == 1
|
58
|
+
@parser.graph[0].object.contents.should == contents
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should parse long literal with escape" do
|
63
|
+
n3 = %(@prefix : <http://example.org/foo#> . :a :b "\\U00015678another" .)
|
64
|
+
if defined?(::Encoding)
|
65
|
+
@parser.parse(n3)
|
66
|
+
@parser.graph[0].object.contents.should == "\u{15678}another"
|
67
|
+
else
|
68
|
+
lambda { @parser.parse(n3) }.should raise_error(RdfException, "Long Unicode escapes no supported in Ruby 1.8")
|
69
|
+
pending("Not supported in Ruby 1.8")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should parse multi-line literal" do
|
74
|
+
@parser.parse(%(
|
75
|
+
<http://www.example.com/books#book12345> <http://purl.org/dc/terms/title> """
|
76
|
+
Foo
|
77
|
+
<html:b xmlns:html="http://www.w3.org/1999/xhtml" html:a="b">bar<rdf:Thing xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><a:b xmlns:a="foo:"></a:b>here<a:c xmlns:a="foo:"></a:c></rd
|
78
|
+
f:Thing></html:b>
|
79
|
+
baz
|
80
|
+
<html:i xmlns:html="http://www.w3.org/1999/xhtml">more</html:i>
|
81
|
+
""" .
|
82
|
+
))
|
83
|
+
|
84
|
+
@parser.graph.should_not be_nil
|
85
|
+
@parser.graph.size.should == 1
|
86
|
+
@parser.graph[0].object.contents.should == %(
|
87
|
+
Foo
|
88
|
+
<html:b xmlns:html="http://www.w3.org/1999/xhtml" html:a="b">bar<rdf:Thing xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><a:b xmlns:a="foo:"></a:b>here<a:c xmlns:a="foo:"></a:c></rd
|
89
|
+
f:Thing></html:b>
|
90
|
+
baz
|
91
|
+
<html:i xmlns:html="http://www.w3.org/1999/xhtml">more</html:i>
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should parse long literal ending in double quote" do
|
96
|
+
@parser.parse(%(:a :b """ \\"""" .), "http://a/b")
|
97
|
+
@parser.graph.size.should == 1
|
98
|
+
@parser.graph[0].object.contents.should == ' "'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should create named subject bnode" do
|
103
|
+
@parser.parse("_:anon <http://example.org/property> <http://example.org/resource2> .")
|
104
|
+
@parser.graph.should_not be_nil
|
105
|
+
@parser.graph.size.should == 1
|
106
|
+
triple = @parser.graph[0]
|
107
|
+
triple.subject.should be_a(BNode)
|
108
|
+
triple.subject.identifier.should =~ /anon/
|
109
|
+
triple.predicate.should == "http://example.org/property"
|
110
|
+
triple.object.should == "http://example.org/resource2"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should create named predicate bnode" do
|
114
|
+
@parser.parse("<http://example.org/resource2> _:anon <http://example.org/object> .")
|
115
|
+
@parser.graph.should_not be_nil
|
116
|
+
@parser.graph.size.should == 1
|
117
|
+
triple = @parser.graph[0]
|
118
|
+
triple.subject.should == "http://example.org/resource2"
|
119
|
+
triple.predicate.should be_a(BNode)
|
120
|
+
triple.predicate.identifier.should =~ /anon/
|
121
|
+
triple.object.should == "http://example.org/object"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should create named object bnode" do
|
125
|
+
@parser.parse("<http://example.org/resource2> <http://example.org/property> _:anon .")
|
126
|
+
@parser.graph.should_not be_nil
|
127
|
+
@parser.graph.size.should == 1
|
128
|
+
triple = @parser.graph[0]
|
129
|
+
triple.subject.should == "http://example.org/resource2"
|
130
|
+
triple.predicate.should == "http://example.org/property"
|
131
|
+
triple.object.should be_a(BNode)
|
132
|
+
triple.object.identifier.should =~ /anon/
|
133
|
+
end
|
134
|
+
|
135
|
+
{
|
136
|
+
"three uris" => "<http://example.org/resource1> <http://example.org/property> <http://example.org/resource2> .",
|
137
|
+
"spaces and tabs throughout" => " <http://example.org/resource3> <http://example.org/property> <http://example.org/resource2> . ",
|
138
|
+
"line ending with CR NL" => "<http://example.org/resource4> <http://example.org/property> <http://example.org/resource2> .\r\n",
|
139
|
+
"literal escapes (1)" => '<http://example.org/resource7> <http://example.org/property> "simple literal" .',
|
140
|
+
"literal escapes (2)" => '<http://example.org/resource8> <http://example.org/property> "backslash:\\\\" .',
|
141
|
+
"literal escapes (3)" => '<http://example.org/resource9> <http://example.org/property> "dquote:\"" .',
|
142
|
+
"literal escapes (4)" => '<http://example.org/resource10> <http://example.org/property> "newline:\n" .',
|
143
|
+
"literal escapes (5)" => '<http://example.org/resource11> <http://example.org/property> "return:\r" .',
|
144
|
+
"literal escapes (6)" => '<http://example.org/resource12> <http://example.org/property> "tab:\t" .',
|
145
|
+
"Space is optional before final . (1)" => ['<http://example.org/resource13> <http://example.org/property> <http://example.org/resource2>.', '<http://example.org/resource13> <http://example.org/property> <http://example.org/resource2> .'],
|
146
|
+
"Space is optional before final . (2)" => ['<http://example.org/resource14> <http://example.org/property> "x".', '<http://example.org/resource14> <http://example.org/property> "x" .'],
|
147
|
+
|
148
|
+
"XML Literals as Datatyped Literals (1)" => '<http://example.org/resource21> <http://example.org/property> ""^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
149
|
+
"XML Literals as Datatyped Literals (2)" => '<http://example.org/resource22> <http://example.org/property> " "^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
150
|
+
"XML Literals as Datatyped Literals (3)" => '<http://example.org/resource23> <http://example.org/property> "x"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
151
|
+
"XML Literals as Datatyped Literals (4)" => '<http://example.org/resource23> <http://example.org/property> "\""^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
152
|
+
"XML Literals as Datatyped Literals (5)" => '<http://example.org/resource24> <http://example.org/property> "<a></a>"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
153
|
+
"XML Literals as Datatyped Literals (6)" => '<http://example.org/resource25> <http://example.org/property> "a <b></b>"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
154
|
+
"XML Literals as Datatyped Literals (7)" => '<http://example.org/resource26> <http://example.org/property> "a <b></b> c"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
155
|
+
"XML Literals as Datatyped Literals (8)" => '<http://example.org/resource26> <http://example.org/property> "a\n<b></b>\nc"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
156
|
+
"XML Literals as Datatyped Literals (9)" => '<http://example.org/resource27> <http://example.org/property> "chat"^^<http://www.w3.org/2000/01/rdf-schema#XMLLiteral> .',
|
157
|
+
|
158
|
+
"Plain literals with languages (1)" => '<http://example.org/resource30> <http://example.org/property> "chat"@fr .',
|
159
|
+
"Plain literals with languages (2)" => '<http://example.org/resource31> <http://example.org/property> "chat"@en .',
|
160
|
+
|
161
|
+
"Typed Literals" => '<http://example.org/resource32> <http://example.org/property> "abc"^^<http://example.org/datatype1> .',
|
162
|
+
}.each_pair do |name, statement|
|
163
|
+
specify "test #{name}" do
|
164
|
+
@parser.parse([statement].flatten.first)
|
165
|
+
@parser.graph.should_not be_nil
|
166
|
+
@parser.graph.size.should == 1
|
167
|
+
#puts @parser.graph[0].to_ntriples
|
168
|
+
@parser.graph[0].to_ntriples.should == [statement].flatten.last.gsub(/\s+/, " ").strip
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should create typed literals" do
|
173
|
+
n3doc = "<http://example.org/joe> <http://xmlns.com/foaf/0.1/name> \"Joe\"^^<http://www.w3.org/2001/XMLSchema#string> ."
|
174
|
+
@parser.parse(n3doc)
|
175
|
+
@parser.graph[0].object.class.should == RdfContext::Literal
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should create BNodes" do
|
179
|
+
n3doc = "_:a a _:c ."
|
180
|
+
@parser.parse(n3doc)
|
181
|
+
@parser.graph[0].subject.class.should == RdfContext::BNode
|
182
|
+
@parser.graph[0].object.class.should == RdfContext::BNode
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "should create URIRefs" do
|
186
|
+
{
|
187
|
+
%(<http://example.org/joe> <http://xmlns.com/foaf/0.1/knows> <http://example.org/jane> .) => %(<http://example.org/joe> <http://xmlns.com/foaf/0.1/knows> <http://example.org/jane> .),
|
188
|
+
%(<joe> <knows> <jane> .) => %(<http://a/joe> <http://a/knows> <http://a/jane> .),
|
189
|
+
%(:joe :knows :jane .) => %(<http://a/b#joe> <http://a/b#knows> <http://a/b#jane> .),
|
190
|
+
%(<#D%C3%BCrst> a "URI percent ^encoded as C3, BC".) => %(<http://a/b#D%C3%BCrst> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "URI percent ^encoded as C3, BC" .),
|
191
|
+
}.each_pair do |n3, nt|
|
192
|
+
it "for '#{n3}'" do
|
193
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
{
|
198
|
+
%(<#Dürst> a "URI straight in UTF8".) => %(<http://a/b#D\\u00FCrst> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "URI straight in UTF8" .),
|
199
|
+
%(:a :related :\u3072\u3089\u304C\u306A.) => %(<http://a/b#a> <http://a/b#related> <http://a/b#\\u3072\\u3089\\u304C\\u306A> .),
|
200
|
+
}.each_pair do |n3, nt|
|
201
|
+
it "for '#{n3}'" do
|
202
|
+
begin
|
203
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
204
|
+
rescue
|
205
|
+
if defined?(::Encoding)
|
206
|
+
raise
|
207
|
+
else
|
208
|
+
pending("Unicode URIs not supported in Ruby 1.8") { raise }
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should create URIRefs" do
|
216
|
+
n3doc = "<http://example.org/joe> <http://xmlns.com/foaf/0.1/knows> <http://example.org/jane> ."
|
217
|
+
@parser.parse(n3doc)
|
218
|
+
@parser.graph[0].subject.class.should == RdfContext::URIRef
|
219
|
+
@parser.graph[0].object.class.should == RdfContext::URIRef
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should create literals" do
|
223
|
+
n3doc = "<http://example.org/joe> <http://xmlns.com/foaf/0.1/name> \"Joe\"."
|
224
|
+
@parser.parse(n3doc)
|
225
|
+
@parser.graph[0].object.class.should == RdfContext::Literal
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe "with illegal syntax" do
|
230
|
+
{
|
231
|
+
%(:y :p1 "xyz"^^xsd:integer .) => %r(Typed literal has an invalid lexical value: .* "xyz"),
|
232
|
+
%(:y :p1 "12xyz"^^xsd:integer .) => %r(Typed literal has an invalid lexical value: .* "12xyz"),
|
233
|
+
%(:y :p1 "xy.z"^^xsd:double .) => %r(Typed literal has an invalid lexical value: .* "xy\.z"),
|
234
|
+
%(:y :p1 "+1.0z"^^xsd:double .) => %r(Typed literal has an invalid lexical value: .* "\+1.0z"),
|
235
|
+
%(:a :b .) => %r(Illegal statment: ".*" missing object),
|
236
|
+
%(:a :b 'single quote' .) => RdfException,
|
237
|
+
%(:a "literal value" :b .) => InvalidPredicate,
|
238
|
+
%(@keywords prefix. :e prefix :f .) => %r(Keyword ".*" used as expression)
|
239
|
+
}.each_pair do |n3, error|
|
240
|
+
it "should raise error for '#{n3}'" do
|
241
|
+
lambda {
|
242
|
+
@parser.parse("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{n3}", "http://a/b")
|
243
|
+
}.should raise_error(error)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "with n3 grammer" do
|
249
|
+
describe "syntactic expressions" do
|
250
|
+
it "should create typed literals with qname" do
|
251
|
+
n3doc = %(
|
252
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
253
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/>
|
254
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
|
255
|
+
<http://example.org/joe> foaf:name \"Joe\"^^xsd:string .
|
256
|
+
)
|
257
|
+
@parser.parse(n3doc)
|
258
|
+
@parser.graph[0].object.class.should == RdfContext::Literal
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should map <> to document uri" do
|
262
|
+
n3doc = "@prefix : <> ."
|
263
|
+
@parser.parse(n3doc, "http://the.document.itself")
|
264
|
+
@parser.graph.nsbinding.should == {"" => Namespace.new("http://the.document.itself#", "")}
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should use <> as a prefix and as a triple node" do
|
268
|
+
n3 = %(@prefix : <> . <> a :a.)
|
269
|
+
nt = %(
|
270
|
+
<http://a/b> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://a/b#a> .
|
271
|
+
)
|
272
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should use <#> as a prefix and as a triple node" do
|
276
|
+
n3 = %(@prefix : <#> . <#> a :a.)
|
277
|
+
nt = %(
|
278
|
+
<http://a/b#> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://a/b#a> .
|
279
|
+
)
|
280
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should generate rdf:type for 'a'" do
|
284
|
+
n3 = %(@prefix a: <http://foo/a#> . a:b a <http://www.w3.org/2000/01/rdf-schema#resource> .)
|
285
|
+
nt = %(<http://foo/a#b> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#resource> .)
|
286
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should generate rdf:type for '@a'" do
|
290
|
+
n3 = %(@prefix a: <http://foo/a#> . a:b @a <http://www.w3.org/2000/01/rdf-schema#resource> .)
|
291
|
+
nt = %(<http://foo/a#b> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#resource> .)
|
292
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should generate inverse predicate for 'is xxx of'" do
|
296
|
+
n3 = %("value" is :prop of :b . :b :prop "value" .)
|
297
|
+
nt = %(<http://a/b#b> <http://a/b#prop> "value" .)
|
298
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
299
|
+
end
|
300
|
+
|
301
|
+
it "should generate inverse predicate for '@is xxx @of'" do
|
302
|
+
n3 = %("value" @is :prop @of :b . :b :prop "value" .)
|
303
|
+
nt = %(<http://a/b#b> <http://a/b#prop> "value" .)
|
304
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should generate inverse predicate for 'is xxx of' with object list" do
|
308
|
+
n3 = %("value" is :prop of :b, :c . )
|
309
|
+
nt = %(
|
310
|
+
<http://a/b#b> <http://a/b#prop> "value" .
|
311
|
+
<http://a/b#c> <http://a/b#prop> "value" .
|
312
|
+
)
|
313
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
314
|
+
end
|
315
|
+
|
316
|
+
it "should generate predicate for 'has xxx'" do
|
317
|
+
n3 = %(@prefix a: <http://foo/a#> . a:b has :pred a:c .)
|
318
|
+
nt = %(<http://foo/a#b> <http://a/b#pred> <http://foo/a#c> .)
|
319
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should generate predicate for '@has xxx'" do
|
323
|
+
n3 = %(@prefix a: <http://foo/a#> . a:b @has :pred a:c .)
|
324
|
+
nt = %(<http://foo/a#b> <http://a/b#pred> <http://foo/a#c> .)
|
325
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should create log:implies predicate for '=>'" do
|
329
|
+
n3 = %(@prefix a: <http://foo/a#> . _:a => a:something .)
|
330
|
+
nt = %(_:a <http://www.w3.org/2000/10/swap/log#implies> <http://foo/a#something> .)
|
331
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should create log:implies inverse predicate for '<='" do
|
335
|
+
n3 = %(@prefix a: <http://foo/a#> . _:a <= a:something .)
|
336
|
+
nt = %(<http://foo/a#something> <http://www.w3.org/2000/10/swap/log#implies> _:a .)
|
337
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "should create owl:sameAs predicate for '='" do
|
341
|
+
n3 = %(@prefix a: <http://foo/a#> . _:a = a:something .)
|
342
|
+
nt = %(_:a <http://www.w3.org/2002/07/owl#sameAs> <http://foo/a#something> .)
|
343
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
344
|
+
end
|
345
|
+
|
346
|
+
{
|
347
|
+
%(:a :b @true) => %(<http://a/b#a> <http://a/b#b> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .),
|
348
|
+
%(:a :b @false) => %(<http://a/b#a> <http://a/b#b> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .),
|
349
|
+
%(:a :b 1) => %(<http://a/b#a> <http://a/b#b> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .),
|
350
|
+
%(:a :b -1) => %(<http://a/b#a> <http://a/b#b> "-1"^^<http://www.w3.org/2001/XMLSchema#integer> .),
|
351
|
+
%(:a :b +1) => %(<http://a/b#a> <http://a/b#b> "+1"^^<http://www.w3.org/2001/XMLSchema#integer> .),
|
352
|
+
%(:a :b 1.0) => %(<http://a/b#a> <http://a/b#b> "1.0"^^<http://www.w3.org/2001/XMLSchema#decimal> .),
|
353
|
+
%(:a :b 1.0e1) => %(<http://a/b#a> <http://a/b#b> "1.0e1"^^<http://www.w3.org/2001/XMLSchema#double> .),
|
354
|
+
%(:a :b 1.0e-1) => %(<http://a/b#a> <http://a/b#b> "1.0e-1"^^<http://www.w3.org/2001/XMLSchema#double> .),
|
355
|
+
%(:a :b 1.0e+1) => %(<http://a/b#a> <http://a/b#b> "1.0e+1"^^<http://www.w3.org/2001/XMLSchema#double> .),
|
356
|
+
}.each_pair do |n3, nt|
|
357
|
+
it "should create typed literal for '#{n3}'" do
|
358
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should accept empty localname" do
|
363
|
+
n3 = %(: : : .)
|
364
|
+
nt = %(<http://a/b#> <http://a/b#> <http://a/b#> .)
|
365
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should accept prefix with empty local name" do
|
369
|
+
n3 = %(@prefix foo: <http://foo/bar#> . foo: foo: foo: .)
|
370
|
+
nt = %(<http://foo/bar#> <http://foo/bar#> <http://foo/bar#> .)
|
371
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
372
|
+
end
|
373
|
+
|
374
|
+
it "should do something for @forAll"
|
375
|
+
|
376
|
+
it "should do something for @forSome"
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "namespaces" do
|
380
|
+
it "should set absolute base" do
|
381
|
+
n3 = %(@base <http://foo/bar> . <> :a <b> . <#c> :d </e>.)
|
382
|
+
nt = %(
|
383
|
+
<http://foo/bar> <http://foo/bara> <http://foo/b> .
|
384
|
+
<http://foo/bar#c> <http://foo/bard> <http://foo/e> .
|
385
|
+
)
|
386
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
387
|
+
end
|
388
|
+
|
389
|
+
it "should set absolute base (trailing /)" do
|
390
|
+
n3 = %(@base <http://foo/bar/> . <> :a <b> . <#c> :d </e>.)
|
391
|
+
nt = %(
|
392
|
+
<http://foo/bar/> <http://foo/bar/a> <http://foo/bar/b> .
|
393
|
+
<http://foo/bar/#c> <http://foo/bar/d> <http://foo/e> .
|
394
|
+
)
|
395
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should set absolute base (trailing #)" do
|
399
|
+
n3 = %(@base <http://foo/bar#> . <> :a <b> . <#c> :d </e>.)
|
400
|
+
nt = %(
|
401
|
+
<http://foo/bar> <http://foo/bar#a> <http://foo/b> .
|
402
|
+
<http://foo/bar#c> <http://foo/bar#d> <http://foo/e> .
|
403
|
+
)
|
404
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should set relative base" do
|
408
|
+
n3 = %(
|
409
|
+
@base <http://example.org/products/>.
|
410
|
+
<> :a <b>, <#c>.
|
411
|
+
@base <prod123/>.
|
412
|
+
<> :a <b>, <#c>.
|
413
|
+
@base <../>.
|
414
|
+
<> :a <d>, <#e>.
|
415
|
+
)
|
416
|
+
nt = %(
|
417
|
+
<http://example.org/products/> <http://example.org/products/a> <http://example.org/products/b> .
|
418
|
+
<http://example.org/products/> <http://example.org/products/a> <http://example.org/products/#c> .
|
419
|
+
<http://example.org/products/prod123/> <http://example.org/products/prod123/a> <http://example.org/products/prod123/b> .
|
420
|
+
<http://example.org/products/prod123/> <http://example.org/products/prod123/a> <http://example.org/products/prod123/#c> .
|
421
|
+
<http://example.org/products/> <http://example.org/products/a> <http://example.org/products/d> .
|
422
|
+
<http://example.org/products/> <http://example.org/products/a> <http://example.org/products/#e> .
|
423
|
+
)
|
424
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
425
|
+
end
|
426
|
+
|
427
|
+
it "should bind named namespace" do
|
428
|
+
n3doc = "@prefix ns: <http://the/namespace#> ."
|
429
|
+
@parser.parse(n3doc, "http://a/b")
|
430
|
+
@parser.graph.nsbinding.should == {"ns" => Namespace.new("http://the/namespace#", "ns")}
|
431
|
+
end
|
432
|
+
|
433
|
+
it "should bind empty prefix to <%> by default" do
|
434
|
+
n3doc = "@prefix : <#> ."
|
435
|
+
@parser.parse(n3doc, "http://the.document.itself")
|
436
|
+
@parser.graph.nsbinding.should == {"" => Namespace.new("http://the.document.itself#", "")}
|
437
|
+
end
|
438
|
+
|
439
|
+
it "should be able to bind _ as namespace" do
|
440
|
+
n3 = %(@prefix _: <http://underscore/> . _:a a _:p.)
|
441
|
+
nt = %(<http://underscore/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://underscore/p> .)
|
442
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
describe "keywords" do
|
447
|
+
[
|
448
|
+
%(prefix :<>.),
|
449
|
+
%(base <>.),
|
450
|
+
%(keywords a.),
|
451
|
+
%(:a is :b of :c.),
|
452
|
+
%(:a @is :b of :c.),
|
453
|
+
%(:a is :b @of :c.),
|
454
|
+
%(:a has :b :c.),
|
455
|
+
].each do |n3|
|
456
|
+
it "should require @ if keywords set to empty for '#{n3}'" do
|
457
|
+
lambda do
|
458
|
+
@parser.parse("@keywords . #{n3}", "http://a/b")
|
459
|
+
end.should raise_error(/unqualified keyword '\w+' used without @keyword directive/)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
{
|
464
|
+
%(:a a :b) => %(<http://a/b#a> <http://a/b#a> <http://a/b#b> .),
|
465
|
+
%(:a :b true) => %(<http://a/b#a> <http://a/b#b> <http://a/b#true> .),
|
466
|
+
%(:a :b false) => %(<http://a/b#a> <http://a/b#b> <http://a/b#false> .),
|
467
|
+
%(c :a :t) => %(<http://a/b#c> <http://a/b#a> <http://a/b#t> .),
|
468
|
+
%(:c a :t) => %(<http://a/b#c> <http://a/b#a> <http://a/b#t> .),
|
469
|
+
%(:c :a t) => %(<http://a/b#c> <http://a/b#a> <http://a/b#t> .),
|
470
|
+
}.each_pair do |n3, nt|
|
471
|
+
it "should use default_ns for '#{n3}'" do
|
472
|
+
@parser.parse("@keywords . #{n3}", "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
{
|
477
|
+
%(@keywords true. :a :b true.) => %(<http://a/b#a> <http://a/b#b> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .),
|
478
|
+
%(@keywords false. :a :b false.) => %(<http://a/b#a> <http://a/b#b> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .),
|
479
|
+
%(@keywords a. :a a :b.) => %(<http://a/b#a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://a/b#b> .),
|
480
|
+
%(@keywords is. :a is :b @of :c.) => %(<http://a/b#c> <http://a/b#b> <http://a/b#a> .),
|
481
|
+
%(@keywords of. :a @is :b of :c.) => %(<http://a/b#c> <http://a/b#b> <http://a/b#a> .),
|
482
|
+
%(@keywords has. :a has :b :c.) => %(<http://a/b#a> <http://a/b#b> <http://a/b#c> .),
|
483
|
+
} .each_pair do |n3, nt|
|
484
|
+
it "should use keyword for '#{n3}'" do
|
485
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
it "should raise error if unknown keyword set" do
|
490
|
+
n3 = %(@keywords foo.)
|
491
|
+
lambda do
|
492
|
+
@parser.parse(n3, "http://a/b")
|
493
|
+
end.should raise_error(ParserException, "undefined keywords used: foo")
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
describe "declaration ordering" do
|
498
|
+
it "should process _ namespace binding after an initial use as a BNode" do
|
499
|
+
n3 = %(
|
500
|
+
_:a a :p.
|
501
|
+
@prefix _: <http://underscore/> .
|
502
|
+
_:a a :p.
|
503
|
+
)
|
504
|
+
nt = %(
|
505
|
+
<http://underscore/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> :p .
|
506
|
+
_:a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> :p .
|
507
|
+
)
|
508
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
509
|
+
end
|
510
|
+
|
511
|
+
it "should allow a prefix to be redefined" do
|
512
|
+
n3 = %(
|
513
|
+
@prefix a: <http://host/A#>.
|
514
|
+
a:b a:p a:v .
|
515
|
+
|
516
|
+
@prefix a: <http://host/Z#>.
|
517
|
+
a:b a:p a:v .
|
518
|
+
)
|
519
|
+
nt = %(
|
520
|
+
<http://host/A#b> <http://host/A#p> <http://host/A#v> .
|
521
|
+
<http://host/Z#b> <http://host/Z#p> <http://host/Z#v> .
|
522
|
+
)
|
523
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
524
|
+
end
|
525
|
+
|
526
|
+
it "should process sequential @base declarations (swap base.n3)" do
|
527
|
+
n3 = %(
|
528
|
+
@base <http://example.com/ontolgies>. <a> :b <foo/bar#baz>.
|
529
|
+
@base <path/DFFERENT/>. <a2> :b2 <foo/bar#baz2>.
|
530
|
+
@prefix : <#>. <d3> :b3 <e3>.
|
531
|
+
)
|
532
|
+
nt = %(
|
533
|
+
<http://example.com/a> <http://example.com/ontolgiesb> <http://example.com/foo/bar#baz> .
|
534
|
+
<http://example.com/path/DFFERENT/a2> <http://example.com/path/DFFERENT/b2> <http://example.com/path/DFFERENT/foo/bar#baz2> .
|
535
|
+
<http://example.com/path/DFFERENT/d3> <http://example.com/path/DFFERENT/#b3> <http://example.com/path/DFFERENT/e3> .
|
536
|
+
)
|
537
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
describe "BNodes" do
|
542
|
+
it "should create BNode for identifier with '_' prefix" do
|
543
|
+
n3 = %(@prefix a: <http://foo/a#> . _:a a:p a:v .)
|
544
|
+
nt = %(_:bnode0 <http://foo/a#p> <http://foo/a#v> .)
|
545
|
+
end
|
546
|
+
|
547
|
+
it "should create BNode for [] as subject" do
|
548
|
+
n3 = %(@prefix a: <http://foo/a#> . [] a:p a:v .)
|
549
|
+
nt = %(_:bnode0 <http://foo/a#p> <http://foo/a#v> .)
|
550
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
551
|
+
end
|
552
|
+
|
553
|
+
it "should create BNode for [] as predicate" do
|
554
|
+
n3 = %(@prefix a: <http://foo/a#> . a:s [] a:o .)
|
555
|
+
nt = %(<http://foo/a#s> _:bnode0 <http://foo/a#o> .)
|
556
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
557
|
+
end
|
558
|
+
|
559
|
+
it "should create BNode for [] as object" do
|
560
|
+
n3 = %(@prefix a: <http://foo/a#> . a:s a:p [] .)
|
561
|
+
nt = %(<http://foo/a#s> <http://foo/a#p> _:bnode0 .)
|
562
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
563
|
+
end
|
564
|
+
|
565
|
+
it "should create BNode for [] as statement" do
|
566
|
+
n3 = %([:a :b] .)
|
567
|
+
nt = %(_:bnode0 <http://a/b#a> <http://a/b#b> .)
|
568
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
569
|
+
end
|
570
|
+
|
571
|
+
it "should create statements with BNode subjects using [ pref obj]" do
|
572
|
+
n3 = %(@prefix a: <http://foo/a#> . [ a:p a:v ] .)
|
573
|
+
nt = %(_:bnode0 <http://foo/a#p> <http://foo/a#v> .)
|
574
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
575
|
+
end
|
576
|
+
|
577
|
+
it "should create BNode as a single object" do
|
578
|
+
n3 = %(@prefix a: <http://foo/a#> . a:b a:oneRef [ a:pp "1" ; a:qq "2" ] .)
|
579
|
+
nt = %(
|
580
|
+
_:bnode0 <http://foo/a#pp> "1" .
|
581
|
+
_:bnode0 <http://foo/a#qq> "2" .
|
582
|
+
<http://foo/a#b> <http://foo/a#oneRef> _:bnode0 .
|
583
|
+
)
|
584
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
585
|
+
end
|
586
|
+
|
587
|
+
it "should create a shared BNode" do
|
588
|
+
n3 = %(
|
589
|
+
@prefix a: <http://foo/a#> .
|
590
|
+
|
591
|
+
a:b1 a:twoRef _:a .
|
592
|
+
a:b2 a:twoRef _:a .
|
593
|
+
|
594
|
+
_:a :pred [ a:pp "1" ; a:qq "2" ].
|
595
|
+
)
|
596
|
+
nt = %(
|
597
|
+
<http://foo/a#b1> <http://foo/a#twoRef> _:a .
|
598
|
+
<http://foo/a#b2> <http://foo/a#twoRef> _:a .
|
599
|
+
_:bnode0 <http://foo/a#pp> "1" .
|
600
|
+
_:bnode0 <http://foo/a#qq> "2" .
|
601
|
+
_:a :pred _:bnode0 .
|
602
|
+
)
|
603
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
604
|
+
end
|
605
|
+
|
606
|
+
it "should create nested BNodes" do
|
607
|
+
n3 = %(
|
608
|
+
@prefix a: <http://foo/a#> .
|
609
|
+
|
610
|
+
a:a a:p [ a:p2 [ a:p3 "v1" , "v2" ; a:p4 "v3" ] ; a:p5 "v4" ] .
|
611
|
+
)
|
612
|
+
nt = %(
|
613
|
+
_:bnode0 <http://foo/a#p3> "v1" .
|
614
|
+
_:bnode0 <http://foo/a#p3> "v2" .
|
615
|
+
_:bnode0 <http://foo/a#p4> "v3" .
|
616
|
+
_:bnode1 <http://foo/a#p2> _:bnode0 .
|
617
|
+
_:bnode1 <http://foo/a#p5> "v4" .
|
618
|
+
<http://foo/a#a> <http://foo/a#p> _:bnode1 .
|
619
|
+
)
|
620
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
621
|
+
end
|
622
|
+
|
623
|
+
describe "from paths" do
|
624
|
+
it "should create bnode for path x.p" do
|
625
|
+
n3 = %(:x2.:y2 :p2 "3" .)
|
626
|
+
nt = %(:x2 :y2 _:bnode0 . _:bnode0 :p2 "3" .)
|
627
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
628
|
+
end
|
629
|
+
|
630
|
+
it "should create bnode for path x!p" do
|
631
|
+
n3 = %(:x2!:y2 :p2 "3" .)
|
632
|
+
nt = %(:x2 :y2 _:bnode0 . _:bnode0 :p2 "3" .)
|
633
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
634
|
+
end
|
635
|
+
|
636
|
+
it "should create bnode for path x^p" do
|
637
|
+
n3 = %(:x2^:y2 :p2 "3" .)
|
638
|
+
nt = %(_:bnode0 :y2 :x2 . _:bnode0 :p2 "3" .)
|
639
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
640
|
+
end
|
641
|
+
|
642
|
+
it "should decode :joe!fam:mother!loc:office!loc:zip as Joe's mother's office's zipcode" do
|
643
|
+
n3 = %(
|
644
|
+
@prefix fam: <http://foo/fam#> .
|
645
|
+
@prefix loc: <http://foo/loc#> .
|
646
|
+
|
647
|
+
:joe!fam:mother!loc:office!loc:zip .
|
648
|
+
)
|
649
|
+
nt = %(
|
650
|
+
:joe <http://foo/fam#mother> _:bnode0 .
|
651
|
+
_:bnode0 <http://foo/loc#office> _:bnode1 .
|
652
|
+
_:bnode1 <http://foo/loc#zip> _:bnode2 .
|
653
|
+
)
|
654
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
655
|
+
end
|
656
|
+
|
657
|
+
it "should decode :joe!fam:mother^fam:mother Anyone whose mother is Joe's mother." do
|
658
|
+
n3 = %(
|
659
|
+
@prefix fam: <http://foo/fam#> .
|
660
|
+
@prefix loc: <http://foo/loc#> .
|
661
|
+
|
662
|
+
:joe!fam:mother^fam:mother .
|
663
|
+
)
|
664
|
+
nt = %(
|
665
|
+
:joe <http://foo/fam#mother> _:bnode0 .
|
666
|
+
_:bnode1 <http://foo/fam#mother> _:bnode0 .
|
667
|
+
)
|
668
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
669
|
+
end
|
670
|
+
|
671
|
+
it "should decode path with property list." do
|
672
|
+
n3 = %(
|
673
|
+
@prefix a: <http://a/ns#>.
|
674
|
+
:a2.a:b2.a:c2 :q1 "3" ; :q2 "4" , "5" .
|
675
|
+
)
|
676
|
+
nt = %(
|
677
|
+
:a2 <http://a/ns#b2> _:bnode0 .
|
678
|
+
_:bnode0 <http://a/ns#c2> _:bnode1 .
|
679
|
+
_:bnode1 :q1 "3" .
|
680
|
+
_:bnode1 :q2 "4" .
|
681
|
+
_:bnode1 :q2 "5" .
|
682
|
+
)
|
683
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
684
|
+
end
|
685
|
+
|
686
|
+
it "should decode path as object(1)" do
|
687
|
+
n3 = %(:a :b "lit"^:c.)
|
688
|
+
nt = %(
|
689
|
+
:a :b _:bnode .
|
690
|
+
_:bnode :c "lit" .
|
691
|
+
)
|
692
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
693
|
+
end
|
694
|
+
|
695
|
+
it "should decode path as object(2)" do
|
696
|
+
n3 = %(@prefix a: <http://a/ns#>. :r :p :o.a:p1.a:p2 .)
|
697
|
+
nt = %(
|
698
|
+
:o <http://a/ns#p1> _:bnode0 .
|
699
|
+
_:bnode0 <http://a/ns#p2> _:bnode1 .
|
700
|
+
:r :p _:bnode1 .
|
701
|
+
)
|
702
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
703
|
+
end
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
describe "formulae" do
|
708
|
+
it "should require that graph be formula_aware when encountering a formlua"
|
709
|
+
|
710
|
+
it "should separate triples between specified and quoted graphs"
|
711
|
+
end
|
712
|
+
|
713
|
+
describe "object lists" do
|
714
|
+
it "should create 2 statements for simple list" do
|
715
|
+
n3 = %(:a :b :c, :d)
|
716
|
+
nt = %(<http://a/b#a> <http://a/b#b> <http://a/b#c> . <http://a/b#a> <http://a/b#b> <http://a/b#d> .)
|
717
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
718
|
+
end
|
719
|
+
end
|
720
|
+
|
721
|
+
describe "property lists" do
|
722
|
+
it "should parse property list" do
|
723
|
+
n3 = %(
|
724
|
+
@prefix a: <http://foo/a#> .
|
725
|
+
|
726
|
+
a:b a:p1 "123" ; a:p1 "456" .
|
727
|
+
a:b a:p2 a:v1 ; a:p3 a:v2 .
|
728
|
+
)
|
729
|
+
nt = %(
|
730
|
+
<http://foo/a#b> <http://foo/a#p1> "123" .
|
731
|
+
<http://foo/a#b> <http://foo/a#p1> "456" .
|
732
|
+
<http://foo/a#b> <http://foo/a#p2> <http://foo/a#v1> .
|
733
|
+
<http://foo/a#b> <http://foo/a#p3> <http://foo/a#v2> .
|
734
|
+
)
|
735
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
736
|
+
end
|
737
|
+
end
|
738
|
+
|
739
|
+
describe "lists" do
|
740
|
+
it "should parse empty list" do
|
741
|
+
n3 = %(@prefix :<http://example.com/>. :empty :set ().)
|
742
|
+
nt = %(
|
743
|
+
<http://example.com/empty> <http://example.com/set> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .)
|
744
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
745
|
+
end
|
746
|
+
|
747
|
+
it "should parse list with single element" do
|
748
|
+
n3 = %(@prefix :<http://example.com/>. :gregg :wrote ("RdfContext").)
|
749
|
+
nt = %(
|
750
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "RdfContext" .
|
751
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
752
|
+
<http://example.com/gregg> <http://example.com/wrote> _:bnode0 .
|
753
|
+
)
|
754
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
755
|
+
end
|
756
|
+
|
757
|
+
it "should parse list with multiple elements" do
|
758
|
+
n3 = %(@prefix :<http://example.com/>. :gregg :name ("Gregg" "Barnum" "Kellogg").)
|
759
|
+
nt = %(
|
760
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Gregg" .
|
761
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode1 .
|
762
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Barnum" .
|
763
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode2 .
|
764
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Kellogg" .
|
765
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
766
|
+
<http://example.com/gregg> <http://example.com/name> _:bnode0 .
|
767
|
+
)
|
768
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
769
|
+
end
|
770
|
+
|
771
|
+
it "should parse unattached lists" do
|
772
|
+
n3 = %(
|
773
|
+
@prefix a: <http://foo/a#> .
|
774
|
+
|
775
|
+
("1" "2" "3") .
|
776
|
+
# This is not a statement.
|
777
|
+
() .
|
778
|
+
)
|
779
|
+
nt = %(
|
780
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "1" .
|
781
|
+
_:bnode0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode1 .
|
782
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "2" .
|
783
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode2 .
|
784
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "3" .
|
785
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
786
|
+
)
|
787
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
788
|
+
end
|
789
|
+
|
790
|
+
it "should add property to nil list" do
|
791
|
+
n3 = %(@prefix a: <http://foo/a#> . () a:prop "nilProp" .)
|
792
|
+
nt = %(<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> <http://foo/a#prop> "nilProp" .)
|
793
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
794
|
+
end
|
795
|
+
it "should parse with compound items" do
|
796
|
+
n3 = %(
|
797
|
+
@prefix a: <http://foo/a#> .
|
798
|
+
|
799
|
+
a:a a:p ( [ a:p2 "v1" ]
|
800
|
+
<http://resource1>
|
801
|
+
<http://resource2>
|
802
|
+
("inner list") ) .
|
803
|
+
|
804
|
+
<http://resource1> a:p "value" .
|
805
|
+
)
|
806
|
+
nt = %(
|
807
|
+
_:bnode0 <http://foo/a#p2> "v1" .
|
808
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:bnode0 .
|
809
|
+
_:bnode1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode2 .
|
810
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://resource1> .
|
811
|
+
_:bnode2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode3 .
|
812
|
+
_:bnode3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://resource2> .
|
813
|
+
_:bnode4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "inner list" .
|
814
|
+
_:bnode4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
815
|
+
_:bnode3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:bnode5 .
|
816
|
+
_:bnode5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:bnode4 .
|
817
|
+
_:bnode5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
818
|
+
<http://foo/a#a> <http://foo/a#p> _:bnode1 .
|
819
|
+
<http://resource1> <http://foo/a#p> "value" .
|
820
|
+
)
|
821
|
+
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug)
|
822
|
+
end
|
823
|
+
|
824
|
+
end
|
825
|
+
|
826
|
+
# n3p tests taken from http://inamidst.com/n3p/test/
|
827
|
+
describe "with real data tests" do
|
828
|
+
dirs = %w(misc lcsh rdflib n3p)
|
829
|
+
dirs.each do |dir|
|
830
|
+
dir_name = File.join(File.dirname(__FILE__), '..', 'test', 'n3_tests', dir, '*.n3')
|
831
|
+
Dir.glob(dir_name).each do |n3|
|
832
|
+
it "#{dir} #{n3}" do
|
833
|
+
test_file(n3)
|
834
|
+
end
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|
838
|
+
|
839
|
+
describe "with AggregateGraph tests" do
|
840
|
+
subject { Graph.new }
|
841
|
+
|
842
|
+
describe "with a type" do
|
843
|
+
before(:each) do
|
844
|
+
subject.parse(%(
|
845
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
846
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
847
|
+
@prefix : <http://test/> .
|
848
|
+
:foo a rdfs:Class.
|
849
|
+
:bar :d :c.
|
850
|
+
:a :d :c.
|
851
|
+
), "http://a/b")
|
852
|
+
end
|
853
|
+
|
854
|
+
it "should have 3 namespaces" do
|
855
|
+
subject.nsbinding.keys.length.should == 3
|
856
|
+
end
|
857
|
+
end
|
858
|
+
|
859
|
+
describe "with blank clause" do
|
860
|
+
before(:each) do
|
861
|
+
subject.parse(%(
|
862
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
863
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
864
|
+
@prefix : <http://test/> .
|
865
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
866
|
+
:foo a rdfs:Resource.
|
867
|
+
:bar rdfs:isDefinedBy [ a log:Formula ].
|
868
|
+
:a :d :e.
|
869
|
+
), "http://a/b")
|
870
|
+
end
|
871
|
+
|
872
|
+
it "should have 4 namespaces" do
|
873
|
+
subject.nsbinding.keys.length.should == 4
|
874
|
+
end
|
875
|
+
end
|
876
|
+
|
877
|
+
describe "with empty subject" do
|
878
|
+
before(:each) do
|
879
|
+
subject.parse(%(
|
880
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
881
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
882
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
883
|
+
@prefix : <http://test/> .
|
884
|
+
<> a log:N3Document.
|
885
|
+
), "http://test/")
|
886
|
+
end
|
887
|
+
|
888
|
+
it "should have 4 namespaces" do
|
889
|
+
subject.nsbinding.keys.length.should == 4
|
890
|
+
end
|
891
|
+
|
892
|
+
it "should have default subject" do
|
893
|
+
subject.size.should == 1
|
894
|
+
subject.triples.first.subject.should == "http://test/"
|
895
|
+
end
|
896
|
+
end
|
897
|
+
end
|
898
|
+
end
|
899
|
+
|
900
|
+
it "should parse rdf_core testcase" do
|
901
|
+
sampledoc = <<-EOF;
|
902
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#PositiveParserTest> .
|
903
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#approval> <http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2002Mar/0235.html> .
|
904
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#inputDocument> <http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/test001.rdf> .
|
905
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#issue> <http://www.w3.org/2000/03/rdf-tracking/#rdfms-xml-base> .
|
906
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#outputDocument> <http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/test001.nt> .
|
907
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#status> "APPROVED" .
|
908
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/test001.nt> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#NT-Document> .
|
909
|
+
<http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/test001.rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#RDF-XML-Document> .
|
910
|
+
EOF
|
911
|
+
@parser.parse(sampledoc, "http://www.w3.org/2000/10/rdf-tests/rdfcore/amp-in-url/Manifest.rdf")
|
912
|
+
|
913
|
+
@parser.graph.should be_equivalent_graph(sampledoc,
|
914
|
+
:about => "http://www.w3.org/2000/10/rdf-tests/rdfcore/amp-in-url/Manifest.rdf",
|
915
|
+
:trace => @parser.debug, :compare => :array
|
916
|
+
)
|
917
|
+
end
|
918
|
+
|
919
|
+
def test_file(filepath)
|
920
|
+
n3_string = File.read(filepath)
|
921
|
+
@parser.parse(n3_string, "file:#{filepath}")
|
922
|
+
|
923
|
+
nt_string = File.read(filepath.sub('.n3', '.nt'))
|
924
|
+
@parser.graph.should be_equivalent_graph(nt_string,
|
925
|
+
:about => "file:#{filepath}",
|
926
|
+
:trace => @parser.debug)
|
927
|
+
end
|
928
|
+
end
|