eyeling 1.28.4 → 1.28.6

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.
@@ -19,6 +19,7 @@ function fail(msg) {
19
19
 
20
20
  const builtins = require('../lib/builtins');
21
21
  require('../lib/engine');
22
+ const { reason } = require('../index');
22
23
 
23
24
  const expectedApiKeys = [
24
25
  'registerBuiltin',
@@ -61,7 +62,7 @@ const expectedTermsKeys = [
61
62
  'Rule',
62
63
  ].sort();
63
64
 
64
- const expectedNsKeys = ['RDF_NS', 'XSD_NS', 'CRYPTO_NS', 'MATH_NS', 'TIME_NS', 'LIST_NS', 'LOG_NS', 'STRING_NS'].sort();
65
+ const expectedNsKeys = ['RDF_NS', 'XSD_NS', 'CRYPTO_NS', 'MATH_NS', 'TIME_NS', 'LIST_NS', 'LOG_NS', 'STRING_NS', 'DT_NS'].sort();
65
66
 
66
67
  function makeOkMapModule() {
67
68
  return {
@@ -97,6 +98,11 @@ function makeBadExportModule() {
97
98
  return 42;
98
99
  }
99
100
 
101
+
102
+ function runReason(input) {
103
+ return reason({ proof: false }, input);
104
+ }
105
+
100
106
  const cases = [
101
107
  {
102
108
  name: 'builtin helper API stays stable and frozen',
@@ -110,6 +116,14 @@ const cases = [
110
116
  assert.deepEqual(Object.keys(api.ns).sort(), expectedNsKeys);
111
117
  },
112
118
  },
119
+ {
120
+ name: 'custom builtin helper termToN3 uses default prefixes when omitted',
121
+ run() {
122
+ const api = builtins.__testBuildBuiltinApi();
123
+ assert.equal(api.termToN3(api.internIri('http://www.w3.org/2000/10/swap/log#implies')), 'log:implies');
124
+ assert.equal(api.termToN3(api.internLiteral('"abc"')), '"abc"');
125
+ },
126
+ },
113
127
  {
114
128
  name: 'registerBuiltinModule accepts supported module export forms',
115
129
  run() {
@@ -149,6 +163,60 @@ const cases = [
149
163
  );
150
164
  },
151
165
  },
166
+
167
+ {
168
+ name: 'datatype builtins inspect literals, validate XSD value spaces, compare values, and canonicalize',
169
+ run() {
170
+ const out = runReason(`
171
+ @prefix : <http://example.org/datatype-tests#> .
172
+ @prefix dt: <https://eyereasoner.github.io/eyeling/datatype#> .
173
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
174
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
175
+
176
+ { "01"^^xsd:integer dt:datatype ?d . } => { :integer :datatype ?d } .
177
+ { "001"^^xsd:integer dt:lexicalForm ?lex . } => { :integer :lexicalForm ?lex } .
178
+ { "hello"@en dt:language ?lang . } => { :language :tag ?lang } .
179
+ { "plain" dt:datatype ?d . } => { :plain :datatype ?d } .
180
+ { "hello"@EN dt:datatype ?d . } => { :langString :datatype ?d } .
181
+
182
+ { "1"^^xsd:integer dt:validForDatatype xsd:integer . } => { :valid :integer true } .
183
+ { "2147483648"^^xsd:int dt:invalidForDatatype xsd:int . } => { :invalid :int true } .
184
+ { "2"^^xsd:boolean dt:invalidForDatatype xsd:boolean . } => { :invalid :boolean true } .
185
+ { "2026-02-31T00:00:00Z"^^xsd:dateTime dt:invalidForDatatype xsd:dateTime . } => { :invalid :dateTime true } .
186
+
187
+ { "01"^^xsd:integer dt:sameValueAs "1.0"^^xsd:decimal . } => { :same :numeric true } .
188
+ { "true"^^xsd:boolean dt:sameValueAs "1"^^xsd:boolean . } => { :same :boolean true } .
189
+ { "2026-06-10T12:00:00Z"^^xsd:dateTime dt:sameValueAs "2026-06-10T14:00:00+02:00"^^xsd:dateTime . } => { :same :dateTime true } .
190
+ { "AQID"^^xsd:base64Binary dt:sameValueAs "010203"^^xsd:hexBinary . } => { :same :binary true } .
191
+ { "11"^^xsd:integer dt:differentValueFrom "12"^^xsd:integer . } => { :different :numeric true } .
192
+
193
+ { "01"^^xsd:integer dt:canonicalLiteral ?ci . } => { :canonical :integer ?ci } .
194
+ { "1"^^xsd:boolean dt:canonicalLiteral ?cb . } => { :canonical :boolean ?cb } .
195
+ { " a\t b "^^xsd:token dt:canonicalLiteral ?ct . } => { :canonical :token ?ct } .
196
+ { "2026-06-10T14:00:00+02:00"^^xsd:dateTime dt:canonicalLiteral ?cd . } => { :canonical :dateTime ?cd } .
197
+ `);
198
+
199
+ assert.match(out, /:integer :datatype xsd:integer \./);
200
+ assert.match(out, /:integer :lexicalForm "001" \./);
201
+ assert.match(out, /:language :tag "en" \./);
202
+ assert.match(out, /:plain :datatype xsd:string \./);
203
+ assert.match(out, /:langString :datatype rdf:langString \./);
204
+ assert.match(out, /:valid :integer true \./);
205
+ assert.match(out, /:invalid :int true \./);
206
+ assert.match(out, /:invalid :boolean true \./);
207
+ assert.match(out, /:invalid :dateTime true \./);
208
+ assert.match(out, /:same :numeric true \./);
209
+ assert.match(out, /:same :boolean true \./);
210
+ assert.match(out, /:same :dateTime true \./);
211
+ assert.match(out, /:same :binary true \./);
212
+ assert.match(out, /:different :numeric true \./);
213
+ assert.match(out, /:canonical :integer "1"\^\^xsd:integer \./);
214
+ assert.match(out, /:canonical :boolean true \./);
215
+ assert.match(out, /:canonical :token "a b"\^\^xsd:token \./);
216
+ assert.match(out, /:canonical :dateTime "2026-06-10T12:00:00Z"\^\^xsd:dateTime \./);
217
+ },
218
+ },
219
+
152
220
  ];
153
221
 
154
222
  let passed = 0;