eyeling 1.21.1 → 1.21.2
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/HANDBOOK.md +1 -1
- package/package.json +3 -3
- package/test/{builtin-contract.test.js → builtins.test.js} +40 -13
- package/test/fixtures/builtins/bad-export.js +0 -3
- package/test/fixtures/builtins/ok-builtins.js +0 -7
- package/test/fixtures/builtins/ok-default-map.js +0 -7
- package/test/fixtures/builtins/ok-map.js +0 -5
- package/test/fixtures/builtins/ok-register.js +0 -7
package/HANDBOOK.md
CHANGED
|
@@ -2141,7 +2141,7 @@ In practice, this means:
|
|
|
2141
2141
|
- builtin module loading accepts only the documented export forms
|
|
2142
2142
|
- the helper API exposed by `__buildBuiltinRegistrationApi()` has a fixed key set
|
|
2143
2143
|
- builtin handlers should return an array of substitution objects
|
|
2144
|
-
- accidental helper drift is caught by `test/
|
|
2144
|
+
- accidental helper drift is caught by `test/builtins.test.js`
|
|
2145
2145
|
|
|
2146
2146
|
This is only meant to stop silent breakage. It is **not** a promise that Eyeling can never change the builtin API. If the helper surface ever needs to change, that change should be deliberate, documented, and called out in release notes.
|
|
2147
2147
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyeling",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "A minimal Notation3 (N3) reasoner in JavaScript.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"build": "node tools/bundle.js",
|
|
43
43
|
"test:packlist": "node test/packlist.test.js",
|
|
44
44
|
"test:api": "node test/api.test.js",
|
|
45
|
-
"test:
|
|
45
|
+
"test:builtins": "node test/builtins.test.js",
|
|
46
46
|
"test:n3gen": "node test/n3gen.test.js",
|
|
47
47
|
"test:examples": "node test/examples.test.js",
|
|
48
48
|
"test:extra": "node test/extra.test.js",
|
|
49
49
|
"test:manifest": "node test/manifest.test.js",
|
|
50
50
|
"test:playground": "node test/playground.test.js",
|
|
51
51
|
"test:package": "node test/package.test.js",
|
|
52
|
-
"test:all": "npm run test:api && npm run test:
|
|
52
|
+
"test:all": "npm run test:api && npm run test:builtins && npm run test:n3gen && npm run test:examples && npm run test:extra && npm run test:manifest && npm run test:playground",
|
|
53
53
|
"pretest": "npm run build && npm run test:packlist",
|
|
54
54
|
"test": "npm run test:all",
|
|
55
55
|
"posttest": "npm run test:package",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert/strict');
|
|
4
|
-
const path = require('node:path');
|
|
5
4
|
|
|
6
5
|
const TTY = process.stdout.isTTY;
|
|
7
6
|
const C = TTY
|
|
@@ -18,7 +17,6 @@ function fail(msg) {
|
|
|
18
17
|
console.error(`${C.r}FAIL${C.n} ${msg}`);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const fixtures = path.join(__dirname, 'fixtures', 'builtins');
|
|
22
20
|
const builtins = require('../lib/builtins');
|
|
23
21
|
require('../lib/engine');
|
|
24
22
|
|
|
@@ -62,8 +60,43 @@ const expectedTermsKeys = [
|
|
|
62
60
|
'Triple',
|
|
63
61
|
'Rule',
|
|
64
62
|
].sort();
|
|
63
|
+
|
|
65
64
|
const expectedNsKeys = ['RDF_NS', 'XSD_NS', 'CRYPTO_NS', 'MATH_NS', 'TIME_NS', 'LIST_NS', 'LOG_NS', 'STRING_NS'].sort();
|
|
66
65
|
|
|
66
|
+
function makeOkMapModule() {
|
|
67
|
+
return {
|
|
68
|
+
'http://example.org/test#ok': ({ subst }) => [subst],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function makeOkRegisterModule() {
|
|
73
|
+
return {
|
|
74
|
+
register(api) {
|
|
75
|
+
api.registerBuiltin('http://example.org/test#ok-register', ({ subst }) => [subst]);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function makeOkBuiltinsModule() {
|
|
81
|
+
return {
|
|
82
|
+
builtins: {
|
|
83
|
+
'http://example.org/test#ok-builtins': ({ subst }) => [subst],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function makeOkDefaultMapModule() {
|
|
89
|
+
return {
|
|
90
|
+
default: {
|
|
91
|
+
'http://example.org/test#ok-default-map': ({ subst }) => [subst],
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function makeBadExportModule() {
|
|
97
|
+
return 42;
|
|
98
|
+
}
|
|
99
|
+
|
|
67
100
|
const cases = [
|
|
68
101
|
{
|
|
69
102
|
name: 'builtin helper API stays stable and frozen',
|
|
@@ -80,23 +113,17 @@ const cases = [
|
|
|
80
113
|
{
|
|
81
114
|
name: 'registerBuiltinModule accepts supported module export forms',
|
|
82
115
|
run() {
|
|
83
|
-
assert.doesNotThrow(() => builtins.registerBuiltinModule(
|
|
84
|
-
assert.doesNotThrow(() =>
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
assert.doesNotThrow(() =>
|
|
88
|
-
builtins.registerBuiltinModule(require(path.join(fixtures, 'ok-builtins.js')), 'ok-builtins'),
|
|
89
|
-
);
|
|
90
|
-
assert.doesNotThrow(() =>
|
|
91
|
-
builtins.registerBuiltinModule(require(path.join(fixtures, 'ok-default-map.js')), 'ok-default-map'),
|
|
92
|
-
);
|
|
116
|
+
assert.doesNotThrow(() => builtins.registerBuiltinModule(makeOkMapModule(), 'ok-map'));
|
|
117
|
+
assert.doesNotThrow(() => builtins.registerBuiltinModule(makeOkRegisterModule(), 'ok-register'));
|
|
118
|
+
assert.doesNotThrow(() => builtins.registerBuiltinModule(makeOkBuiltinsModule(), 'ok-builtins'));
|
|
119
|
+
assert.doesNotThrow(() => builtins.registerBuiltinModule(makeOkDefaultMapModule(), 'ok-default-map'));
|
|
93
120
|
},
|
|
94
121
|
},
|
|
95
122
|
{
|
|
96
123
|
name: 'registerBuiltinModule rejects unsupported module exports',
|
|
97
124
|
run() {
|
|
98
125
|
assert.throws(
|
|
99
|
-
() => builtins.registerBuiltinModule(
|
|
126
|
+
() => builtins.registerBuiltinModule(makeBadExportModule(), 'bad-export'),
|
|
100
127
|
/must export a function, a \{ register\(\) \} object, or an object mapping predicate IRIs to handlers/,
|
|
101
128
|
);
|
|
102
129
|
},
|