@mojir/lits 2.1.40 → 2.1.41
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/README.md +8 -8
- package/dist/cli/cli.js +849 -229
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +2 -2
- package/dist/cli/src/builtin/bindingNode.d.ts +1 -1
- package/dist/cli/src/parser/Parser.d.ts +1 -1
- package/dist/cli/src/parser/types.d.ts +1 -1
- package/dist/full.esm.js +1 -1
- package/dist/full.esm.js.map +1 -1
- package/dist/full.js +1 -1
- package/dist/full.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1 -1
- package/dist/lits.iife.js.map +1 -1
- package/dist/modules/assert.esm.js +1 -1
- package/dist/modules/assert.esm.js.map +1 -1
- package/dist/modules/assert.js +1 -1
- package/dist/modules/assert.js.map +1 -1
- package/dist/modules/grid.esm.js +1 -1
- package/dist/modules/grid.esm.js.map +1 -1
- package/dist/modules/grid.js +1 -1
- package/dist/modules/grid.js.map +1 -1
- package/dist/modules/linearAlgebra.esm.js +1 -1
- package/dist/modules/linearAlgebra.esm.js.map +1 -1
- package/dist/modules/linearAlgebra.js +1 -1
- package/dist/modules/linearAlgebra.js.map +1 -1
- package/dist/modules/matrix.esm.js +1 -1
- package/dist/modules/matrix.esm.js.map +1 -1
- package/dist/modules/matrix.js +1 -1
- package/dist/modules/matrix.js.map +1 -1
- package/dist/modules/numberTheory.esm.js +1 -1
- package/dist/modules/numberTheory.esm.js.map +1 -1
- package/dist/modules/numberTheory.js +1 -1
- package/dist/modules/numberTheory.js.map +1 -1
- package/dist/modules/reference/api.d.ts +4 -4
- package/dist/modules/reference/index.d.ts +2 -2
- package/dist/modules/src/builtin/bindingNode.d.ts +1 -1
- package/dist/modules/src/full.d.ts +1 -14
- package/dist/modules/src/parser/Parser.d.ts +1 -1
- package/dist/modules/src/parser/types.d.ts +1 -1
- package/dist/modules/vector.esm.js +1 -1
- package/dist/modules/vector.esm.js.map +1 -1
- package/dist/modules/vector.js +1 -1
- package/dist/modules/vector.js.map +1 -1
- package/dist/reference/api.d.ts +4 -4
- package/dist/reference/index.d.ts +2 -2
- package/dist/src/builtin/bindingNode.d.ts +1 -1
- package/dist/src/full.d.ts +1 -14
- package/dist/src/parser/Parser.d.ts +1 -1
- package/dist/src/parser/types.d.ts +1 -1
- package/dist/testFramework.esm.js +1 -1
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +1 -1
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var readline = require('node:readline');
|
|
|
7
7
|
var os = require('node:os');
|
|
8
8
|
var process$1 = require('node:process');
|
|
9
9
|
|
|
10
|
-
var version = "2.1.
|
|
10
|
+
var version = "2.1.41";
|
|
11
11
|
|
|
12
12
|
function getCodeMarker(sourceCodeInfo) {
|
|
13
13
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -4086,8 +4086,11 @@ function partition(n, step, seq, pad, sourceCodeInfo) {
|
|
|
4086
4086
|
|
|
4087
4087
|
const annotatedArrays = new WeakSet();
|
|
4088
4088
|
const vectors = new WeakSet();
|
|
4089
|
+
const notVectors = new WeakSet();
|
|
4089
4090
|
const matrices = new WeakSet();
|
|
4091
|
+
const notMatrices = new WeakSet();
|
|
4090
4092
|
const grids = new WeakSet();
|
|
4093
|
+
const notGrids = new WeakSet();
|
|
4091
4094
|
function annotate(value) {
|
|
4092
4095
|
if (!Array.isArray(value)) {
|
|
4093
4096
|
return value;
|
|
@@ -4108,11 +4111,15 @@ function isVector(vector) {
|
|
|
4108
4111
|
if (vectors.has(vector)) {
|
|
4109
4112
|
return true;
|
|
4110
4113
|
}
|
|
4114
|
+
if (notVectors.has(vector)) {
|
|
4115
|
+
return false;
|
|
4116
|
+
}
|
|
4111
4117
|
if (vector.every(elem => isNumber(elem))) {
|
|
4112
4118
|
annotatedArrays.add(vector);
|
|
4113
4119
|
vectors.add(vector);
|
|
4114
4120
|
return true;
|
|
4115
4121
|
}
|
|
4122
|
+
notVectors.add(vector);
|
|
4116
4123
|
return false;
|
|
4117
4124
|
}
|
|
4118
4125
|
function assertVector(vector, sourceCodeInfo) {
|
|
@@ -4155,18 +4162,25 @@ function isGrid(grid) {
|
|
|
4155
4162
|
if (grids.has(grid)) {
|
|
4156
4163
|
return true;
|
|
4157
4164
|
}
|
|
4165
|
+
if (notGrids.has(grid)) {
|
|
4166
|
+
return false;
|
|
4167
|
+
}
|
|
4158
4168
|
if (grid.length === 0) {
|
|
4169
|
+
notGrids.add(grid);
|
|
4159
4170
|
return false;
|
|
4160
4171
|
}
|
|
4161
4172
|
if (!Array.isArray(grid[0])) {
|
|
4173
|
+
notGrids.add(grid);
|
|
4162
4174
|
return false;
|
|
4163
4175
|
}
|
|
4164
4176
|
const nbrOfCols = grid[0].length;
|
|
4165
4177
|
for (const row of grid.slice(1)) {
|
|
4166
4178
|
if (!Array.isArray(row)) {
|
|
4179
|
+
notGrids.add(grid);
|
|
4167
4180
|
return false;
|
|
4168
4181
|
}
|
|
4169
4182
|
if (row.length !== nbrOfCols) {
|
|
4183
|
+
notGrids.add(grid);
|
|
4170
4184
|
return false;
|
|
4171
4185
|
}
|
|
4172
4186
|
}
|
|
@@ -4186,24 +4200,21 @@ function isMatrix(matrix) {
|
|
|
4186
4200
|
if (matrices.has(matrix)) {
|
|
4187
4201
|
return true;
|
|
4188
4202
|
}
|
|
4189
|
-
if (matrix
|
|
4203
|
+
if (notMatrices.has(matrix)) {
|
|
4190
4204
|
return false;
|
|
4191
4205
|
}
|
|
4192
|
-
if (
|
|
4206
|
+
if (matrix.length === 0) {
|
|
4207
|
+
notMatrices.add(matrix);
|
|
4193
4208
|
return false;
|
|
4194
4209
|
}
|
|
4195
|
-
if (matrix[0].length === 0) {
|
|
4210
|
+
if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {
|
|
4211
|
+
notMatrices.add(matrix);
|
|
4196
4212
|
return false;
|
|
4197
4213
|
}
|
|
4198
4214
|
const nbrOfCols = matrix[0].length;
|
|
4199
|
-
for (const row of matrix
|
|
4200
|
-
if (!Array.isArray(row)) {
|
|
4201
|
-
|
|
4202
|
-
}
|
|
4203
|
-
if (row.length !== nbrOfCols) {
|
|
4204
|
-
return false;
|
|
4205
|
-
}
|
|
4206
|
-
if (row.some(cell => !isNumber(cell))) {
|
|
4215
|
+
for (const row of matrix) {
|
|
4216
|
+
if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {
|
|
4217
|
+
notMatrices.add(matrix);
|
|
4207
4218
|
return false;
|
|
4208
4219
|
}
|
|
4209
4220
|
}
|
|
@@ -6095,7 +6106,7 @@ const predicatesNormalExpression = {
|
|
|
6095
6106
|
args: { x: { type: 'any' } },
|
|
6096
6107
|
variants: [{ argumentNames: ['x'] }],
|
|
6097
6108
|
description: 'Returns `true` if $x is a string, otherwise `false`.',
|
|
6098
|
-
seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', '
|
|
6109
|
+
seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', 'collection?', 'sequence?'],
|
|
6099
6110
|
examples: [
|
|
6100
6111
|
'string?("")',
|
|
6101
6112
|
'string?("A string")',
|
|
@@ -6302,7 +6313,7 @@ const predicatesNormalExpression = {
|
|
|
6302
6313
|
args: { x: { type: 'any' } },
|
|
6303
6314
|
variants: [{ argumentNames: ['x'] }],
|
|
6304
6315
|
description: 'Returns `true` if $x is an array, otherwise `false`.',
|
|
6305
|
-
seeAlso: ['
|
|
6316
|
+
seeAlso: ['sequence?', 'collection?', 'object?', 'string?', 'vector?', 'matrix?', 'grid?', 'function?'],
|
|
6306
6317
|
examples: [
|
|
6307
6318
|
'array?([])',
|
|
6308
6319
|
'array?([1, 2, 3])',
|
|
@@ -6313,7 +6324,7 @@ const predicatesNormalExpression = {
|
|
|
6313
6324
|
],
|
|
6314
6325
|
},
|
|
6315
6326
|
},
|
|
6316
|
-
'
|
|
6327
|
+
'collection?': {
|
|
6317
6328
|
evaluate: ([first]) => {
|
|
6318
6329
|
return isColl(first);
|
|
6319
6330
|
},
|
|
@@ -6323,20 +6334,20 @@ const predicatesNormalExpression = {
|
|
|
6323
6334
|
returns: { type: 'boolean' },
|
|
6324
6335
|
args: { x: { type: 'any' } },
|
|
6325
6336
|
variants: [{ argumentNames: ['x'] }],
|
|
6326
|
-
description: 'Returns `true` if $x is a
|
|
6327
|
-
seeAlso: ['
|
|
6337
|
+
description: 'Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.',
|
|
6338
|
+
seeAlso: ['sequence?', 'array?', 'object?', 'string?'],
|
|
6328
6339
|
examples: [
|
|
6329
|
-
'
|
|
6330
|
-
'
|
|
6331
|
-
'
|
|
6332
|
-
'
|
|
6333
|
-
'
|
|
6334
|
-
'
|
|
6335
|
-
'
|
|
6340
|
+
'collection?([])',
|
|
6341
|
+
'collection?([1, 2, 3])',
|
|
6342
|
+
'collection?(object("a", 10))',
|
|
6343
|
+
'collection?("Albert")',
|
|
6344
|
+
'collection?(42)',
|
|
6345
|
+
'collection?(10.1)',
|
|
6346
|
+
'collection?((x, y) -> x + y)',
|
|
6336
6347
|
],
|
|
6337
6348
|
},
|
|
6338
6349
|
},
|
|
6339
|
-
'
|
|
6350
|
+
'sequence?': {
|
|
6340
6351
|
evaluate: ([first]) => {
|
|
6341
6352
|
return isSeq(first);
|
|
6342
6353
|
},
|
|
@@ -6346,16 +6357,16 @@ const predicatesNormalExpression = {
|
|
|
6346
6357
|
returns: { type: 'boolean' },
|
|
6347
6358
|
args: { x: { type: 'any' } },
|
|
6348
6359
|
variants: [{ argumentNames: ['x'] }],
|
|
6349
|
-
description: 'Returns `true` if $x is a
|
|
6350
|
-
seeAlso: ['
|
|
6360
|
+
description: 'Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.',
|
|
6361
|
+
seeAlso: ['collection?', 'array?', 'string?'],
|
|
6351
6362
|
examples: [
|
|
6352
|
-
'
|
|
6353
|
-
'
|
|
6354
|
-
'
|
|
6355
|
-
'
|
|
6356
|
-
'
|
|
6357
|
-
'
|
|
6358
|
-
'
|
|
6363
|
+
'sequence?([])',
|
|
6364
|
+
'sequence?([1, 2, 3])',
|
|
6365
|
+
'sequence?(object("a", 10))',
|
|
6366
|
+
'sequence?("Albert")',
|
|
6367
|
+
'sequence?(42)',
|
|
6368
|
+
'sequence?(10.1)',
|
|
6369
|
+
'sequence?((x, y) -> x + y)',
|
|
6359
6370
|
],
|
|
6360
6371
|
},
|
|
6361
6372
|
},
|
|
@@ -6368,7 +6379,7 @@ const predicatesNormalExpression = {
|
|
|
6368
6379
|
args: { x: { type: 'any' } },
|
|
6369
6380
|
variants: [{ argumentNames: ['x'] }],
|
|
6370
6381
|
description: 'Returns `true` if $x is an object, otherwise `false`.',
|
|
6371
|
-
seeAlso: ['
|
|
6382
|
+
seeAlso: ['collection?', 'array?', 'string?', 'function?'],
|
|
6372
6383
|
examples: [
|
|
6373
6384
|
'object?(object("a", 10))',
|
|
6374
6385
|
'object?(42)',
|
|
@@ -8059,7 +8070,7 @@ function walkDefaults(bindingTarget, onDefault) {
|
|
|
8059
8070
|
}
|
|
8060
8071
|
}
|
|
8061
8072
|
}
|
|
8062
|
-
function
|
|
8073
|
+
function evaluateBindingNodeValues(target, value, evaluate) {
|
|
8063
8074
|
const sourceCodeInfo = target[2];
|
|
8064
8075
|
const record = {};
|
|
8065
8076
|
createRecord(target, value, evaluate, sourceCodeInfo, record);
|
|
@@ -8159,7 +8170,7 @@ const defSpecialExpression = {
|
|
|
8159
8170
|
const target = bindingNode[1][0];
|
|
8160
8171
|
const value = bindingNode[1][1];
|
|
8161
8172
|
const bindingValue = evaluateNode(value, contextStack);
|
|
8162
|
-
const values =
|
|
8173
|
+
const values = evaluateBindingNodeValues(target, bindingValue, Node => evaluateNode(Node, contextStack));
|
|
8163
8174
|
contextStack.exportValues(values, target[2]);
|
|
8164
8175
|
return bindingValue;
|
|
8165
8176
|
},
|
|
@@ -8366,7 +8377,7 @@ const letSpecialExpression = {
|
|
|
8366
8377
|
const target = bindingNode[1][0];
|
|
8367
8378
|
const value = bindingNode[1][1];
|
|
8368
8379
|
const bindingValue = evaluateNode(value, contextStack);
|
|
8369
|
-
const values =
|
|
8380
|
+
const values = evaluateBindingNodeValues(target, bindingValue, Node => evaluateNode(Node, contextStack));
|
|
8370
8381
|
contextStack.addValues(values, target[2]);
|
|
8371
8382
|
return bindingValue;
|
|
8372
8383
|
},
|
|
@@ -8417,7 +8428,7 @@ const loopSpecialExpression = {
|
|
|
8417
8428
|
const bindingNodes = node[1][1];
|
|
8418
8429
|
const bindingContext = bindingNodes.reduce((result, bindingNode) => {
|
|
8419
8430
|
const val = evaluateNode(bindingNode[1][1], contextStack.create(result));
|
|
8420
|
-
const valueRecord =
|
|
8431
|
+
const valueRecord = evaluateBindingNodeValues(bindingNode[1][0], val, Node => evaluateNode(Node, contextStack));
|
|
8421
8432
|
Object.entries(valueRecord).forEach(([name, value]) => {
|
|
8422
8433
|
result[name] = { value };
|
|
8423
8434
|
});
|
|
@@ -8437,7 +8448,7 @@ const loopSpecialExpression = {
|
|
|
8437
8448
|
throw new LitsError(`recur expected ${bindingNodes.length} parameters, got ${valueToString(params.length)}`, node[2]);
|
|
8438
8449
|
}
|
|
8439
8450
|
bindingNodes.forEach((bindingNode, index) => {
|
|
8440
|
-
const valueRecord =
|
|
8451
|
+
const valueRecord = evaluateBindingNodeValues(bindingNode[1][0], asAny(params[index]), Node => evaluateNode(Node, contextStack));
|
|
8441
8452
|
for (const [name, value] of Object.entries(valueRecord)) {
|
|
8442
8453
|
bindingContext[name].value = value;
|
|
8443
8454
|
}
|
|
@@ -8470,7 +8481,7 @@ function addToContext(bindings, context, contextStack, evaluateNode) {
|
|
|
8470
8481
|
for (const bindingNode of bindings) {
|
|
8471
8482
|
const [target, bindingValue] = bindingNode[1];
|
|
8472
8483
|
const val = evaluateNode(bindingValue, contextStack);
|
|
8473
|
-
const valueRecord =
|
|
8484
|
+
const valueRecord = evaluateBindingNodeValues(target, val, Node => evaluateNode(Node, contextStack));
|
|
8474
8485
|
Object.entries(valueRecord).forEach(([name, value]) => {
|
|
8475
8486
|
context[name] = { value };
|
|
8476
8487
|
});
|
|
@@ -8508,7 +8519,7 @@ function evaluateLoop(returnResult, loopNode, contextStack, evaluateNode) {
|
|
|
8508
8519
|
break;
|
|
8509
8520
|
}
|
|
8510
8521
|
const val = asAny(seq[index], sourceCodeInfo);
|
|
8511
|
-
const valueRecord =
|
|
8522
|
+
const valueRecord = evaluateBindingNodeValues(targetNode, val, Node => evaluateNode(Node, newContextStack));
|
|
8512
8523
|
Object.entries(valueRecord).forEach(([name, value]) => {
|
|
8513
8524
|
context[name] = { value };
|
|
8514
8525
|
});
|
|
@@ -9027,12 +9038,10 @@ const specialExpressions = [
|
|
|
9027
9038
|
condSpecialExpression,
|
|
9028
9039
|
defSpecialExpression,
|
|
9029
9040
|
definedSpecialExpression,
|
|
9030
|
-
// defnSpecialExpression,
|
|
9031
9041
|
doSpecialExpression,
|
|
9032
9042
|
doseqSpecialExpression,
|
|
9033
9043
|
lambdaSpecialExpression,
|
|
9034
9044
|
forSpecialExpression,
|
|
9035
|
-
// functionSpecialExpression,
|
|
9036
9045
|
ifSpecialExpression,
|
|
9037
9046
|
letSpecialExpression,
|
|
9038
9047
|
loopSpecialExpression,
|
|
@@ -9114,7 +9123,7 @@ const functionExecutors = {
|
|
|
9114
9123
|
: isUnknownRecord(error) && typeof error.message === 'string'
|
|
9115
9124
|
? error.message
|
|
9116
9125
|
: '<no message>';
|
|
9117
|
-
throw new LitsError(`Native function
|
|
9126
|
+
throw new LitsError(`Native function threw: "${message}"`, sourceCodeInfo);
|
|
9118
9127
|
}
|
|
9119
9128
|
},
|
|
9120
9129
|
UserDefined: (fn, params, sourceCodeInfo, contextStack, { evaluateNode }) => {
|
|
@@ -9122,7 +9131,6 @@ const functionExecutors = {
|
|
|
9122
9131
|
if (!arityAcceptsMin(fn.arity, params.length)) {
|
|
9123
9132
|
throw new LitsError(`Expected ${fn.arity} arguments, got ${params.length}.`, sourceCodeInfo);
|
|
9124
9133
|
}
|
|
9125
|
-
// checkParams(fn.evaluatedfunction, params.length, sourceCodeInfo)
|
|
9126
9134
|
const evaluatedFunction = fn.evaluatedfunction;
|
|
9127
9135
|
const args = evaluatedFunction[0];
|
|
9128
9136
|
const nbrOfNonRestArgs = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length;
|
|
@@ -9132,7 +9140,7 @@ const functionExecutors = {
|
|
|
9132
9140
|
for (let i = 0; i < params.length; i += 1) {
|
|
9133
9141
|
if (i < nbrOfNonRestArgs) {
|
|
9134
9142
|
const param = toAny(params[i]);
|
|
9135
|
-
const valueRecord =
|
|
9143
|
+
const valueRecord = evaluateBindingNodeValues(args[i], param, node => evaluateNode(node, newContextStack.create(newContext)));
|
|
9136
9144
|
Object.entries(valueRecord).forEach(([key, value]) => {
|
|
9137
9145
|
newContext[key] = { value };
|
|
9138
9146
|
});
|
|
@@ -9144,14 +9152,14 @@ const functionExecutors = {
|
|
|
9144
9152
|
for (let i = params.length; i < nbrOfNonRestArgs; i++) {
|
|
9145
9153
|
const arg = args[i];
|
|
9146
9154
|
const defaultValue = evaluateNode(arg[1][1], contextStack.create(newContext));
|
|
9147
|
-
const valueRecord =
|
|
9155
|
+
const valueRecord = evaluateBindingNodeValues(arg, defaultValue, node => evaluateNode(node, contextStack.create(newContext)));
|
|
9148
9156
|
Object.entries(valueRecord).forEach(([key, value]) => {
|
|
9149
9157
|
newContext[key] = { value };
|
|
9150
9158
|
});
|
|
9151
9159
|
}
|
|
9152
9160
|
const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest);
|
|
9153
9161
|
if (restArgument !== undefined) {
|
|
9154
|
-
const valueRecord =
|
|
9162
|
+
const valueRecord = evaluateBindingNodeValues(restArgument, rest, node => evaluateNode(node, contextStack.create(newContext)));
|
|
9155
9163
|
Object.entries(valueRecord).forEach(([key, value]) => {
|
|
9156
9164
|
newContext[key] = { value };
|
|
9157
9165
|
});
|
|
@@ -9229,7 +9237,7 @@ const functionExecutors = {
|
|
|
9229
9237
|
return executeFunction(asFunctionLike(fn.function, sourceCodeInfo), fnulledParams, contextStack, sourceCodeInfo);
|
|
9230
9238
|
},
|
|
9231
9239
|
Builtin: (fn, params, sourceCodeInfo, contextStack, { executeFunction }) => {
|
|
9232
|
-
const normalExpression = asNonUndefined(allNormalExpressions[fn.
|
|
9240
|
+
const normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuiltinSymbolType], sourceCodeInfo);
|
|
9233
9241
|
return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction });
|
|
9234
9242
|
},
|
|
9235
9243
|
SpecialBuiltin: (fn, params, sourceCodeInfo, contextStack, { executeFunction }) => {
|
|
@@ -9464,14 +9472,9 @@ class ContextStackImpl {
|
|
|
9464
9472
|
if (this.globalContext[name]) {
|
|
9465
9473
|
throw new LitsError(`Cannot redefine exported value "${name}"`, sourceCodeInfo);
|
|
9466
9474
|
}
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
if (normalExpressionKeys.includes(name)) {
|
|
9471
|
-
throw new LitsError(`Cannot shadow builtin function "${name}"`, sourceCodeInfo);
|
|
9472
|
-
}
|
|
9473
|
-
if (name === 'self') {
|
|
9474
|
-
throw new LitsError(`Cannot shadow builtin value "${name}"`, sourceCodeInfo);
|
|
9475
|
+
const shadowedName = getShadowedBuiltinName(name);
|
|
9476
|
+
if (shadowedName) {
|
|
9477
|
+
throw new LitsError(`Cannot shadow ${shadowedName}`, sourceCodeInfo);
|
|
9475
9478
|
}
|
|
9476
9479
|
this.globalContext[name] = { value };
|
|
9477
9480
|
}
|
|
@@ -9485,14 +9488,9 @@ class ContextStackImpl {
|
|
|
9485
9488
|
if (currentContext[name]) {
|
|
9486
9489
|
throw new LitsError(`Cannot redefine value "${name}"`, sourceCodeInfo);
|
|
9487
9490
|
}
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
if (normalExpressionKeys.includes(name)) {
|
|
9492
|
-
throw new LitsError(`Cannot shadow builtin function "${name}"`, sourceCodeInfo);
|
|
9493
|
-
}
|
|
9494
|
-
if (name === 'self') {
|
|
9495
|
-
throw new LitsError(`Cannot shadow builtin value "${name}"`, sourceCodeInfo);
|
|
9491
|
+
const shadowedName = getShadowedBuiltinName(name);
|
|
9492
|
+
if (shadowedName) {
|
|
9493
|
+
throw new LitsError(`Cannot shadow ${shadowedName}`, sourceCodeInfo);
|
|
9496
9494
|
}
|
|
9497
9495
|
currentContext[name] = { value: toAny(value) };
|
|
9498
9496
|
}
|
|
@@ -9561,7 +9559,7 @@ class ContextStackImpl {
|
|
|
9561
9559
|
return {
|
|
9562
9560
|
[FUNCTION_SYMBOL]: true,
|
|
9563
9561
|
functionType: 'Builtin',
|
|
9564
|
-
|
|
9562
|
+
normalBuiltinSymbolType: type,
|
|
9565
9563
|
sourceCodeInfo: node[2],
|
|
9566
9564
|
arity: normalExpression.arity,
|
|
9567
9565
|
name,
|
|
@@ -9573,20 +9571,20 @@ class ContextStackImpl {
|
|
|
9573
9571
|
throw new UndefinedSymbolError(node[1], node[2]);
|
|
9574
9572
|
}
|
|
9575
9573
|
}
|
|
9576
|
-
function
|
|
9577
|
-
if (specialExpressionKeys.includes(name))
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
if (
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9574
|
+
function getShadowedBuiltinName(name) {
|
|
9575
|
+
if (specialExpressionKeys.includes(name))
|
|
9576
|
+
return `special expression "${name}"`;
|
|
9577
|
+
if (normalExpressionKeys.includes(name))
|
|
9578
|
+
return `builtin function "${name}"`;
|
|
9579
|
+
if (name === 'self')
|
|
9580
|
+
return `builtin value "${name}"`;
|
|
9581
|
+
return null;
|
|
9582
|
+
}
|
|
9583
|
+
function assertNotShadowingBuiltin(name) {
|
|
9584
|
+
const shadowedName = getShadowedBuiltinName(name);
|
|
9585
|
+
if (shadowedName) {
|
|
9586
|
+
throw new LitsError(`Cannot shadow ${shadowedName}`, undefined);
|
|
9588
9587
|
}
|
|
9589
|
-
return true;
|
|
9590
9588
|
}
|
|
9591
9589
|
function createContextStack(params = {}, modules) {
|
|
9592
9590
|
const globalContext = params.globalContext ?? {};
|
|
@@ -9601,18 +9599,15 @@ function createContextStack(params = {}, modules) {
|
|
|
9601
9599
|
const identifierParts = identifier.split('.');
|
|
9602
9600
|
const name = identifierParts.pop();
|
|
9603
9601
|
if (/^[A-Z]/.test(name)) {
|
|
9604
|
-
|
|
9605
|
-
return acc;
|
|
9602
|
+
throw new LitsError(`Invalid identifier "${identifier}" in jsFunctions, function name must not start with an uppercase letter`, undefined);
|
|
9606
9603
|
}
|
|
9607
9604
|
let scope = acc;
|
|
9608
9605
|
for (const part of identifierParts) {
|
|
9609
9606
|
if (part.length === 0) {
|
|
9610
|
-
|
|
9611
|
-
return acc;
|
|
9607
|
+
throw new LitsError(`Invalid empty identifier "${identifier}" in jsFunctions`, undefined);
|
|
9612
9608
|
}
|
|
9613
9609
|
if (!/^[A-Z]/.test(part)) {
|
|
9614
|
-
|
|
9615
|
-
return acc;
|
|
9610
|
+
throw new LitsError(`Invalid identifier "${identifier}" in jsFunctions, module name must start with an uppercase letter`, undefined);
|
|
9616
9611
|
}
|
|
9617
9612
|
if (!scope[part]) {
|
|
9618
9613
|
scope[part] = {};
|
|
@@ -9620,7 +9615,7 @@ function createContextStack(params = {}, modules) {
|
|
|
9620
9615
|
scope = scope[part];
|
|
9621
9616
|
}
|
|
9622
9617
|
assertJsFunction(entry);
|
|
9623
|
-
const
|
|
9618
|
+
const nativeFn = {
|
|
9624
9619
|
functionType: 'NativeJsFunction',
|
|
9625
9620
|
nativeFn: entry,
|
|
9626
9621
|
name,
|
|
@@ -9628,10 +9623,10 @@ function createContextStack(params = {}, modules) {
|
|
|
9628
9623
|
arity: entry.arity ?? {},
|
|
9629
9624
|
docString: entry.docString ?? '',
|
|
9630
9625
|
};
|
|
9631
|
-
if (scope === acc
|
|
9632
|
-
|
|
9626
|
+
if (scope === acc) {
|
|
9627
|
+
assertNotShadowingBuiltin(name);
|
|
9633
9628
|
}
|
|
9634
|
-
scope[name] =
|
|
9629
|
+
scope[name] = nativeFn;
|
|
9635
9630
|
return acc;
|
|
9636
9631
|
}, {}),
|
|
9637
9632
|
});
|
|
@@ -10333,6 +10328,7 @@ function getSymbolName(symbol) {
|
|
|
10333
10328
|
const exponentiationPrecedence = 12;
|
|
10334
10329
|
const binaryFunctionalOperatorPrecedence = 3;
|
|
10335
10330
|
const conditionalOperatorPrecedence = 1;
|
|
10331
|
+
const maxShorthandLambdaArity = 20;
|
|
10336
10332
|
const placeholderRegexp = /^\$([1-9]\d?)?$/;
|
|
10337
10333
|
function withSourceCodeInfo(node, sourceCodeInfo) {
|
|
10338
10334
|
if (sourceCodeInfo) {
|
|
@@ -10637,7 +10633,7 @@ class Parser {
|
|
|
10637
10633
|
return withSourceCodeInfo([NodeTypes.NormalBuiltinSymbol, normalExpressionTypes[operatorName]], token[2]);
|
|
10638
10634
|
}
|
|
10639
10635
|
if (operatorName === '->') {
|
|
10640
|
-
return this.
|
|
10636
|
+
return this.parseShorthandLambdaFunction();
|
|
10641
10637
|
}
|
|
10642
10638
|
else {
|
|
10643
10639
|
throw new LitsError(`Illegal operator: ${operatorName}`, token[2]);
|
|
@@ -10803,7 +10799,7 @@ class Parser {
|
|
|
10803
10799
|
throw new LitsError(`Unknown special expression: ${type}`, symbol[2]);
|
|
10804
10800
|
}
|
|
10805
10801
|
}
|
|
10806
|
-
else if (isNormalBuiltinSymbolNode(symbol) ||
|
|
10802
|
+
else if (isNormalBuiltinSymbolNode(symbol) || isUserDefinedSymbolNode(symbol)) {
|
|
10807
10803
|
return createNamedNormalExpressionNode(symbol, params, symbol[2]);
|
|
10808
10804
|
}
|
|
10809
10805
|
else {
|
|
@@ -10887,7 +10883,7 @@ class Parser {
|
|
|
10887
10883
|
this.advance();
|
|
10888
10884
|
return functionArguments;
|
|
10889
10885
|
}
|
|
10890
|
-
|
|
10886
|
+
parseShorthandLambdaFunction() {
|
|
10891
10887
|
const firstToken = this.asToken(this.peek());
|
|
10892
10888
|
this.advance();
|
|
10893
10889
|
const startPos = this.parseState.position;
|
|
@@ -10917,7 +10913,7 @@ class Parser {
|
|
|
10917
10913
|
dollar1 = match[1] ? 'WITH_1' : 'NAKED';
|
|
10918
10914
|
}
|
|
10919
10915
|
arity = Math.max(arity, Number(number));
|
|
10920
|
-
if (arity >
|
|
10916
|
+
if (arity > maxShorthandLambdaArity)
|
|
10921
10917
|
throw new LitsError('Can\'t specify more than 20 arguments', firstToken[2]);
|
|
10922
10918
|
}
|
|
10923
10919
|
}
|
|
@@ -12053,16 +12049,558 @@ const moduleDocs$6 = {
|
|
|
12053
12049
|
},
|
|
12054
12050
|
],
|
|
12055
12051
|
examples: [
|
|
12056
|
-
'let { assert-true } = import("Assert");\ntry assert-true(false, "Expected true") catch (e) e.message end',
|
|
12057
|
-
'let { assert-true } = import("Assert");\ntry assert-true(false) catch (e) e.message end',
|
|
12058
|
-
'let { assert-true } = import("Assert");\ntry assert-true(true) catch (e) e.message end',
|
|
12052
|
+
'let { assert-true } = import("Assert");\ntry assert-true(false, "Expected true") catch (e) e.message end',
|
|
12053
|
+
'let { assert-true } = import("Assert");\ntry assert-true(false) catch (e) e.message end',
|
|
12054
|
+
'let { assert-true } = import("Assert");\ntry assert-true(true) catch (e) e.message end',
|
|
12055
|
+
],
|
|
12056
|
+
seeAlso: ['Assert.assert-false', 'Assert.assert-truthy', 'Assert.assert-falsy', 'Assert.assert', 'Assert.assert-boolean'],
|
|
12057
|
+
hideOperatorForm: true,
|
|
12058
|
+
},
|
|
12059
|
+
'assert-false': {
|
|
12060
|
+
category: 'Assert',
|
|
12061
|
+
description: 'If $value is not `false` it throws `AssertionError`.',
|
|
12062
|
+
returns: {
|
|
12063
|
+
type: 'null',
|
|
12064
|
+
},
|
|
12065
|
+
args: {
|
|
12066
|
+
value: {
|
|
12067
|
+
type: 'any',
|
|
12068
|
+
},
|
|
12069
|
+
message: {
|
|
12070
|
+
type: 'string',
|
|
12071
|
+
},
|
|
12072
|
+
},
|
|
12073
|
+
variants: [
|
|
12074
|
+
{
|
|
12075
|
+
argumentNames: [
|
|
12076
|
+
'value',
|
|
12077
|
+
],
|
|
12078
|
+
},
|
|
12079
|
+
{
|
|
12080
|
+
argumentNames: [
|
|
12081
|
+
'value',
|
|
12082
|
+
'message',
|
|
12083
|
+
],
|
|
12084
|
+
},
|
|
12085
|
+
],
|
|
12086
|
+
examples: [
|
|
12087
|
+
'let { assert-false } = import("Assert");\ntry assert-false(true, "Expected false") catch (e) e.message end',
|
|
12088
|
+
'let { assert-false } = import("Assert");\ntry assert-false(true) catch (e) e.message end',
|
|
12089
|
+
'let { assert-false } = import("Assert");\ntry assert-false(false) catch (e) e.message end',
|
|
12090
|
+
],
|
|
12091
|
+
seeAlso: ['Assert.assert-true', 'Assert.assert-falsy', 'Assert.assert-truthy', 'Assert.assert-boolean'],
|
|
12092
|
+
hideOperatorForm: true,
|
|
12093
|
+
},
|
|
12094
|
+
'assert-truthy': {
|
|
12095
|
+
category: 'Assert',
|
|
12096
|
+
description: 'If $value is not `truthy` it throws `AssertionError`.',
|
|
12097
|
+
returns: {
|
|
12098
|
+
type: 'null',
|
|
12099
|
+
},
|
|
12100
|
+
args: {
|
|
12101
|
+
value: {
|
|
12102
|
+
type: 'any',
|
|
12103
|
+
},
|
|
12104
|
+
message: {
|
|
12105
|
+
type: 'string',
|
|
12106
|
+
},
|
|
12107
|
+
},
|
|
12108
|
+
variants: [
|
|
12109
|
+
{
|
|
12110
|
+
argumentNames: [
|
|
12111
|
+
'value',
|
|
12112
|
+
],
|
|
12113
|
+
},
|
|
12114
|
+
{
|
|
12115
|
+
argumentNames: [
|
|
12116
|
+
'value',
|
|
12117
|
+
'message',
|
|
12118
|
+
],
|
|
12119
|
+
},
|
|
12120
|
+
],
|
|
12121
|
+
examples: [
|
|
12122
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(false, "Expected truthy") catch (e) e.message end',
|
|
12123
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(false) catch (e) e.message end',
|
|
12124
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(0) catch (e) e.message end',
|
|
12125
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(null) catch (e) e.message end',
|
|
12126
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy("") catch (e) e.message end',
|
|
12127
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(true) catch (e) e.message end',
|
|
12128
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(1) catch (e) e.message end',
|
|
12129
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy("x") catch (e) e.message end',
|
|
12130
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy([]) catch (e) e.message end',
|
|
12131
|
+
'let { assert-truthy } = import("Assert");\ntry assert-truthy(nd) catch (e) e.message end',
|
|
12132
|
+
],
|
|
12133
|
+
seeAlso: ['Assert.assert-falsy', 'Assert.assert-true', 'Assert.assert-false', 'Assert.assert', 'Assert.assert-null'],
|
|
12134
|
+
hideOperatorForm: true,
|
|
12135
|
+
},
|
|
12136
|
+
'assert-falsy': {
|
|
12137
|
+
category: 'Assert',
|
|
12138
|
+
description: 'If $value is not `falsy` it throws `AssertionError`.',
|
|
12139
|
+
returns: {
|
|
12140
|
+
type: 'null',
|
|
12141
|
+
},
|
|
12142
|
+
args: {
|
|
12143
|
+
value: {
|
|
12144
|
+
type: 'any',
|
|
12145
|
+
},
|
|
12146
|
+
message: {
|
|
12147
|
+
type: 'string',
|
|
12148
|
+
},
|
|
12149
|
+
},
|
|
12150
|
+
variants: [
|
|
12151
|
+
{
|
|
12152
|
+
argumentNames: [
|
|
12153
|
+
'value',
|
|
12154
|
+
],
|
|
12155
|
+
},
|
|
12156
|
+
{
|
|
12157
|
+
argumentNames: [
|
|
12158
|
+
'value',
|
|
12159
|
+
'message',
|
|
12160
|
+
],
|
|
12161
|
+
},
|
|
12162
|
+
],
|
|
12163
|
+
examples: [
|
|
12164
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(true, "Expected falsy") catch (e) e.message end',
|
|
12165
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy("x") catch (e) e.message end',
|
|
12166
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy([]) catch (e) e.message end',
|
|
12167
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(nd) catch (e) e.message end',
|
|
12168
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(1) catch (e) e.message end',
|
|
12169
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(false) catch (e) e.message end',
|
|
12170
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(0) catch (e) e.message end',
|
|
12171
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy(null) catch (e) e.message end',
|
|
12172
|
+
'let { assert-falsy } = import("Assert");\ntry assert-falsy("") catch (e) e.message end',
|
|
12173
|
+
],
|
|
12174
|
+
seeAlso: ['Assert.assert-truthy', 'Assert.assert-false', 'Assert.assert-true', 'Assert.assert-null'],
|
|
12175
|
+
hideOperatorForm: true,
|
|
12176
|
+
},
|
|
12177
|
+
'assert-null': {
|
|
12178
|
+
category: 'Assert',
|
|
12179
|
+
description: 'If $value is not `null` it throws `AssertionError`.',
|
|
12180
|
+
returns: {
|
|
12181
|
+
type: 'null',
|
|
12182
|
+
},
|
|
12183
|
+
args: {
|
|
12184
|
+
value: {
|
|
12185
|
+
type: 'any',
|
|
12186
|
+
},
|
|
12187
|
+
message: {
|
|
12188
|
+
type: 'string',
|
|
12189
|
+
},
|
|
12190
|
+
},
|
|
12191
|
+
variants: [
|
|
12192
|
+
{
|
|
12193
|
+
argumentNames: [
|
|
12194
|
+
'value',
|
|
12195
|
+
],
|
|
12196
|
+
},
|
|
12197
|
+
{
|
|
12198
|
+
argumentNames: [
|
|
12199
|
+
'value',
|
|
12200
|
+
'message',
|
|
12201
|
+
],
|
|
12202
|
+
},
|
|
12203
|
+
],
|
|
12204
|
+
examples: [
|
|
12205
|
+
'let { assert-null } = import("Assert");\ntry assert-null(null) catch (e) e.message end',
|
|
12206
|
+
'let { assert-null } = import("Assert");\ntry assert-null(true, "Expected null") catch (e) e.message end',
|
|
12207
|
+
'let { assert-null } = import("Assert");\ntry assert-null("x") catch (e) e.message end',
|
|
12208
|
+
'let { assert-null } = import("Assert");\ntry assert-null([]) catch (e) e.message end',
|
|
12209
|
+
'let { assert-null } = import("Assert");\ntry assert-null(nd) catch (e) e.message end',
|
|
12210
|
+
'let { assert-null } = import("Assert");\ntry assert-null(1) catch (e) e.message end',
|
|
12211
|
+
'let { assert-null } = import("Assert");\ntry assert-null(false) catch (e) e.message end',
|
|
12212
|
+
'let { assert-null } = import("Assert");\ntry assert-null(0) catch (e) e.message end',
|
|
12213
|
+
'let { assert-null } = import("Assert");\ntry assert-null("") catch (e) e.message end',
|
|
12214
|
+
],
|
|
12215
|
+
seeAlso: ['Assert.assert-truthy', 'Assert.assert-falsy'],
|
|
12216
|
+
hideOperatorForm: true,
|
|
12217
|
+
},
|
|
12218
|
+
'assert-throws': {
|
|
12219
|
+
category: 'Assert',
|
|
12220
|
+
description: 'If $fun does not throw, it throws `AssertionError`.',
|
|
12221
|
+
returns: {
|
|
12222
|
+
type: 'null',
|
|
12223
|
+
},
|
|
12224
|
+
args: {
|
|
12225
|
+
fun: {
|
|
12226
|
+
type: 'function',
|
|
12227
|
+
},
|
|
12228
|
+
message: {
|
|
12229
|
+
type: 'string',
|
|
12230
|
+
},
|
|
12231
|
+
},
|
|
12232
|
+
variants: [
|
|
12233
|
+
{
|
|
12234
|
+
argumentNames: [
|
|
12235
|
+
'fun',
|
|
12236
|
+
],
|
|
12237
|
+
},
|
|
12238
|
+
{
|
|
12239
|
+
argumentNames: [
|
|
12240
|
+
'fun',
|
|
12241
|
+
'message',
|
|
12242
|
+
],
|
|
12243
|
+
},
|
|
12244
|
+
],
|
|
12245
|
+
examples: [
|
|
12246
|
+
'let { assert-throws } = import("Assert");\nassert-throws(-> throw("Error"))',
|
|
12247
|
+
'let { assert-throws } = import("Assert");\ntry assert-throws(-> identity("Error")) catch (e) e.message end',
|
|
12248
|
+
],
|
|
12249
|
+
seeAlso: ['Assert.assert-throws-error', 'Assert.assert-not-throws'],
|
|
12250
|
+
hideOperatorForm: true,
|
|
12251
|
+
},
|
|
12252
|
+
'assert-throws-error': {
|
|
12253
|
+
category: 'Assert',
|
|
12254
|
+
description: 'If $fun does not throw $error-message, it throws `AssertionError`.',
|
|
12255
|
+
returns: {
|
|
12256
|
+
type: 'null',
|
|
12257
|
+
},
|
|
12258
|
+
args: {
|
|
12259
|
+
'fun': {
|
|
12260
|
+
type: 'function',
|
|
12261
|
+
},
|
|
12262
|
+
'error-message': {
|
|
12263
|
+
type: 'string',
|
|
12264
|
+
},
|
|
12265
|
+
'message': {
|
|
12266
|
+
type: 'string',
|
|
12267
|
+
},
|
|
12268
|
+
},
|
|
12269
|
+
variants: [
|
|
12270
|
+
{
|
|
12271
|
+
argumentNames: [
|
|
12272
|
+
'value',
|
|
12273
|
+
'error-message',
|
|
12274
|
+
],
|
|
12275
|
+
},
|
|
12276
|
+
{
|
|
12277
|
+
argumentNames: [
|
|
12278
|
+
'value',
|
|
12279
|
+
'error-message',
|
|
12280
|
+
'message',
|
|
12281
|
+
],
|
|
12282
|
+
},
|
|
12283
|
+
],
|
|
12284
|
+
examples: [
|
|
12285
|
+
'let { assert-throws-error } = import("Assert");\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end',
|
|
12286
|
+
'let { assert-throws-error } = import("Assert");\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end',
|
|
12287
|
+
],
|
|
12288
|
+
seeAlso: ['Assert.assert-throws', 'Assert.assert-not-throws'],
|
|
12289
|
+
hideOperatorForm: true,
|
|
12290
|
+
},
|
|
12291
|
+
'assert-not-throws': {
|
|
12292
|
+
category: 'Assert',
|
|
12293
|
+
description: 'If $fun throws, it throws `AssertionError`.',
|
|
12294
|
+
returns: {
|
|
12295
|
+
type: 'null',
|
|
12296
|
+
},
|
|
12297
|
+
args: {
|
|
12298
|
+
fun: {
|
|
12299
|
+
type: 'function',
|
|
12300
|
+
},
|
|
12301
|
+
message: {
|
|
12302
|
+
type: 'string',
|
|
12303
|
+
},
|
|
12304
|
+
},
|
|
12305
|
+
variants: [
|
|
12306
|
+
{
|
|
12307
|
+
argumentNames: [
|
|
12308
|
+
'fun',
|
|
12309
|
+
],
|
|
12310
|
+
},
|
|
12311
|
+
{
|
|
12312
|
+
argumentNames: [
|
|
12313
|
+
'fun',
|
|
12314
|
+
'message',
|
|
12315
|
+
],
|
|
12316
|
+
},
|
|
12317
|
+
],
|
|
12318
|
+
examples: [
|
|
12319
|
+
'let { assert-not-throws } = import("Assert");\ntry assert-not-throws(-> identity("Error")) catch (e) e.message end',
|
|
12320
|
+
'let { assert-not-throws } = import("Assert");\ntry assert-not-throws(-> throw("Error")) catch (e) e.message end',
|
|
12321
|
+
],
|
|
12322
|
+
seeAlso: ['Assert.assert-throws', 'Assert.assert-throws-error'],
|
|
12323
|
+
hideOperatorForm: true,
|
|
12324
|
+
},
|
|
12325
|
+
'assert-array': {
|
|
12326
|
+
category: 'Assert',
|
|
12327
|
+
description: 'If $value is not an `array` it throws `AssertionError`.',
|
|
12328
|
+
returns: {
|
|
12329
|
+
type: 'null',
|
|
12330
|
+
},
|
|
12331
|
+
args: {
|
|
12332
|
+
value: {
|
|
12333
|
+
type: 'any',
|
|
12334
|
+
},
|
|
12335
|
+
message: {
|
|
12336
|
+
type: 'string',
|
|
12337
|
+
},
|
|
12338
|
+
},
|
|
12339
|
+
variants: [
|
|
12340
|
+
{
|
|
12341
|
+
argumentNames: [
|
|
12342
|
+
'value',
|
|
12343
|
+
],
|
|
12344
|
+
},
|
|
12345
|
+
{
|
|
12346
|
+
argumentNames: [
|
|
12347
|
+
'value',
|
|
12348
|
+
'message',
|
|
12349
|
+
],
|
|
12350
|
+
},
|
|
12351
|
+
],
|
|
12352
|
+
examples: [
|
|
12353
|
+
'let { assert-array } = import("Assert");\ntry assert-array([1, 2, 3]) catch (e) e.message end',
|
|
12354
|
+
'let { assert-array } = import("Assert");\ntry assert-array("string") catch (e) e.message end',
|
|
12355
|
+
'let { assert-array } = import("Assert");\ntry assert-array(42, "Expected an array") catch (e) e.message end',
|
|
12356
|
+
],
|
|
12357
|
+
seeAlso: ['Assert.assert-object', 'Assert.assert-collection', 'Assert.assert-sequence'],
|
|
12358
|
+
hideOperatorForm: true,
|
|
12359
|
+
},
|
|
12360
|
+
'assert-boolean': {
|
|
12361
|
+
category: 'Assert',
|
|
12362
|
+
description: 'If $value is not a `boolean` it throws `AssertionError`.',
|
|
12363
|
+
returns: {
|
|
12364
|
+
type: 'null',
|
|
12365
|
+
},
|
|
12366
|
+
args: {
|
|
12367
|
+
value: {
|
|
12368
|
+
type: 'any',
|
|
12369
|
+
},
|
|
12370
|
+
message: {
|
|
12371
|
+
type: 'string',
|
|
12372
|
+
},
|
|
12373
|
+
},
|
|
12374
|
+
variants: [
|
|
12375
|
+
{
|
|
12376
|
+
argumentNames: [
|
|
12377
|
+
'value',
|
|
12378
|
+
],
|
|
12379
|
+
},
|
|
12380
|
+
{
|
|
12381
|
+
argumentNames: [
|
|
12382
|
+
'value',
|
|
12383
|
+
'message',
|
|
12384
|
+
],
|
|
12385
|
+
},
|
|
12386
|
+
],
|
|
12387
|
+
examples: [
|
|
12388
|
+
'let { assert-boolean } = import("Assert");\ntry assert-boolean(true) catch (e) e.message end',
|
|
12389
|
+
'let { assert-boolean } = import("Assert");\ntry assert-boolean(false) catch (e) e.message end',
|
|
12390
|
+
'let { assert-boolean } = import("Assert");\ntry assert-boolean(1, "Expected a boolean") catch (e) e.message end',
|
|
12391
|
+
],
|
|
12392
|
+
seeAlso: ['Assert.assert-true', 'Assert.assert-false', 'Assert.assert-number', 'Assert.assert-string'],
|
|
12393
|
+
hideOperatorForm: true,
|
|
12394
|
+
},
|
|
12395
|
+
'assert-collection': {
|
|
12396
|
+
category: 'Assert',
|
|
12397
|
+
description: 'If $value is not a `collection` (array, object, or string) it throws `AssertionError`.',
|
|
12398
|
+
returns: {
|
|
12399
|
+
type: 'null',
|
|
12400
|
+
},
|
|
12401
|
+
args: {
|
|
12402
|
+
value: {
|
|
12403
|
+
type: 'any',
|
|
12404
|
+
},
|
|
12405
|
+
message: {
|
|
12406
|
+
type: 'string',
|
|
12407
|
+
},
|
|
12408
|
+
},
|
|
12409
|
+
variants: [
|
|
12410
|
+
{
|
|
12411
|
+
argumentNames: [
|
|
12412
|
+
'value',
|
|
12413
|
+
],
|
|
12414
|
+
},
|
|
12415
|
+
{
|
|
12416
|
+
argumentNames: [
|
|
12417
|
+
'value',
|
|
12418
|
+
'message',
|
|
12419
|
+
],
|
|
12420
|
+
},
|
|
12421
|
+
],
|
|
12422
|
+
examples: [
|
|
12423
|
+
'let { assert-collection } = import("Assert");\ntry assert-collection([1, 2]) catch (e) e.message end',
|
|
12424
|
+
'let { assert-collection } = import("Assert");\ntry assert-collection({ a: 1 }) catch (e) e.message end',
|
|
12425
|
+
'let { assert-collection } = import("Assert");\ntry assert-collection("hello") catch (e) e.message end',
|
|
12426
|
+
'let { assert-collection } = import("Assert");\ntry assert-collection(42, "Expected a collection") catch (e) e.message end',
|
|
12427
|
+
],
|
|
12428
|
+
seeAlso: ['Assert.assert-sequence', 'Assert.assert-array', 'Assert.assert-object'],
|
|
12429
|
+
hideOperatorForm: true,
|
|
12430
|
+
},
|
|
12431
|
+
'assert-function': {
|
|
12432
|
+
category: 'Assert',
|
|
12433
|
+
description: 'If $value is not a `function` it throws `AssertionError`.',
|
|
12434
|
+
returns: {
|
|
12435
|
+
type: 'null',
|
|
12436
|
+
},
|
|
12437
|
+
args: {
|
|
12438
|
+
value: {
|
|
12439
|
+
type: 'any',
|
|
12440
|
+
},
|
|
12441
|
+
message: {
|
|
12442
|
+
type: 'string',
|
|
12443
|
+
},
|
|
12444
|
+
},
|
|
12445
|
+
variants: [
|
|
12446
|
+
{
|
|
12447
|
+
argumentNames: [
|
|
12448
|
+
'value',
|
|
12449
|
+
],
|
|
12450
|
+
},
|
|
12451
|
+
{
|
|
12452
|
+
argumentNames: [
|
|
12453
|
+
'value',
|
|
12454
|
+
'message',
|
|
12455
|
+
],
|
|
12456
|
+
},
|
|
12457
|
+
],
|
|
12458
|
+
examples: [
|
|
12459
|
+
'let { assert-function } = import("Assert");\ntry assert-function(-> $ + 1) catch (e) e.message end',
|
|
12460
|
+
'let { assert-function } = import("Assert");\ntry assert-function(42, "Expected a function") catch (e) e.message end',
|
|
12461
|
+
],
|
|
12462
|
+
seeAlso: ['Assert.assert-number', 'Assert.assert-string'],
|
|
12463
|
+
hideOperatorForm: true,
|
|
12464
|
+
},
|
|
12465
|
+
'assert-grid': {
|
|
12466
|
+
category: 'Assert',
|
|
12467
|
+
description: 'If $value is not a `grid` it throws `AssertionError`.',
|
|
12468
|
+
returns: {
|
|
12469
|
+
type: 'null',
|
|
12470
|
+
},
|
|
12471
|
+
args: {
|
|
12472
|
+
value: {
|
|
12473
|
+
type: 'any',
|
|
12474
|
+
},
|
|
12475
|
+
message: {
|
|
12476
|
+
type: 'string',
|
|
12477
|
+
},
|
|
12478
|
+
},
|
|
12479
|
+
variants: [
|
|
12480
|
+
{
|
|
12481
|
+
argumentNames: [
|
|
12482
|
+
'value',
|
|
12483
|
+
],
|
|
12484
|
+
},
|
|
12485
|
+
{
|
|
12486
|
+
argumentNames: [
|
|
12487
|
+
'value',
|
|
12488
|
+
'message',
|
|
12489
|
+
],
|
|
12490
|
+
},
|
|
12491
|
+
],
|
|
12492
|
+
examples: [
|
|
12493
|
+
'let { assert-grid } = import("Assert");\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end',
|
|
12494
|
+
'let { assert-grid } = import("Assert");\ntry assert-grid([1, 2], "Expected a grid") catch (e) e.message end',
|
|
12495
|
+
],
|
|
12496
|
+
seeAlso: ['Assert.assert-matrix', 'Assert.assert-vector'],
|
|
12497
|
+
hideOperatorForm: true,
|
|
12498
|
+
},
|
|
12499
|
+
'assert-integer': {
|
|
12500
|
+
category: 'Assert',
|
|
12501
|
+
description: 'If $value is not an `integer` it throws `AssertionError`.',
|
|
12502
|
+
returns: {
|
|
12503
|
+
type: 'null',
|
|
12504
|
+
},
|
|
12505
|
+
args: {
|
|
12506
|
+
value: {
|
|
12507
|
+
type: 'any',
|
|
12508
|
+
},
|
|
12509
|
+
message: {
|
|
12510
|
+
type: 'string',
|
|
12511
|
+
},
|
|
12512
|
+
},
|
|
12513
|
+
variants: [
|
|
12514
|
+
{
|
|
12515
|
+
argumentNames: [
|
|
12516
|
+
'value',
|
|
12517
|
+
],
|
|
12518
|
+
},
|
|
12519
|
+
{
|
|
12520
|
+
argumentNames: [
|
|
12521
|
+
'value',
|
|
12522
|
+
'message',
|
|
12523
|
+
],
|
|
12524
|
+
},
|
|
12525
|
+
],
|
|
12526
|
+
examples: [
|
|
12527
|
+
'let { assert-integer } = import("Assert");\ntry assert-integer(42) catch (e) e.message end',
|
|
12528
|
+
'let { assert-integer } = import("Assert");\ntry assert-integer(3.14, "Expected an integer") catch (e) e.message end',
|
|
12529
|
+
],
|
|
12530
|
+
seeAlso: ['Assert.assert-number'],
|
|
12531
|
+
hideOperatorForm: true,
|
|
12532
|
+
},
|
|
12533
|
+
'assert-matrix': {
|
|
12534
|
+
category: 'Assert',
|
|
12535
|
+
description: 'If $value is not a `matrix` it throws `AssertionError`.',
|
|
12536
|
+
returns: {
|
|
12537
|
+
type: 'null',
|
|
12538
|
+
},
|
|
12539
|
+
args: {
|
|
12540
|
+
value: {
|
|
12541
|
+
type: 'any',
|
|
12542
|
+
},
|
|
12543
|
+
message: {
|
|
12544
|
+
type: 'string',
|
|
12545
|
+
},
|
|
12546
|
+
},
|
|
12547
|
+
variants: [
|
|
12548
|
+
{
|
|
12549
|
+
argumentNames: [
|
|
12550
|
+
'value',
|
|
12551
|
+
],
|
|
12552
|
+
},
|
|
12553
|
+
{
|
|
12554
|
+
argumentNames: [
|
|
12555
|
+
'value',
|
|
12556
|
+
'message',
|
|
12557
|
+
],
|
|
12558
|
+
},
|
|
12559
|
+
],
|
|
12560
|
+
examples: [
|
|
12561
|
+
'let { assert-matrix } = import("Assert");\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end',
|
|
12562
|
+
'let { assert-matrix } = import("Assert");\ntry assert-matrix([1, 2], "Expected a matrix") catch (e) e.message end',
|
|
12563
|
+
],
|
|
12564
|
+
seeAlso: ['Assert.assert-vector', 'Assert.assert-grid'],
|
|
12565
|
+
hideOperatorForm: true,
|
|
12566
|
+
},
|
|
12567
|
+
'assert-number': {
|
|
12568
|
+
category: 'Assert',
|
|
12569
|
+
description: 'If $value is not a `number` it throws `AssertionError`.',
|
|
12570
|
+
returns: {
|
|
12571
|
+
type: 'null',
|
|
12572
|
+
},
|
|
12573
|
+
args: {
|
|
12574
|
+
value: {
|
|
12575
|
+
type: 'any',
|
|
12576
|
+
},
|
|
12577
|
+
message: {
|
|
12578
|
+
type: 'string',
|
|
12579
|
+
},
|
|
12580
|
+
},
|
|
12581
|
+
variants: [
|
|
12582
|
+
{
|
|
12583
|
+
argumentNames: [
|
|
12584
|
+
'value',
|
|
12585
|
+
],
|
|
12586
|
+
},
|
|
12587
|
+
{
|
|
12588
|
+
argumentNames: [
|
|
12589
|
+
'value',
|
|
12590
|
+
'message',
|
|
12591
|
+
],
|
|
12592
|
+
},
|
|
12593
|
+
],
|
|
12594
|
+
examples: [
|
|
12595
|
+
'let { assert-number } = import("Assert");\ntry assert-number(42) catch (e) e.message end',
|
|
12596
|
+
'let { assert-number } = import("Assert");\ntry assert-number("hello", "Expected a number") catch (e) e.message end',
|
|
12059
12597
|
],
|
|
12060
|
-
seeAlso: ['Assert.assert-
|
|
12598
|
+
seeAlso: ['Assert.assert-integer', 'Assert.assert-boolean', 'Assert.assert-string', 'Assert.assert-function'],
|
|
12061
12599
|
hideOperatorForm: true,
|
|
12062
12600
|
},
|
|
12063
|
-
'assert-
|
|
12601
|
+
'assert-object': {
|
|
12064
12602
|
category: 'Assert',
|
|
12065
|
-
description: 'If $value is not `
|
|
12603
|
+
description: 'If $value is not an `object` it throws `AssertionError`.',
|
|
12066
12604
|
returns: {
|
|
12067
12605
|
type: 'null',
|
|
12068
12606
|
},
|
|
@@ -12088,16 +12626,15 @@ const moduleDocs$6 = {
|
|
|
12088
12626
|
},
|
|
12089
12627
|
],
|
|
12090
12628
|
examples: [
|
|
12091
|
-
'let { assert-
|
|
12092
|
-
'let { assert-
|
|
12093
|
-
'let { assert-false } = import("Assert");\ntry assert-false(false) catch (e) e.message end',
|
|
12629
|
+
'let { assert-object } = import("Assert");\ntry assert-object({ a: 1 }) catch (e) e.message end',
|
|
12630
|
+
'let { assert-object } = import("Assert");\ntry assert-object([1, 2], "Expected an object") catch (e) e.message end',
|
|
12094
12631
|
],
|
|
12095
|
-
seeAlso: ['Assert.assert-
|
|
12632
|
+
seeAlso: ['Assert.assert-array', 'Assert.assert-collection'],
|
|
12096
12633
|
hideOperatorForm: true,
|
|
12097
12634
|
},
|
|
12098
|
-
'assert-
|
|
12635
|
+
'assert-regexp': {
|
|
12099
12636
|
category: 'Assert',
|
|
12100
|
-
description: 'If $value is not `
|
|
12637
|
+
description: 'If $value is not a `regexp` it throws `AssertionError`.',
|
|
12101
12638
|
returns: {
|
|
12102
12639
|
type: 'null',
|
|
12103
12640
|
},
|
|
@@ -12123,23 +12660,15 @@ const moduleDocs$6 = {
|
|
|
12123
12660
|
},
|
|
12124
12661
|
],
|
|
12125
12662
|
examples: [
|
|
12126
|
-
'let { assert-
|
|
12127
|
-
'let { assert-
|
|
12128
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy(0) catch (e) e.message end',
|
|
12129
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy(null) catch (e) e.message end',
|
|
12130
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy("") catch (e) e.message end',
|
|
12131
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy(true) catch (e) e.message end',
|
|
12132
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy(1) catch (e) e.message end',
|
|
12133
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy("x") catch (e) e.message end',
|
|
12134
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy([]) catch (e) e.message end',
|
|
12135
|
-
'let { assert-truthy } = import("Assert");\ntry assert-truthy(nd) catch (e) e.message end',
|
|
12663
|
+
'let { assert-regexp } = import("Assert");\ntry assert-regexp(#"^start") catch (e) e.message end',
|
|
12664
|
+
'let { assert-regexp } = import("Assert");\ntry assert-regexp("hello", "Expected a regexp") catch (e) e.message end',
|
|
12136
12665
|
],
|
|
12137
|
-
seeAlso: ['Assert.assert-
|
|
12666
|
+
seeAlso: ['Assert.assert-string'],
|
|
12138
12667
|
hideOperatorForm: true,
|
|
12139
12668
|
},
|
|
12140
|
-
'assert-
|
|
12669
|
+
'assert-sequence': {
|
|
12141
12670
|
category: 'Assert',
|
|
12142
|
-
description: 'If $value is not `
|
|
12671
|
+
description: 'If $value is not a `sequence` (array or string) it throws `AssertionError`.',
|
|
12143
12672
|
returns: {
|
|
12144
12673
|
type: 'null',
|
|
12145
12674
|
},
|
|
@@ -12165,22 +12694,16 @@ const moduleDocs$6 = {
|
|
|
12165
12694
|
},
|
|
12166
12695
|
],
|
|
12167
12696
|
examples: [
|
|
12168
|
-
'let { assert-
|
|
12169
|
-
'let { assert-
|
|
12170
|
-
'let { assert-
|
|
12171
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy(nd) catch (e) e.message end',
|
|
12172
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy(1) catch (e) e.message end',
|
|
12173
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy(false) catch (e) e.message end',
|
|
12174
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy(0) catch (e) e.message end',
|
|
12175
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy(null) catch (e) e.message end',
|
|
12176
|
-
'let { assert-falsy } = import("Assert");\ntry assert-falsy("") catch (e) e.message end',
|
|
12697
|
+
'let { assert-sequence } = import("Assert");\ntry assert-sequence([1, 2]) catch (e) e.message end',
|
|
12698
|
+
'let { assert-sequence } = import("Assert");\ntry assert-sequence("hello") catch (e) e.message end',
|
|
12699
|
+
'let { assert-sequence } = import("Assert");\ntry assert-sequence({ a: 1 }, "Expected a sequence") catch (e) e.message end',
|
|
12177
12700
|
],
|
|
12178
|
-
seeAlso: ['Assert.assert-
|
|
12701
|
+
seeAlso: ['Assert.assert-collection', 'Assert.assert-array'],
|
|
12179
12702
|
hideOperatorForm: true,
|
|
12180
12703
|
},
|
|
12181
|
-
'assert-
|
|
12704
|
+
'assert-string': {
|
|
12182
12705
|
category: 'Assert',
|
|
12183
|
-
description: 'If $value is not `
|
|
12706
|
+
description: 'If $value is not a `string` it throws `AssertionError`.',
|
|
12184
12707
|
returns: {
|
|
12185
12708
|
type: 'null',
|
|
12186
12709
|
},
|
|
@@ -12206,129 +12729,48 @@ const moduleDocs$6 = {
|
|
|
12206
12729
|
},
|
|
12207
12730
|
],
|
|
12208
12731
|
examples: [
|
|
12209
|
-
'let { assert-
|
|
12210
|
-
'let { assert-
|
|
12211
|
-
'let { assert-null } = import("Assert");\ntry assert-null("x") catch (e) e.message end',
|
|
12212
|
-
'let { assert-null } = import("Assert");\ntry assert-null([]) catch (e) e.message end',
|
|
12213
|
-
'let { assert-null } = import("Assert");\ntry assert-null(nd) catch (e) e.message end',
|
|
12214
|
-
'let { assert-null } = import("Assert");\ntry assert-null(1) catch (e) e.message end',
|
|
12215
|
-
'let { assert-null } = import("Assert");\ntry assert-null(false) catch (e) e.message end',
|
|
12216
|
-
'let { assert-null } = import("Assert");\ntry assert-null(0) catch (e) e.message end',
|
|
12217
|
-
'let { assert-null } = import("Assert");\ntry assert-null("") catch (e) e.message end',
|
|
12732
|
+
'let { assert-string } = import("Assert");\ntry assert-string("hello") catch (e) e.message end',
|
|
12733
|
+
'let { assert-string } = import("Assert");\ntry assert-string(42, "Expected a string") catch (e) e.message end',
|
|
12218
12734
|
],
|
|
12219
|
-
seeAlso: ['Assert.assert-
|
|
12735
|
+
seeAlso: ['Assert.assert-number', 'Assert.assert-boolean', 'Assert.assert-regexp', 'Assert.assert-function'],
|
|
12220
12736
|
hideOperatorForm: true,
|
|
12221
12737
|
},
|
|
12222
|
-
'assert-
|
|
12738
|
+
'assert-vector': {
|
|
12223
12739
|
category: 'Assert',
|
|
12224
|
-
description: 'If $
|
|
12740
|
+
description: 'If $value is not a `vector` it throws `AssertionError`.',
|
|
12225
12741
|
returns: {
|
|
12226
12742
|
type: 'null',
|
|
12227
12743
|
},
|
|
12228
12744
|
args: {
|
|
12229
|
-
|
|
12230
|
-
type: '
|
|
12745
|
+
value: {
|
|
12746
|
+
type: 'any',
|
|
12231
12747
|
},
|
|
12232
12748
|
message: {
|
|
12233
12749
|
type: 'string',
|
|
12234
12750
|
},
|
|
12235
12751
|
},
|
|
12236
|
-
variants: [
|
|
12237
|
-
{
|
|
12238
|
-
argumentNames: [
|
|
12239
|
-
'fun',
|
|
12240
|
-
],
|
|
12241
|
-
},
|
|
12242
|
-
{
|
|
12243
|
-
argumentNames: [
|
|
12244
|
-
'fun',
|
|
12245
|
-
'message',
|
|
12246
|
-
],
|
|
12247
|
-
},
|
|
12248
|
-
],
|
|
12249
|
-
examples: [
|
|
12250
|
-
'let { assert-throws } = import("Assert");\nassert-throws(-> throw("Error"))',
|
|
12251
|
-
'let { assert-throws } = import("Assert");\ntry assert-throws(-> identity("Error")) catch (e) e.message end',
|
|
12252
|
-
],
|
|
12253
|
-
seeAlso: ['Assert.assert-throws-error', 'Assert.assert-not-throws'],
|
|
12254
|
-
hideOperatorForm: true,
|
|
12255
|
-
},
|
|
12256
|
-
'assert-throws-error': {
|
|
12257
|
-
category: 'Assert',
|
|
12258
|
-
description: 'If $fun does not throw $error-message, it throws `AssertionError`.',
|
|
12259
|
-
returns: {
|
|
12260
|
-
type: 'null',
|
|
12261
|
-
},
|
|
12262
|
-
args: {
|
|
12263
|
-
'fun': {
|
|
12264
|
-
type: 'function',
|
|
12265
|
-
},
|
|
12266
|
-
'error-message': {
|
|
12267
|
-
type: 'string',
|
|
12268
|
-
},
|
|
12269
|
-
'message': {
|
|
12270
|
-
type: 'string',
|
|
12271
|
-
},
|
|
12272
|
-
},
|
|
12273
12752
|
variants: [
|
|
12274
12753
|
{
|
|
12275
12754
|
argumentNames: [
|
|
12276
12755
|
'value',
|
|
12277
|
-
'error-message',
|
|
12278
12756
|
],
|
|
12279
12757
|
},
|
|
12280
12758
|
{
|
|
12281
12759
|
argumentNames: [
|
|
12282
12760
|
'value',
|
|
12283
|
-
'error-message',
|
|
12284
|
-
'message',
|
|
12285
|
-
],
|
|
12286
|
-
},
|
|
12287
|
-
],
|
|
12288
|
-
examples: [
|
|
12289
|
-
'let { assert-throws-error } = import("Assert");\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end',
|
|
12290
|
-
'let { assert-throws-error } = import("Assert");\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end',
|
|
12291
|
-
],
|
|
12292
|
-
seeAlso: ['Assert.assert-throws', 'Assert.assert-not-throws'],
|
|
12293
|
-
hideOperatorForm: true,
|
|
12294
|
-
},
|
|
12295
|
-
'assert-not-throws': {
|
|
12296
|
-
category: 'Assert',
|
|
12297
|
-
description: 'If $fun throws, it throws `AssertionError`.',
|
|
12298
|
-
returns: {
|
|
12299
|
-
type: 'null',
|
|
12300
|
-
},
|
|
12301
|
-
args: {
|
|
12302
|
-
fun: {
|
|
12303
|
-
type: 'function',
|
|
12304
|
-
},
|
|
12305
|
-
message: {
|
|
12306
|
-
type: 'string',
|
|
12307
|
-
},
|
|
12308
|
-
},
|
|
12309
|
-
variants: [
|
|
12310
|
-
{
|
|
12311
|
-
argumentNames: [
|
|
12312
|
-
'fun',
|
|
12313
|
-
],
|
|
12314
|
-
},
|
|
12315
|
-
{
|
|
12316
|
-
argumentNames: [
|
|
12317
|
-
'fun',
|
|
12318
12761
|
'message',
|
|
12319
12762
|
],
|
|
12320
12763
|
},
|
|
12321
12764
|
],
|
|
12322
12765
|
examples: [
|
|
12323
|
-
'let { assert-
|
|
12324
|
-
'let { assert-
|
|
12766
|
+
'let { assert-vector } = import("Assert");\ntry assert-vector([1, 2, 3]) catch (e) e.message end',
|
|
12767
|
+
'let { assert-vector } = import("Assert");\ntry assert-vector(["a", "b"], "Expected a vector") catch (e) e.message end',
|
|
12325
12768
|
],
|
|
12326
|
-
seeAlso: ['Assert.assert-
|
|
12769
|
+
seeAlso: ['Assert.assert-matrix', 'Assert.assert-grid'],
|
|
12327
12770
|
hideOperatorForm: true,
|
|
12328
12771
|
},
|
|
12329
12772
|
};
|
|
12330
12773
|
|
|
12331
|
-
// TODO, remove some, add some. E.g. type guards, assert-number, assert-string, etc.
|
|
12332
12774
|
const assertNormalExpression = {
|
|
12333
12775
|
'assert': {
|
|
12334
12776
|
evaluate: (params, sourceCodeInfo) => {
|
|
@@ -12553,6 +12995,175 @@ const assertNormalExpression = {
|
|
|
12553
12995
|
},
|
|
12554
12996
|
arity: { min: 1, max: 2 },
|
|
12555
12997
|
},
|
|
12998
|
+
'assert-array': {
|
|
12999
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13000
|
+
if (message !== undefined) {
|
|
13001
|
+
assertString(message, sourceCodeInfo);
|
|
13002
|
+
message = ` ${message}`;
|
|
13003
|
+
}
|
|
13004
|
+
message ??= '';
|
|
13005
|
+
if (!Array.isArray(first))
|
|
13006
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be an array.${message}`, sourceCodeInfo);
|
|
13007
|
+
return null;
|
|
13008
|
+
},
|
|
13009
|
+
arity: { min: 1, max: 2 },
|
|
13010
|
+
},
|
|
13011
|
+
'assert-boolean': {
|
|
13012
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13013
|
+
if (message !== undefined) {
|
|
13014
|
+
assertString(message, sourceCodeInfo);
|
|
13015
|
+
message = ` ${message}`;
|
|
13016
|
+
}
|
|
13017
|
+
message ??= '';
|
|
13018
|
+
if (typeof first !== 'boolean')
|
|
13019
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a boolean.${message}`, sourceCodeInfo);
|
|
13020
|
+
return null;
|
|
13021
|
+
},
|
|
13022
|
+
arity: { min: 1, max: 2 },
|
|
13023
|
+
},
|
|
13024
|
+
'assert-collection': {
|
|
13025
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13026
|
+
if (message !== undefined) {
|
|
13027
|
+
assertString(message, sourceCodeInfo);
|
|
13028
|
+
message = ` ${message}`;
|
|
13029
|
+
}
|
|
13030
|
+
message ??= '';
|
|
13031
|
+
if (!isColl(first))
|
|
13032
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a collection.${message}`, sourceCodeInfo);
|
|
13033
|
+
return null;
|
|
13034
|
+
},
|
|
13035
|
+
arity: { min: 1, max: 2 },
|
|
13036
|
+
},
|
|
13037
|
+
'assert-function': {
|
|
13038
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13039
|
+
if (message !== undefined) {
|
|
13040
|
+
assertString(message, sourceCodeInfo);
|
|
13041
|
+
message = ` ${message}`;
|
|
13042
|
+
}
|
|
13043
|
+
message ??= '';
|
|
13044
|
+
if (!isLitsFunction(first))
|
|
13045
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a function.${message}`, sourceCodeInfo);
|
|
13046
|
+
return null;
|
|
13047
|
+
},
|
|
13048
|
+
arity: { min: 1, max: 2 },
|
|
13049
|
+
},
|
|
13050
|
+
'assert-grid': {
|
|
13051
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13052
|
+
if (message !== undefined) {
|
|
13053
|
+
assertString(message, sourceCodeInfo);
|
|
13054
|
+
message = ` ${message}`;
|
|
13055
|
+
}
|
|
13056
|
+
message ??= '';
|
|
13057
|
+
if (!isGrid(first))
|
|
13058
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a grid.${message}`, sourceCodeInfo);
|
|
13059
|
+
return null;
|
|
13060
|
+
},
|
|
13061
|
+
arity: { min: 1, max: 2 },
|
|
13062
|
+
},
|
|
13063
|
+
'assert-integer': {
|
|
13064
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13065
|
+
if (message !== undefined) {
|
|
13066
|
+
assertString(message, sourceCodeInfo);
|
|
13067
|
+
message = ` ${message}`;
|
|
13068
|
+
}
|
|
13069
|
+
message ??= '';
|
|
13070
|
+
if (typeof first !== 'number' || !isNumber(first, { integer: true }))
|
|
13071
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be an integer.${message}`, sourceCodeInfo);
|
|
13072
|
+
return null;
|
|
13073
|
+
},
|
|
13074
|
+
arity: { min: 1, max: 2 },
|
|
13075
|
+
},
|
|
13076
|
+
'assert-matrix': {
|
|
13077
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13078
|
+
if (message !== undefined) {
|
|
13079
|
+
assertString(message, sourceCodeInfo);
|
|
13080
|
+
message = ` ${message}`;
|
|
13081
|
+
}
|
|
13082
|
+
message ??= '';
|
|
13083
|
+
if (!isMatrix(first))
|
|
13084
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a matrix.${message}`, sourceCodeInfo);
|
|
13085
|
+
return null;
|
|
13086
|
+
},
|
|
13087
|
+
arity: { min: 1, max: 2 },
|
|
13088
|
+
},
|
|
13089
|
+
'assert-number': {
|
|
13090
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13091
|
+
if (message !== undefined) {
|
|
13092
|
+
assertString(message, sourceCodeInfo);
|
|
13093
|
+
message = ` ${message}`;
|
|
13094
|
+
}
|
|
13095
|
+
message ??= '';
|
|
13096
|
+
if (typeof first !== 'number')
|
|
13097
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a number.${message}`, sourceCodeInfo);
|
|
13098
|
+
return null;
|
|
13099
|
+
},
|
|
13100
|
+
arity: { min: 1, max: 2 },
|
|
13101
|
+
},
|
|
13102
|
+
'assert-object': {
|
|
13103
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13104
|
+
if (message !== undefined) {
|
|
13105
|
+
assertString(message, sourceCodeInfo);
|
|
13106
|
+
message = ` ${message}`;
|
|
13107
|
+
}
|
|
13108
|
+
message ??= '';
|
|
13109
|
+
if (!isObj(first))
|
|
13110
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be an object.${message}`, sourceCodeInfo);
|
|
13111
|
+
return null;
|
|
13112
|
+
},
|
|
13113
|
+
arity: { min: 1, max: 2 },
|
|
13114
|
+
},
|
|
13115
|
+
'assert-regexp': {
|
|
13116
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13117
|
+
if (message !== undefined) {
|
|
13118
|
+
assertString(message, sourceCodeInfo);
|
|
13119
|
+
message = ` ${message}`;
|
|
13120
|
+
}
|
|
13121
|
+
message ??= '';
|
|
13122
|
+
if (!isRegularExpression(first))
|
|
13123
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a regexp.${message}`, sourceCodeInfo);
|
|
13124
|
+
return null;
|
|
13125
|
+
},
|
|
13126
|
+
arity: { min: 1, max: 2 },
|
|
13127
|
+
},
|
|
13128
|
+
'assert-sequence': {
|
|
13129
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13130
|
+
if (message !== undefined) {
|
|
13131
|
+
assertString(message, sourceCodeInfo);
|
|
13132
|
+
message = ` ${message}`;
|
|
13133
|
+
}
|
|
13134
|
+
message ??= '';
|
|
13135
|
+
if (!isSeq(first))
|
|
13136
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a sequence.${message}`, sourceCodeInfo);
|
|
13137
|
+
return null;
|
|
13138
|
+
},
|
|
13139
|
+
arity: { min: 1, max: 2 },
|
|
13140
|
+
},
|
|
13141
|
+
'assert-string': {
|
|
13142
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13143
|
+
if (message !== undefined) {
|
|
13144
|
+
assertString(message, sourceCodeInfo);
|
|
13145
|
+
message = ` ${message}`;
|
|
13146
|
+
}
|
|
13147
|
+
message ??= '';
|
|
13148
|
+
if (typeof first !== 'string')
|
|
13149
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a string.${message}`, sourceCodeInfo);
|
|
13150
|
+
return null;
|
|
13151
|
+
},
|
|
13152
|
+
arity: { min: 1, max: 2 },
|
|
13153
|
+
},
|
|
13154
|
+
'assert-vector': {
|
|
13155
|
+
evaluate: ([first, message], sourceCodeInfo) => {
|
|
13156
|
+
if (message !== undefined) {
|
|
13157
|
+
assertString(message, sourceCodeInfo);
|
|
13158
|
+
message = ` ${message}`;
|
|
13159
|
+
}
|
|
13160
|
+
message ??= '';
|
|
13161
|
+
if (!isVector(first))
|
|
13162
|
+
throw new AssertionError(`Expected ${JSON.stringify(first)} to be a vector.${message}`, sourceCodeInfo);
|
|
13163
|
+
return null;
|
|
13164
|
+
},
|
|
13165
|
+
arity: { min: 1, max: 2 },
|
|
13166
|
+
},
|
|
12556
13167
|
};
|
|
12557
13168
|
for (const [key, docs] of Object.entries(moduleDocs$6)) {
|
|
12558
13169
|
if (assertNormalExpression[key])
|
|
@@ -31853,7 +32464,7 @@ function stringifyValue(value, html) {
|
|
|
31853
32464
|
const lt = '<';
|
|
31854
32465
|
if (isLitsFunction(value)) {
|
|
31855
32466
|
if (value.functionType === 'Builtin')
|
|
31856
|
-
return `${lt}builtin function ${value.
|
|
32467
|
+
return `${lt}builtin function ${value.normalBuiltinSymbolType}${gt}`;
|
|
31857
32468
|
else
|
|
31858
32469
|
return `${lt}function ${value.n ?? '\u03BB'}${gt}`;
|
|
31859
32470
|
}
|
|
@@ -32303,8 +32914,8 @@ const api = {
|
|
|
32303
32914
|
'integer?',
|
|
32304
32915
|
'array?',
|
|
32305
32916
|
'object?',
|
|
32306
|
-
'
|
|
32307
|
-
'
|
|
32917
|
+
'collection?',
|
|
32918
|
+
'sequence?',
|
|
32308
32919
|
'regexp?',
|
|
32309
32920
|
'zero?',
|
|
32310
32921
|
'pos?',
|
|
@@ -32366,7 +32977,6 @@ const api = {
|
|
|
32366
32977
|
'bit-set',
|
|
32367
32978
|
'bit-test',
|
|
32368
32979
|
],
|
|
32369
|
-
// TODO, remove some, add some. E.g. type guards, assert-number, assert-string, etc.
|
|
32370
32980
|
assert: [
|
|
32371
32981
|
'Assert.assert',
|
|
32372
32982
|
'Assert.assert=',
|
|
@@ -32383,6 +32993,19 @@ const api = {
|
|
|
32383
32993
|
'Assert.assert-throws',
|
|
32384
32994
|
'Assert.assert-throws-error',
|
|
32385
32995
|
'Assert.assert-not-throws',
|
|
32996
|
+
'Assert.assert-array',
|
|
32997
|
+
'Assert.assert-boolean',
|
|
32998
|
+
'Assert.assert-collection',
|
|
32999
|
+
'Assert.assert-function',
|
|
33000
|
+
'Assert.assert-grid',
|
|
33001
|
+
'Assert.assert-integer',
|
|
33002
|
+
'Assert.assert-matrix',
|
|
33003
|
+
'Assert.assert-number',
|
|
33004
|
+
'Assert.assert-object',
|
|
33005
|
+
'Assert.assert-regexp',
|
|
33006
|
+
'Assert.assert-sequence',
|
|
33007
|
+
'Assert.assert-string',
|
|
33008
|
+
'Assert.assert-vector',
|
|
32386
33009
|
],
|
|
32387
33010
|
grid: [
|
|
32388
33011
|
'Grid.every?',
|
|
@@ -32990,8 +33613,6 @@ function getCliFunctionExamples(fmt, reference) {
|
|
|
32990
33613
|
.map((example) => {
|
|
32991
33614
|
const oldLog = console.log;
|
|
32992
33615
|
console.log = function () { };
|
|
32993
|
-
const oldWarn = console.warn;
|
|
32994
|
-
console.warn = function () { };
|
|
32995
33616
|
let result;
|
|
32996
33617
|
try {
|
|
32997
33618
|
result = lits$1.run(`(try (do ${example}) (catch e e))`);
|
|
@@ -33002,7 +33623,6 @@ ${fmt.gray(stringifiedResult)}`;
|
|
|
33002
33623
|
}
|
|
33003
33624
|
finally {
|
|
33004
33625
|
console.log = oldLog;
|
|
33005
|
-
console.warn = oldWarn;
|
|
33006
33626
|
}
|
|
33007
33627
|
})
|
|
33008
33628
|
.join('\n\n');
|