eyeprolog 1.5.44 → 1.5.45
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/package.json +1 -1
- package/src/iso.js +1 -1
- package/test/run-iso-strict.mjs +33 -0
- package/test/run-regression.mjs +14 -0
package/package.json
CHANGED
package/src/iso.js
CHANGED
|
@@ -2688,7 +2688,7 @@ function validateControlCallable(term, culprit, env) {
|
|
|
2688
2688
|
// eagerly and reports the whole control term as the culprit.
|
|
2689
2689
|
if (argument.type === VAR) continue;
|
|
2690
2690
|
if (argument.type !== ATOM && argument.type !== COMPOUND) {
|
|
2691
|
-
throw new PrologError('type_error(callable)', culprit);
|
|
2691
|
+
throw new PrologError('type_error(callable)', copyResolved(culprit, env));
|
|
2692
2692
|
}
|
|
2693
2693
|
pending.push(argument);
|
|
2694
2694
|
}
|
package/test/run-iso-strict.mjs
CHANGED
|
@@ -72,6 +72,29 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
72
72
|
'type_error(float)', 'negative integer exponent correction');
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
reporter.test('round-trips ISO floats through number_chars/2 and quoted write_term/2', () => {
|
|
76
|
+
for (const literal of ['1.0000000000000001', '0.10000000000000002']) {
|
|
77
|
+
const converted = run('', {
|
|
78
|
+
isoStrict: true,
|
|
79
|
+
goal: `N=${literal}, number_chars(N,Chars), number_chars(M,Chars), M == N`,
|
|
80
|
+
});
|
|
81
|
+
equal(converted.stats.completed_goal_lists, 1, `number_chars/2 float round-trip ${literal}`);
|
|
82
|
+
|
|
83
|
+
let written = '';
|
|
84
|
+
run('', {
|
|
85
|
+
isoStrict: true,
|
|
86
|
+
goal: `write_term(${literal},[quoted(true)])`,
|
|
87
|
+
ioOptions: { write: (text) => { written += text; } },
|
|
88
|
+
});
|
|
89
|
+
const reread = run('', {
|
|
90
|
+
isoStrict: true,
|
|
91
|
+
goal: `read_term(X,[]), X == ${literal}`,
|
|
92
|
+
ioOptions: { input: `${written}.` },
|
|
93
|
+
});
|
|
94
|
+
equal(reread.stats.completed_goal_lists, 1, `quoted write_term/2 float round-trip ${literal}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
75
98
|
reporter.test('keeps Corrigendum 2 core predicates and excludes Part 3 phrase', () => {
|
|
76
99
|
const registry = createStrictIsoRegistry();
|
|
77
100
|
equal(Boolean(registry.get('subsumes_term', 2)), true, 'subsumes_term/2');
|
|
@@ -1250,6 +1273,16 @@ export function runIsoStrict(reporter = new TestReporter()) {
|
|
|
1250
1273
|
'if-then-else commits after a successful condition');
|
|
1251
1274
|
equal(capture(() => run('', { isoStrict: true, goal: 'call((write(a),3))' })).formal,
|
|
1252
1275
|
'type_error(callable)', 'nested non-callable control term is rejected');
|
|
1276
|
+
let issue93Output = '';
|
|
1277
|
+
const issue93Error = capture(() => run('', {
|
|
1278
|
+
isoStrict: true,
|
|
1279
|
+
goal: 'X=3,Y=(write(X),X),call(Y)',
|
|
1280
|
+
ioOptions: { write: (chunk) => { issue93Output += chunk; } },
|
|
1281
|
+
}));
|
|
1282
|
+
equal(issue93Error.formal, 'type_error(callable)', 'issue #93 raises the ISO callability error');
|
|
1283
|
+
equal(issue93Error.message, 'error(type_error(callable), (write(3), 3))',
|
|
1284
|
+
'issue #93 reports the fully instantiated control-term culprit');
|
|
1285
|
+
equal(issue93Output, '', 'issue #93 validates the complete body before executing write/1');
|
|
1253
1286
|
equal(run('', {
|
|
1254
1287
|
isoStrict: true,
|
|
1255
1288
|
goal: 'catch(X,error(instantiation_error,_),true)',
|
package/test/run-regression.mjs
CHANGED
|
@@ -1618,6 +1618,20 @@ c4 ?- call((!;1)).
|
|
|
1618
1618
|
assertEqual(result.stderr, '', 'stderr');
|
|
1619
1619
|
},
|
|
1620
1620
|
},
|
|
1621
|
+
{
|
|
1622
|
+
name: 'call/1 reports the instantiated complete control-term culprit (issue #93)',
|
|
1623
|
+
run: () => {
|
|
1624
|
+
const result = runCli([], {
|
|
1625
|
+
input: 'X = 3, Y = (write(X), X), call(Y).\nhalt.\n',
|
|
1626
|
+
});
|
|
1627
|
+
assertEqual(result.status, 0, 'exit status');
|
|
1628
|
+
assertEqual(result.stdout,
|
|
1629
|
+
'?- error(type_error(callable, (write(3), 3)), eyeprolog).\n' +
|
|
1630
|
+
'?- ',
|
|
1631
|
+
'fully instantiated call/1 culprit');
|
|
1632
|
+
assertEqual(result.stderr, '', 'stderr');
|
|
1633
|
+
},
|
|
1634
|
+
},
|
|
1621
1635
|
{
|
|
1622
1636
|
name: 'number_chars and number_codes keep exponent floats syntactically readable (issue #50)',
|
|
1623
1637
|
run: () => {
|