eyeling 1.27.9 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/api.test.js CHANGED
@@ -2106,29 +2106,32 @@ _:x :hates { _:foo :making :mess }.
2106
2106
  },
2107
2107
  },
2108
2108
  {
2109
- name: '63a RDF/JS export: reasonRdfJs can skip N3-only derived triples',
2109
+ name: '63a RDF/JS export: reasonRdfJs emits RDF 1.2 Quad terms for singleton graph terms',
2110
2110
  async run() {
2111
2111
  const ex = 'http://example.org/';
2112
2112
  const input = `@prefix : <${ex}>.
2113
2113
  :a :p :b.
2114
2114
  { :a :p :b. } => { :x :holds { :a :p :b. }. :x :ok :yes. }.`;
2115
2115
  const quads = [];
2116
- for await (const quad of reasonRdfJs(input, { skipUnsupportedRdfJs: true })) {
2116
+ for await (const quad of reasonRdfJs(input)) {
2117
2117
  quads.push(quad);
2118
2118
  }
2119
2119
  this.quads = quads;
2120
- return quads.map((q) => `${q.subject.value} ${q.predicate.value} ${q.object.value}`).join('\n');
2120
+ return quads.map((q) => `${q.subject.value} ${q.predicate.value} ${q.object.termType}:${q.object.value}`).join('\n');
2121
2121
  },
2122
- expect: [/http:\/\/example\.org\/ok/],
2123
- notExpect: [/http:\/\/example\.org\/holds/],
2122
+ expect: [/http:\/\/example\.org\/ok/, /http:\/\/example\.org\/holds\s+Quad:/],
2124
2123
  check(outputIgnored, tc) {
2125
- assert.equal(tc.quads.length, 1, 'Expected one yielded RDF/JS quad after skipping GraphTerm output');
2126
- assert.equal(tc.quads[0].predicate.value, 'http://example.org/ok');
2127
- assert.equal(tc.quads[0].object.value, 'http://example.org/yes');
2124
+ assert.equal(tc.quads.length, 2, 'Expected both derived facts as RDF/JS quads');
2125
+ const holds = tc.quads.find((q) => q.predicate.value === 'http://example.org/holds');
2126
+ assert.ok(holds, 'Expected :holds quad');
2127
+ assert.equal(holds.object.termType, 'Quad');
2128
+ assert.equal(holds.object.subject.value, 'http://example.org/a');
2129
+ assert.equal(holds.object.predicate.value, 'http://example.org/p');
2130
+ assert.equal(holds.object.object.value, 'http://example.org/b');
2128
2131
  },
2129
2132
  },
2130
2133
  {
2131
- name: '63b RDF/JS export: reasonStream keeps N3 closure while omitting unsupported closureQuads',
2134
+ name: '63b RDF/JS export: reasonStream converts singleton graph terms without skipUnsupportedRdfJs',
2132
2135
  run() {
2133
2136
  const ex = 'http://example.org/';
2134
2137
  const input = `@prefix : <${ex}>.
@@ -2137,7 +2140,6 @@ _:x :hates { _:foo :making :mess }.
2137
2140
  const seen = [];
2138
2141
  const result = reasonStream(input, {
2139
2142
  rdfjs: true,
2140
- skipUnsupportedRdfJs: true,
2141
2143
  includeInputFactsInClosure: false,
2142
2144
  onDerived: ({ triple, quad }) => seen.push({ triple, quad }),
2143
2145
  });
@@ -2148,24 +2150,23 @@ _:x :hates { _:foo :making :mess }.
2148
2150
  expect: [/:holds/, /:ok/],
2149
2151
  check(outputIgnored, tc) {
2150
2152
  assert.equal(tc.seen.length, 2, 'Expected both derived facts to reach onDerived');
2151
- assert.equal(tc.seen.filter((x) => x.quad).length, 1, 'Expected only one RDF/JS quad in onDerived');
2153
+ assert.equal(tc.seen.filter((x) => x.quad).length, 2, 'Expected both RDF/JS quads in onDerived');
2152
2154
  assert.ok(Array.isArray(tc.result.closureQuads), 'Expected closureQuads array');
2153
- assert.equal(
2154
- tc.result.closureQuads.length,
2155
- 1,
2156
- 'Expected unsupported GraphTerm triple to be omitted from closureQuads',
2155
+ assert.equal(tc.result.closureQuads.length, 2, 'Expected both RDF/JS quads in closureQuads');
2156
+ assert.ok(
2157
+ tc.result.closureQuads.some(
2158
+ (q) => q.predicate.value === 'http://example.org/holds' && q.object.termType === 'Quad',
2159
+ ),
2160
+ 'Expected RDF 1.2 Quad term object in closureQuads',
2157
2161
  );
2158
- assert.equal(tc.result.closureQuads[0].predicate.value, 'http://example.org/ok');
2159
2162
  assert.match(tc.result.closureN3, /:holds/, 'Expected N3 closure to retain quoted-formula triple');
2160
2163
  },
2161
2164
  },
2162
2165
  {
2163
- name: '64 RDF/JS validation: named-graph input quads are rejected clearly',
2164
- expectError: true,
2166
+ name: '64 RDF/JS input: named-graph quads are represented as log:nameOf graph terms',
2165
2167
  run() {
2166
2168
  const ex = 'http://example.org/';
2167
- return reason(
2168
- {},
2169
+ const result = reasonStream(
2169
2170
  {
2170
2171
  quads: [
2171
2172
  rdfjs.quad(
@@ -2176,7 +2177,61 @@ _:x :hates { _:foo :making :mess }.
2176
2177
  ),
2177
2178
  ],
2178
2179
  },
2180
+ { rdfjs: true },
2181
+ );
2182
+ this.result = result;
2183
+ return result.closureN3;
2184
+ },
2185
+ expect: [/log:nameOf/, /http:\/\/example\.org\/g/, /http:\/\/example\.org\/s/],
2186
+ check(outputIgnored, tc) {
2187
+ assert.equal(tc.result.closureQuads.length, 1, 'Expected one named-graph RDF/JS quad');
2188
+ assert.equal(tc.result.closureQuads[0].graph.value, 'http://example.org/g');
2189
+ },
2190
+ },
2191
+ {
2192
+ name: '64a RDF/JS input: Quad terms are accepted as RDF 1.2 triple terms',
2193
+ run() {
2194
+ const ex = 'http://example.org/';
2195
+ const quoted = rdfjs.quad(
2196
+ rdfjs.namedNode(ex + 's'),
2197
+ rdfjs.namedNode(ex + 'p'),
2198
+ rdfjs.namedNode(ex + 'o'),
2199
+ );
2200
+ const result = reasonStream(
2201
+ {
2202
+ quads: [rdfjs.quad(rdfjs.namedNode(ex + 'obs'), rdfjs.namedNode(ex + 'about'), quoted)],
2203
+ },
2204
+ { rdf: true, rdfjs: true },
2205
+ );
2206
+ this.result = result;
2207
+ return result.closureN3;
2208
+ },
2209
+ expect: [/<<\(\s+<http:\/\/example\.org\/s>\s+<http:\/\/example\.org\/p>\s+<http:\/\/example\.org\/o>\s+\)>>/],
2210
+ check(outputIgnored, tc) {
2211
+ assert.equal(tc.result.closureQuads.length, 1, 'Expected one RDF/JS quad');
2212
+ assert.equal(tc.result.closureQuads[0].object.termType, 'Quad');
2213
+ assert.equal(tc.result.closureQuads[0].object.subject.value, 'http://example.org/s');
2214
+ },
2215
+ },
2216
+ {
2217
+ name: '64b RDF/JS input: object with quads and n3 text is merged',
2218
+ run() {
2219
+ const ex = 'http://example.org/';
2220
+ const result = reasonStream(
2221
+ {
2222
+ n3: `@prefix : <${ex}>.
2223
+ { ?x :p ?y. } => { ?x :q ?y. } .`,
2224
+ quads: [rdfjs.quad(rdfjs.namedNode(ex + 'a'), rdfjs.namedNode(ex + 'p'), rdfjs.namedNode(ex + 'b'))],
2225
+ },
2226
+ { includeInputFactsInClosure: false, rdfjs: true },
2179
2227
  );
2228
+ this.result = result;
2229
+ return result.closureN3;
2230
+ },
2231
+ expect: [/:a\s+:q\s+:b/],
2232
+ check(outputIgnored, tc) {
2233
+ assert.equal(tc.result.closureQuads.length, 1, 'Expected one derived RDF/JS quad');
2234
+ assert.equal(tc.result.closureQuads[0].predicate.value, 'http://example.org/q');
2180
2235
  },
2181
2236
  },
2182
2237
  {