@@ -1189,6 +1189,65 @@ describe('Parser', () => {
11891189 shouldParse ( '<a> <b> <c> <g>.\n<<<a> <b> <c>>> <d> <e>.' ,
11901190 [ 'a' , 'b' , 'c' , 'g' ] ,
11911191 [ [ 'a' , 'b' , 'c' ] , 'd' , 'e' ] ) ) ;
1192+
1193+ it ( 'should parse an explicit triple with reified annotation' ,
1194+ shouldParse ( '<a> <b> <c> {| <d> <e> |} .' ,
1195+ [ 'a' , 'b' , 'c' ] ,
1196+ [ [ 'a' , 'b' , 'c' ] , 'd' , 'e' ] ) ) ;
1197+
1198+ const q = [ 'http://example.com/ns#s' , 'http://example.com/ns#p' ,
1199+ [ 'http://example.com/ns#a' , 'http://example.com/ns#b' , 'http://example.com/ns#c' ] ] ;
1200+
1201+ it ( 'should parse an explicit triple with reified annotation containing prefixed iris' ,
1202+ shouldParse ( 'PREFIX : <http://example.com/ns#> \n :s :p <<:a :b :c>> {| :q :z |} .' ,
1203+ q , [ q , 'http://example.com/ns#q' , 'http://example.com/ns#z' ] ) ) ;
1204+
1205+ it ( 'should parse an explicit triple with 2 reified annotations' ,
1206+ shouldParse ( '<a> <b> <c> {| <d> <e>; <f> <g> |} .' ,
1207+ [ 'a' , 'b' , 'c' ] ,
1208+ [ [ 'a' , 'b' , 'c' ] , 'd' , 'e' ] ,
1209+ [ [ 'a' , 'b' , 'c' ] , 'f' , 'g' ] ) ) ;
1210+
1211+ // TODO: See if this is required by the spec tests
1212+ // it('should parse an explicit triple with reified annotation containing punctuation',
1213+ // shouldParse('<a> <b> <c> {| <d> <e> . |} .',
1214+ // ['a', 'b', 'c'],
1215+ // [['a', 'b', 'c'], 'd', 'e']));
1216+
1217+ it ( 'should parse an explicit triple with reified annotation in a named graph' ,
1218+ shouldParse ( '<G> { <a> <b> <c> {| <d> <e> |} . }' ,
1219+ [ 'a' , 'b' , 'c' , 'G' ] ,
1220+ [ [ 'a' , 'b' , 'c' ] , 'd' , 'e' , 'G' ] ) ) ;
1221+
1222+ it ( 'should parse an explicit triple with 2 reified annotations in a named graph' ,
1223+ shouldParse ( '<G> { <a> <b> <c> {| <d> <e>; <f> <g> |} . }' ,
1224+ [ 'a' , 'b' , 'c' , 'G' ] ,
1225+ [ [ 'a' , 'b' , 'c' ] , 'd' , 'e' , 'G' ] ,
1226+ [ [ 'a' , 'b' , 'c' ] , 'f' , 'g' , 'G' ] ) ) ;
1227+
1228+ it ( 'should not parse an annotated object in list' ,
1229+ shouldNotParse ( '<a> <b> ( <c> {| <d> <e> |} )' ,
1230+ 'Expected entity but got {| on line 1.' ) ) ;
1231+
1232+ it ( 'should not parse an annotated statement in list' ,
1233+ shouldNotParse ( '<a> <b> ( <c> <d> <e> {| <d> <e> |} )' ,
1234+ 'Expected entity but got {| on line 1.' ) ) ;
1235+
1236+ it ( 'should not parse fourth term in quoted triple' ,
1237+ shouldNotParse ( '<< <a> <b> <c> <g> >> <p> <q>' ,
1238+ 'Expected >> to follow "http://example.org/c" but got IRI on line 1.' ) ) ;
1239+
1240+ it ( 'should not parse fourth term in quoted triple object' ,
1241+ shouldNotParse ( '<p> <q> << <a> <b> <c> <g> >>' ,
1242+ 'Expected >> to follow "http://example.org/c" but got IRI on line 1.' ) ) ;
1243+
1244+ it ( 'should not parse quoted triple as predicate' ,
1245+ shouldNotParse ( '<p> << <a> <b> <c> >> <q>' ,
1246+ 'Expected entity but got << on line 1.' ) ) ;
1247+
1248+ it ( 'should not parse quoted quad as predicate' ,
1249+ shouldNotParse ( '<p> << <a> <b> <c> <d> >> <q>' ,
1250+ 'Expected entity but got << on line 1.' ) ) ;
11921251 } ) ;
11931252
11941253 describe ( 'An Parser instance without document IRI' , ( ) => {
@@ -1369,6 +1428,10 @@ describe('Parser', () => {
13691428 shouldNotParse ( parser , '<<<a> <b> <c>>> <a> <b> .' ,
13701429 'Unexpected RDF* syntax on line 1.' ) ) ;
13711430
1431+ it ( 'should not parse annotated statement' ,
1432+ shouldNotParse ( parser , '<a> <b> <c> {| <a> <b> |} .' ,
1433+ 'Unexpected RDF* syntax on line 1.' ) ) ;
1434+
13721435 it ( 'should not parse RDF* in the object position' ,
13731436 shouldNotParse ( parser , '<a> <b> <<a> <b> <c>>>.' ,
13741437 'Unexpected RDF* syntax on line 1.' ) ) ;
@@ -2494,7 +2557,7 @@ function mapToQuad(item) {
24942557function toSortedJSON ( triples ) {
24952558 triples = triples . map ( t => {
24962559 return JSON . stringify ( [
2497- t . subject . toJSON ( ) , t . predicate . toJSON ( ) , t . object . toJSON ( ) , t . graph . toJSON ( ) ,
2560+ t . subject && t . subject . toJSON ( ) , t . predicate && t . predicate . toJSON ( ) , t . object && t . object . toJSON ( ) , t . graph && t . graph . toJSON ( ) ,
24982561 ] ) ;
24992562 } ) ;
25002563 triples . sort ( ) ;
0 commit comments