eyeprolog 1.2.32 → 1.2.33
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/lib/clpz.pl +35 -33
- package/test/run-regression.mjs +31 -0
package/package.json
CHANGED
package/src/lib/clpz.pl
CHANGED
|
@@ -7,22 +7,24 @@
|
|
|
7
7
|
constraints will be added as their propagation semantics become available.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
% Current operator names in predicate indicators are parenthesized as bare
|
|
11
|
+
% atoms (for example, (#>)/2); quoting is unnecessary.
|
|
10
12
|
:- module(clpz, [
|
|
11
|
-
(
|
|
12
|
-
(
|
|
13
|
-
(
|
|
14
|
-
(
|
|
15
|
-
(
|
|
16
|
-
(
|
|
17
|
-
(
|
|
18
|
-
(
|
|
19
|
-
(
|
|
20
|
-
(
|
|
21
|
-
(
|
|
22
|
-
(
|
|
23
|
-
(
|
|
24
|
-
(
|
|
25
|
-
(
|
|
13
|
+
(#>)/2,
|
|
14
|
+
(#<)/2,
|
|
15
|
+
(#>=)/2,
|
|
16
|
+
(#=<)/2,
|
|
17
|
+
(#=)/2,
|
|
18
|
+
(#\=)/2,
|
|
19
|
+
(#\)/1,
|
|
20
|
+
(#<==>)/2,
|
|
21
|
+
(#==>)/2,
|
|
22
|
+
(#<==)/2,
|
|
23
|
+
(#\/)/2,
|
|
24
|
+
(#\)/2,
|
|
25
|
+
(#/\)/2,
|
|
26
|
+
(in)/2,
|
|
27
|
+
(ins)/2,
|
|
26
28
|
all_different/1,
|
|
27
29
|
all_distinct/1,
|
|
28
30
|
nvalue/2,
|
|
@@ -50,33 +52,33 @@
|
|
|
50
52
|
:- op(760, yfx, #<==>).
|
|
51
53
|
:- op(750, xfy, #==>).
|
|
52
54
|
:- op(750, yfx, #<==).
|
|
53
|
-
:- op(740, yfx,
|
|
54
|
-
:- op(730, yfx,
|
|
55
|
-
:- op(720, yfx,
|
|
56
|
-
:- op(710, fy,
|
|
55
|
+
:- op(740, yfx, #\/).
|
|
56
|
+
:- op(730, yfx, #\).
|
|
57
|
+
:- op(720, yfx, #/\).
|
|
58
|
+
:- op(710, fy, #\).
|
|
57
59
|
:- op(700, xfx, #>).
|
|
58
60
|
:- op(700, xfx, #<).
|
|
59
61
|
:- op(700, xfx, #>=).
|
|
60
62
|
:- op(700, xfx, #=<).
|
|
61
63
|
:- op(700, xfx, #=).
|
|
62
|
-
:- op(700, xfx,
|
|
64
|
+
:- op(700, xfx, #\=).
|
|
63
65
|
:- op(700, xfx, in).
|
|
64
66
|
:- op(700, xfx, ins).
|
|
65
67
|
:- op(450, xfx, ..).
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
#>(Left, Right) :- eyeprolog__clpz_post(#>(Left, Right)).
|
|
70
|
+
#<(Left, Right) :- eyeprolog__clpz_post(#<(Left, Right)).
|
|
71
|
+
#>=(Left, Right) :- eyeprolog__clpz_post(#>=(Left, Right)).
|
|
72
|
+
#=<(Left, Right) :- eyeprolog__clpz_post(#=<(Left, Right)).
|
|
73
|
+
#=(Left, Right) :- eyeprolog__clpz_post(#=(Left, Right)).
|
|
74
|
+
#\=(Left, Right) :- eyeprolog__clpz_post(#\=(Left, Right)).
|
|
75
|
+
#\(Constraint) :- eyeprolog__clpz_post(#\(Constraint)).
|
|
76
|
+
#<==>(Left, Right) :- eyeprolog__clpz_post(#<==>(Left, Right)).
|
|
77
|
+
#==>(Left, Right) :- eyeprolog__clpz_post(#==>(Left, Right)).
|
|
78
|
+
#<==(Left, Right) :- eyeprolog__clpz_post(#<==(Left, Right)).
|
|
79
|
+
#\/(Left, Right) :- eyeprolog__clpz_post(#\/(Left, Right)).
|
|
80
|
+
#\(Left, Right) :- eyeprolog__clpz_post(#\(Left, Right)).
|
|
81
|
+
#/\(Left, Right) :- eyeprolog__clpz_post(#/\(Left, Right)).
|
|
80
82
|
|
|
81
83
|
in(Integer, Domain) :- eyeprolog__clpz_in(Integer, Domain).
|
|
82
84
|
ins(Integers, Domain) :- eyeprolog__clpz_ins(Integers, Domain).
|
package/test/run-regression.mjs
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from '../src/index.js';
|
|
41
41
|
import { parseGoalText, parseNumberTokenText } from '../src/parser.js';
|
|
42
42
|
import { compareTerms } from '../src/term.js';
|
|
43
|
+
import { formatTermForWrite } from '../src/write.js';
|
|
43
44
|
import { selectClauseCandidates } from '../src/program.js';
|
|
44
45
|
import { TestReporter, isMainModule } from './test-style.mjs';
|
|
45
46
|
import { buildConformanceReport, formatConformanceReport } from './run-conformance-report.mjs';
|
|
@@ -730,6 +731,36 @@ c4 ?- call((!;1)).
|
|
|
730
731
|
assertIncludes(caught.message, 'operator atom', 'syntax rejection');
|
|
731
732
|
},
|
|
732
733
|
},
|
|
734
|
+
{
|
|
735
|
+
name: 'CLP(Z) operator declarations avoid unnecessary quoted atoms',
|
|
736
|
+
run: () => {
|
|
737
|
+
const filename = path.join(packageRoot, 'src', 'lib', 'clpz.pl');
|
|
738
|
+
const source = fs.readFileSync(filename, 'utf8');
|
|
739
|
+
for (const name of ['#>', '#<', '#>=', '#=<', '#=', '#\\=', '#<==>', '#==>', '#<==', '#\\/', '#/\\']) {
|
|
740
|
+
assertIncludes(source, `(${name})/2`, `${name}/2 export is parenthesized`);
|
|
741
|
+
assertNotIncludes(source, `('${name}')/2`, `${name}/2 export is not quoted`);
|
|
742
|
+
assertNotIncludes(source, `'${name}'(`, `${name} functional notation is not quoted`);
|
|
743
|
+
}
|
|
744
|
+
assertIncludes(source, '(#\\)/1', '#\\/1 export is parenthesized');
|
|
745
|
+
assertIncludes(source, '(#\\)/2', '#\\/2 export is parenthesized');
|
|
746
|
+
assertIncludes(source, '(in)/2', 'in/2 export is parenthesized');
|
|
747
|
+
assertIncludes(source, '(ins)/2', 'ins/2 export is parenthesized');
|
|
748
|
+
assertNotIncludes(source, "('in')/2", 'in/2 export is not quoted');
|
|
749
|
+
assertNotIncludes(source, "('ins')/2", 'ins/2 export is not quoted');
|
|
750
|
+
|
|
751
|
+
const canonicalOptions = { quoted: true, ignoreOps: true, compact: true, operators: [] };
|
|
752
|
+
assertEqual(
|
|
753
|
+
formatTermForWrite(compound('#>', [atom('a'), atom('b')]), new Env(), canonicalOptions),
|
|
754
|
+
'#>(a,b)',
|
|
755
|
+
'canonical #> functor has no quotes',
|
|
756
|
+
);
|
|
757
|
+
assertEqual(
|
|
758
|
+
formatTermForWrite(compound('#\\=', [atom('a'), atom('b')]), new Env(), canonicalOptions),
|
|
759
|
+
'#\\=(a,b)',
|
|
760
|
+
'canonical #\\= functor has no quotes',
|
|
761
|
+
);
|
|
762
|
+
},
|
|
763
|
+
},
|
|
733
764
|
{
|
|
734
765
|
name: 'layout distinguishes prefix notation from functional notation',
|
|
735
766
|
run: () => {
|