@mojir/lits 2.1.33 → 2.1.35
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 +585 -206
- package/dist/cli/cli.js +136 -121
- package/dist/cli/src/parser/Parser.d.ts +7 -2
- package/dist/index.esm.js +129 -116
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +129 -116
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +129 -116
- package/dist/lits.iife.js.map +1 -1
- package/dist/src/parser/Parser.d.ts +7 -2
- package/dist/testFramework.esm.js +129 -116
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +129 -116
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/lits.iife.js
CHANGED
|
@@ -14562,6 +14562,48 @@ var Lits = (function (exports) {
|
|
|
14562
14562
|
docString,
|
|
14563
14563
|
];
|
|
14564
14564
|
};
|
|
14565
|
+
Parser.prototype.parseImplicitBlock = function (ends) {
|
|
14566
|
+
var nodes = [];
|
|
14567
|
+
while (!this.isAtEnd() && !this.isImplicitBlockEnd(ends)) {
|
|
14568
|
+
if (isOperatorToken(this.peek(), ';')) {
|
|
14569
|
+
this.advance();
|
|
14570
|
+
}
|
|
14571
|
+
else {
|
|
14572
|
+
nodes.push(this.parseExpression());
|
|
14573
|
+
}
|
|
14574
|
+
}
|
|
14575
|
+
this.assertImplicitBlockEnd(ends);
|
|
14576
|
+
if (nodes.length === 0) {
|
|
14577
|
+
throw new LitsError('Expected expression', this.peekSourceCodeInfo());
|
|
14578
|
+
}
|
|
14579
|
+
return nodes.length === 1
|
|
14580
|
+
? nodes[0]
|
|
14581
|
+
: withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, nodes]], this.peekSourceCodeInfo());
|
|
14582
|
+
};
|
|
14583
|
+
Parser.prototype.assertImplicitBlockEnd = function (ends) {
|
|
14584
|
+
if (!this.isImplicitBlockEnd(ends)) {
|
|
14585
|
+
throw new LitsError("Expected ".concat(ends.map(function (e) { return e[1]; }).join(' or ')), this.peekSourceCodeInfo());
|
|
14586
|
+
}
|
|
14587
|
+
};
|
|
14588
|
+
Parser.prototype.isImplicitBlockEnd = function (ends) {
|
|
14589
|
+
var e_1, _a;
|
|
14590
|
+
try {
|
|
14591
|
+
for (var ends_1 = __values(ends), ends_1_1 = ends_1.next(); !ends_1_1.done; ends_1_1 = ends_1.next()) {
|
|
14592
|
+
var end = ends_1_1.value;
|
|
14593
|
+
if (isReservedSymbolToken(this.peek(), end)) {
|
|
14594
|
+
return true;
|
|
14595
|
+
}
|
|
14596
|
+
}
|
|
14597
|
+
}
|
|
14598
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
14599
|
+
finally {
|
|
14600
|
+
try {
|
|
14601
|
+
if (ends_1_1 && !ends_1_1.done && (_a = ends_1.return)) _a.call(ends_1);
|
|
14602
|
+
}
|
|
14603
|
+
finally { if (e_1) throw e_1.error; }
|
|
14604
|
+
}
|
|
14605
|
+
return false;
|
|
14606
|
+
};
|
|
14565
14607
|
Parser.prototype.parseLoop = function (firstToken) {
|
|
14566
14608
|
this.advance();
|
|
14567
14609
|
assertLParenToken(this.peek());
|
|
@@ -14590,8 +14632,7 @@ var Lits = (function (exports) {
|
|
|
14590
14632
|
};
|
|
14591
14633
|
Parser.prototype.parseTry = function (token) {
|
|
14592
14634
|
this.advance();
|
|
14593
|
-
var tryExpression = this.
|
|
14594
|
-
assertReservedSymbolToken(this.peek(), 'catch');
|
|
14635
|
+
var tryExpression = this.parseImplicitBlock(['catch']);
|
|
14595
14636
|
this.advance();
|
|
14596
14637
|
var errorSymbol;
|
|
14597
14638
|
if (isLParenToken(this.peek())) {
|
|
@@ -14600,7 +14641,8 @@ var Lits = (function (exports) {
|
|
|
14600
14641
|
assertRParenToken(this.peek());
|
|
14601
14642
|
this.advance();
|
|
14602
14643
|
}
|
|
14603
|
-
var catchExpression = this.
|
|
14644
|
+
var catchExpression = this.parseImplicitBlock(['end']);
|
|
14645
|
+
this.advance();
|
|
14604
14646
|
return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.try, tryExpression, errorSymbol, catchExpression]], token[2]);
|
|
14605
14647
|
};
|
|
14606
14648
|
Parser.prototype.parseForOrDoseq = function (firstToken) {
|
|
@@ -14691,7 +14733,7 @@ var Lits = (function (exports) {
|
|
|
14691
14733
|
}
|
|
14692
14734
|
};
|
|
14693
14735
|
Parser.prototype.isInternalLoopBindingDelimiter = function (token, symbols) {
|
|
14694
|
-
var
|
|
14736
|
+
var e_2, _a;
|
|
14695
14737
|
// end of loop binding
|
|
14696
14738
|
if (isOperatorToken(token, ',') || isRParenToken(token)) {
|
|
14697
14739
|
return true;
|
|
@@ -14707,12 +14749,12 @@ var Lits = (function (exports) {
|
|
|
14707
14749
|
}
|
|
14708
14750
|
}
|
|
14709
14751
|
}
|
|
14710
|
-
catch (
|
|
14752
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
14711
14753
|
finally {
|
|
14712
14754
|
try {
|
|
14713
14755
|
if (symbols_1_1 && !symbols_1_1.done && (_a = symbols_1.return)) _a.call(symbols_1);
|
|
14714
14756
|
}
|
|
14715
|
-
finally { if (
|
|
14757
|
+
finally { if (e_2) throw e_2.error; }
|
|
14716
14758
|
}
|
|
14717
14759
|
return false;
|
|
14718
14760
|
};
|
|
@@ -14737,12 +14779,13 @@ var Lits = (function (exports) {
|
|
|
14737
14779
|
var condition = this.parseExpression();
|
|
14738
14780
|
assertReservedSymbolToken(this.peek(), 'then');
|
|
14739
14781
|
this.advance();
|
|
14740
|
-
var thenExpression = this.
|
|
14782
|
+
var thenExpression = this.parseImplicitBlock(['else', 'end']);
|
|
14741
14783
|
var elseExpression;
|
|
14742
14784
|
if (isReservedSymbolToken(this.peek(), 'else')) {
|
|
14743
14785
|
this.advance();
|
|
14744
|
-
elseExpression = this.
|
|
14786
|
+
elseExpression = this.parseImplicitBlock(['end']);
|
|
14745
14787
|
}
|
|
14788
|
+
this.advance();
|
|
14746
14789
|
return isUnless
|
|
14747
14790
|
? withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.unless, [condition, thenExpression, elseExpression]]], token[2])
|
|
14748
14791
|
: withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [condition, thenExpression, elseExpression]]], token[2]);
|
|
@@ -14756,26 +14799,11 @@ var Lits = (function (exports) {
|
|
|
14756
14799
|
var caseExpression = this.parseExpression();
|
|
14757
14800
|
assertReservedSymbolToken(this.peek(), 'then');
|
|
14758
14801
|
this.advance();
|
|
14759
|
-
var
|
|
14760
|
-
while (!this.isAtEnd()
|
|
14761
|
-
&& !isReservedSymbolToken(this.peek(), 'case')
|
|
14762
|
-
&& !isReservedSymbolToken(this.peek(), 'end')) {
|
|
14763
|
-
expressions.push(this.parseExpression());
|
|
14764
|
-
if (isOperatorToken(this.peek(), ';')) {
|
|
14765
|
-
this.advance();
|
|
14766
|
-
}
|
|
14767
|
-
else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
|
|
14768
|
-
throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
|
|
14769
|
-
}
|
|
14770
|
-
}
|
|
14771
|
-
var thenExpression = expressions.length === 1
|
|
14772
|
-
? expressions[0]
|
|
14773
|
-
: withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
|
|
14802
|
+
var thenExpression = this.parseImplicitBlock(['case', 'end']);
|
|
14774
14803
|
params.push([caseExpression, thenExpression]);
|
|
14775
14804
|
if (isReservedSymbolToken(this.peek(), 'end')) {
|
|
14776
14805
|
break;
|
|
14777
14806
|
}
|
|
14778
|
-
assertReservedSymbolToken(this.peek(), 'case');
|
|
14779
14807
|
}
|
|
14780
14808
|
assertReservedSymbolToken(this.peek());
|
|
14781
14809
|
this.advance();
|
|
@@ -14791,26 +14819,11 @@ var Lits = (function (exports) {
|
|
|
14791
14819
|
var caseExpression = this.parseExpression();
|
|
14792
14820
|
assertReservedSymbolToken(this.peek(), 'then');
|
|
14793
14821
|
this.advance();
|
|
14794
|
-
var
|
|
14795
|
-
while (!this.isAtEnd()
|
|
14796
|
-
&& !isReservedSymbolToken(this.peek(), 'case')
|
|
14797
|
-
&& !isReservedSymbolToken(this.peek(), 'end')) {
|
|
14798
|
-
expressions.push(this.parseExpression());
|
|
14799
|
-
if (isOperatorToken(this.peek(), ';')) {
|
|
14800
|
-
this.advance();
|
|
14801
|
-
}
|
|
14802
|
-
else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
|
|
14803
|
-
throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
|
|
14804
|
-
}
|
|
14805
|
-
}
|
|
14806
|
-
var thenExpression = expressions.length === 1
|
|
14807
|
-
? expressions[0]
|
|
14808
|
-
: withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
|
|
14822
|
+
var thenExpression = this.parseImplicitBlock(['case', 'end']);
|
|
14809
14823
|
params.push([caseExpression, thenExpression]);
|
|
14810
14824
|
if (isReservedSymbolToken(this.peek(), 'end')) {
|
|
14811
14825
|
break;
|
|
14812
14826
|
}
|
|
14813
|
-
assertReservedSymbolToken(this.peek(), 'case');
|
|
14814
14827
|
}
|
|
14815
14828
|
assertReservedSymbolToken(this.peek(), 'end');
|
|
14816
14829
|
this.advance();
|
|
@@ -15758,7 +15771,7 @@ var Lits = (function (exports) {
|
|
|
15758
15771
|
{ argumentNames: ['value', 'message'] },
|
|
15759
15772
|
],
|
|
15760
15773
|
description: 'If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.',
|
|
15761
|
-
examples: ['try
|
|
15774
|
+
examples: ['try assert(0, "Expected a positive value") catch (e) e.message end'],
|
|
15762
15775
|
noOperatorDocumentation: true,
|
|
15763
15776
|
},
|
|
15764
15777
|
'assert!=': {
|
|
@@ -15776,10 +15789,10 @@ var Lits = (function (exports) {
|
|
|
15776
15789
|
],
|
|
15777
15790
|
description: 'If $a is the same as $b it throws `AssertionError`.',
|
|
15778
15791
|
examples: [
|
|
15779
|
-
'try
|
|
15780
|
-
'try
|
|
15781
|
-
'try
|
|
15782
|
-
'try
|
|
15792
|
+
'try assert!=(0, 0, "Expected different values") catch (e) e.message end',
|
|
15793
|
+
'try assert!=(0, 0) catch (e) e.message end',
|
|
15794
|
+
'try 0 assert!= 0 catch (e) e.message end',
|
|
15795
|
+
'try assert!=(0, 1) catch (e) e.message end',
|
|
15783
15796
|
],
|
|
15784
15797
|
noOperatorDocumentation: true,
|
|
15785
15798
|
},
|
|
@@ -15798,9 +15811,9 @@ var Lits = (function (exports) {
|
|
|
15798
15811
|
],
|
|
15799
15812
|
description: 'If $a is not structural equal to $b it throws `AssertionError`.',
|
|
15800
15813
|
examples: [
|
|
15801
|
-
'try
|
|
15802
|
-
'try
|
|
15803
|
-
'try
|
|
15814
|
+
'try assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") catch (e) e.message end',
|
|
15815
|
+
'try assert=({ "a": 1 }, { "a": 2 }) catch (e) e.message end',
|
|
15816
|
+
'try assert=({ "a": 1 }, { "a": 1 }) catch (e) e.message end',
|
|
15804
15817
|
],
|
|
15805
15818
|
noOperatorDocumentation: true,
|
|
15806
15819
|
},
|
|
@@ -15819,9 +15832,9 @@ var Lits = (function (exports) {
|
|
|
15819
15832
|
],
|
|
15820
15833
|
description: 'If $a is not greater than $b it throws `AssertionError`.',
|
|
15821
15834
|
examples: [
|
|
15822
|
-
'try
|
|
15823
|
-
'try
|
|
15824
|
-
'try
|
|
15835
|
+
'try assert-gt(0, 1, "Expected greater value") catch (e) e.message end',
|
|
15836
|
+
'try assert-gt(0, 0) catch (e) e.message end',
|
|
15837
|
+
'try assert-gt(1, 0) catch (e) e.message end',
|
|
15825
15838
|
],
|
|
15826
15839
|
noOperatorDocumentation: true,
|
|
15827
15840
|
},
|
|
@@ -15840,9 +15853,9 @@ var Lits = (function (exports) {
|
|
|
15840
15853
|
],
|
|
15841
15854
|
description: 'If $a is not less than $b it throws `AssertionError`.',
|
|
15842
15855
|
examples: [
|
|
15843
|
-
'try
|
|
15844
|
-
'try
|
|
15845
|
-
'try
|
|
15856
|
+
'try assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end',
|
|
15857
|
+
'try assert-lte(1, 1) catch (e) e.message end',
|
|
15858
|
+
'try assert-lte(0, 1) catch (e) e.message end',
|
|
15846
15859
|
],
|
|
15847
15860
|
noOperatorDocumentation: true,
|
|
15848
15861
|
},
|
|
@@ -15861,9 +15874,9 @@ var Lits = (function (exports) {
|
|
|
15861
15874
|
],
|
|
15862
15875
|
description: 'If $a is less than $b it throws `AssertionError`.',
|
|
15863
15876
|
examples: [
|
|
15864
|
-
'try
|
|
15865
|
-
'try
|
|
15866
|
-
'try
|
|
15877
|
+
'try assert-gte(0, 1, "Expected greater value") catch (e) e.message end',
|
|
15878
|
+
'try assert-gte(0, 1) catch (e) e.message end',
|
|
15879
|
+
'try assert-gte(1, 1) catch (e) e.message end',
|
|
15867
15880
|
],
|
|
15868
15881
|
noOperatorDocumentation: true,
|
|
15869
15882
|
},
|
|
@@ -15882,9 +15895,9 @@ var Lits = (function (exports) {
|
|
|
15882
15895
|
],
|
|
15883
15896
|
description: 'If $a is grater than $b it throws `AssertionError`.',
|
|
15884
15897
|
examples: [
|
|
15885
|
-
'try
|
|
15886
|
-
'try
|
|
15887
|
-
'try
|
|
15898
|
+
'try assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end',
|
|
15899
|
+
'try assert-lte(1, 0) catch (e) e.message end',
|
|
15900
|
+
'try assert-lte(1, 1) catch (e) e.message end',
|
|
15888
15901
|
],
|
|
15889
15902
|
noOperatorDocumentation: true,
|
|
15890
15903
|
},
|
|
@@ -15908,9 +15921,9 @@ var Lits = (function (exports) {
|
|
|
15908
15921
|
],
|
|
15909
15922
|
description: 'If $value is not `true` it throws `AssertionError`.',
|
|
15910
15923
|
examples: [
|
|
15911
|
-
'try
|
|
15912
|
-
'try
|
|
15913
|
-
'try
|
|
15924
|
+
'try assert-true(false, "Expected true") catch (e) e.message end',
|
|
15925
|
+
'try assert-true(false) catch (e) e.message end',
|
|
15926
|
+
'try assert-true(true) catch (e) e.message end',
|
|
15914
15927
|
],
|
|
15915
15928
|
noOperatorDocumentation: true,
|
|
15916
15929
|
},
|
|
@@ -15934,9 +15947,9 @@ var Lits = (function (exports) {
|
|
|
15934
15947
|
],
|
|
15935
15948
|
description: 'If $value is not `false` it throws `AssertionError`.',
|
|
15936
15949
|
examples: [
|
|
15937
|
-
'try
|
|
15938
|
-
'try
|
|
15939
|
-
'try
|
|
15950
|
+
'try assert-false(true, "Expected false") catch (e) e.message end',
|
|
15951
|
+
'try assert-false(true) catch (e) e.message end',
|
|
15952
|
+
'try assert-false(false) catch (e) e.message end',
|
|
15940
15953
|
],
|
|
15941
15954
|
noOperatorDocumentation: true,
|
|
15942
15955
|
},
|
|
@@ -15960,16 +15973,16 @@ var Lits = (function (exports) {
|
|
|
15960
15973
|
],
|
|
15961
15974
|
description: 'If $value is not `truthy` it throws `AssertionError`.',
|
|
15962
15975
|
examples: [
|
|
15963
|
-
'try
|
|
15964
|
-
'try
|
|
15965
|
-
'try
|
|
15966
|
-
'try
|
|
15967
|
-
'try
|
|
15968
|
-
'try
|
|
15969
|
-
'try
|
|
15970
|
-
'try
|
|
15971
|
-
'try
|
|
15972
|
-
'try
|
|
15976
|
+
'try assert-truthy(false, "Expected truthy") catch (e) e.message end',
|
|
15977
|
+
'try assert-truthy(false) catch (e) e.message end',
|
|
15978
|
+
'try assert-truthy(0) catch (e) e.message end',
|
|
15979
|
+
'try assert-truthy(null) catch (e) e.message end',
|
|
15980
|
+
'try assert-truthy("") catch (e) e.message end',
|
|
15981
|
+
'try assert-truthy(true) catch (e) e.message end',
|
|
15982
|
+
'try assert-truthy(1) catch (e) e.message end',
|
|
15983
|
+
'try assert-truthy("x") catch (e) e.message end',
|
|
15984
|
+
'try assert-truthy([]) catch (e) e.message end',
|
|
15985
|
+
'try assert-truthy(nd) catch (e) e.message end',
|
|
15973
15986
|
],
|
|
15974
15987
|
noOperatorDocumentation: true,
|
|
15975
15988
|
},
|
|
@@ -15993,15 +16006,15 @@ var Lits = (function (exports) {
|
|
|
15993
16006
|
],
|
|
15994
16007
|
description: 'If $value is not `falsy` it throws `AssertionError`.',
|
|
15995
16008
|
examples: [
|
|
15996
|
-
'try
|
|
15997
|
-
'try
|
|
15998
|
-
'try
|
|
15999
|
-
'try
|
|
16000
|
-
'try
|
|
16001
|
-
'try
|
|
16002
|
-
'try
|
|
16003
|
-
'try
|
|
16004
|
-
'try
|
|
16009
|
+
'try assert-falsy(true, "Expected falsy") catch (e) e.message end',
|
|
16010
|
+
'try assert-falsy("x") catch (e) e.message end',
|
|
16011
|
+
'try assert-falsy([]) catch (e) e.message end',
|
|
16012
|
+
'try assert-falsy(nd) catch (e) e.message end',
|
|
16013
|
+
'try assert-falsy(1) catch (e) e.message end',
|
|
16014
|
+
'try assert-falsy(false) catch (e) e.message end',
|
|
16015
|
+
'try assert-falsy(0) catch (e) e.message end',
|
|
16016
|
+
'try assert-falsy(null) catch (e) e.message end',
|
|
16017
|
+
'try assert-falsy("") catch (e) e.message end',
|
|
16005
16018
|
],
|
|
16006
16019
|
noOperatorDocumentation: true,
|
|
16007
16020
|
},
|
|
@@ -16025,15 +16038,15 @@ var Lits = (function (exports) {
|
|
|
16025
16038
|
],
|
|
16026
16039
|
description: 'If $value is not `null` it throws `AssertionError`.',
|
|
16027
16040
|
examples: [
|
|
16028
|
-
'try
|
|
16029
|
-
'try
|
|
16030
|
-
'try
|
|
16031
|
-
'try
|
|
16032
|
-
'try
|
|
16033
|
-
'try
|
|
16034
|
-
'try
|
|
16035
|
-
'try
|
|
16036
|
-
'try
|
|
16041
|
+
'try assert-null(null) catch (e) e.message end',
|
|
16042
|
+
'try assert-null(true, "Expected null") catch (e) e.message end',
|
|
16043
|
+
'try assert-null("x") catch (e) e.message end',
|
|
16044
|
+
'try assert-null([]) catch (e) e.message end',
|
|
16045
|
+
'try assert-null(nd) catch (e) e.message end',
|
|
16046
|
+
'try assert-null(1) catch (e) e.message end',
|
|
16047
|
+
'try assert-null(false) catch (e) e.message end',
|
|
16048
|
+
'try assert-null(0) catch (e) e.message end',
|
|
16049
|
+
'try assert-null("") catch (e) e.message end',
|
|
16037
16050
|
],
|
|
16038
16051
|
noOperatorDocumentation: true,
|
|
16039
16052
|
},
|
|
@@ -16058,7 +16071,7 @@ var Lits = (function (exports) {
|
|
|
16058
16071
|
description: 'If $fun does not throw, it throws `AssertionError`.',
|
|
16059
16072
|
examples: [
|
|
16060
16073
|
'assert-throws(-> throw("Error"))',
|
|
16061
|
-
'try
|
|
16074
|
+
'try assert-throws(-> identity("Error")) catch (e) e.message end',
|
|
16062
16075
|
],
|
|
16063
16076
|
noOperatorDocumentation: true,
|
|
16064
16077
|
},
|
|
@@ -16085,8 +16098,8 @@ var Lits = (function (exports) {
|
|
|
16085
16098
|
],
|
|
16086
16099
|
description: 'If $fun does not throw $error-message, it throws `AssertionError`.',
|
|
16087
16100
|
examples: [
|
|
16088
|
-
'try
|
|
16089
|
-
'try
|
|
16101
|
+
'try assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end',
|
|
16102
|
+
'try assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end',
|
|
16090
16103
|
],
|
|
16091
16104
|
noOperatorDocumentation: true,
|
|
16092
16105
|
},
|
|
@@ -16110,8 +16123,8 @@ var Lits = (function (exports) {
|
|
|
16110
16123
|
],
|
|
16111
16124
|
description: 'If $fun throws, it throws `AssertionError`.',
|
|
16112
16125
|
examples: [
|
|
16113
|
-
'try
|
|
16114
|
-
'try
|
|
16126
|
+
'try assert-not-throws(-> identity("Error")) catch (e) e.message end',
|
|
16127
|
+
'try assert-not-throws(-> throw("Error")) catch (e) e.message end',
|
|
16115
16128
|
],
|
|
16116
16129
|
noOperatorDocumentation: true,
|
|
16117
16130
|
},
|
|
@@ -26802,9 +26815,9 @@ var Lits = (function (exports) {
|
|
|
26802
26815
|
],
|
|
26803
26816
|
description: 'Executes `try-body`. If that throws, the `catch-body` gets executed. See examples for details.',
|
|
26804
26817
|
examples: [
|
|
26805
|
-
"\ntry
|
|
26806
|
-
"\ntry
|
|
26807
|
-
"\ntry
|
|
26818
|
+
"\ntry\n 2 / 4\ncatch\n \"Oops!\"\nend",
|
|
26819
|
+
"\ntry\n foo()\ncatch(error)\n \"Error: \" ++ error.message\nend",
|
|
26820
|
+
"\ntry\n foo()\ncatch\n 42\nend",
|
|
26808
26821
|
],
|
|
26809
26822
|
},
|
|
26810
26823
|
'throw': {
|
|
@@ -26823,8 +26836,8 @@ var Lits = (function (exports) {
|
|
|
26823
26836
|
],
|
|
26824
26837
|
description: 'Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.',
|
|
26825
26838
|
examples: [
|
|
26826
|
-
'try
|
|
26827
|
-
'try
|
|
26839
|
+
'try throw("You shall not pass!") catch(error) "Error: " ++ error.message end',
|
|
26840
|
+
'try throw(slice("You shall not pass!", 0, 3)) catch(error) "Error: " ++ error.message end',
|
|
26828
26841
|
],
|
|
26829
26842
|
},
|
|
26830
26843
|
'if': {
|
|
@@ -26838,10 +26851,10 @@ var Lits = (function (exports) {
|
|
|
26838
26851
|
],
|
|
26839
26852
|
description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',
|
|
26840
26853
|
examples: [
|
|
26841
|
-
"\nif true then
|
|
26842
|
-
'if false then write!("TRUE") else write!("FALSE")',
|
|
26843
|
-
'if true then write!("TRUE")',
|
|
26844
|
-
'if false then write!("TRUE")',
|
|
26854
|
+
"\nif true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend",
|
|
26855
|
+
'if false then write!("TRUE") else write!("FALSE") end',
|
|
26856
|
+
'if true then write!("TRUE") end',
|
|
26857
|
+
'if false then write!("TRUE") end',
|
|
26845
26858
|
],
|
|
26846
26859
|
},
|
|
26847
26860
|
'unless': {
|
|
@@ -26855,10 +26868,10 @@ var Lits = (function (exports) {
|
|
|
26855
26868
|
],
|
|
26856
26869
|
description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',
|
|
26857
26870
|
examples: [
|
|
26858
|
-
"\nunless true then
|
|
26859
|
-
'unless false then write!("TRUE") else write!("FALSE")',
|
|
26860
|
-
'unless true then write!("TRUE")',
|
|
26861
|
-
'unless false then write!("TRUE")',
|
|
26871
|
+
"\nunless true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend",
|
|
26872
|
+
'unless false then write!("TRUE") else write!("FALSE") end',
|
|
26873
|
+
'unless true then write!("TRUE") end',
|
|
26874
|
+
'unless false then write!("TRUE") end',
|
|
26862
26875
|
],
|
|
26863
26876
|
},
|
|
26864
26877
|
'cond': {
|
|
@@ -26912,9 +26925,9 @@ var Lits = (function (exports) {
|
|
|
26912
26925
|
customVariants: ['recur(...recur-args)'],
|
|
26913
26926
|
description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',
|
|
26914
26927
|
examples: [
|
|
26915
|
-
"\nlet foo = (n) -> {\n write!(n);\n if !(zero?(n)) then
|
|
26916
|
-
"\n(n -> {\n write!(n);\n if !(zero?(n)) then
|
|
26917
|
-
"\nloop (n = 3) -> {\n write!(n);\n if !(zero?(n)) then
|
|
26928
|
+
"\nlet foo = (n) -> {\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\n};\nfoo(3)",
|
|
26929
|
+
"\n(n -> {\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\n})(3)",
|
|
26930
|
+
"\nloop (n = 3) -> {\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\n}",
|
|
26918
26931
|
],
|
|
26919
26932
|
},
|
|
26920
26933
|
};
|
|
@@ -30970,7 +30983,7 @@ var Lits = (function (exports) {
|
|
|
30970
30983
|
title: 'never',
|
|
30971
30984
|
category: 'Datatype',
|
|
30972
30985
|
description: 'A value that can never be created',
|
|
30973
|
-
examples: ["\n// throw(\"error\") will never return a value\ntry
|
|
30986
|
+
examples: ["\n// throw(\"error\") will never return a value\ntry throw(\"error\") catch \"never\" end",
|
|
30974
30987
|
],
|
|
30975
30988
|
},
|
|
30976
30989
|
};
|