fable 3.0.132 → 3.0.134

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.
@@ -162,6 +162,8 @@ suite
162
162
 
163
163
  Expect(_Parser.solve('5 ^ 2')).to.equal('25');
164
164
 
165
+ Expect(_Parser.solve('Result = sqrt(100 * (C + 30)) + sin(Depth - Width) / 10', { "PR": 1.5, "Z": "20.036237", "C": -13, Depth: 100.203, Width: 10.5})).to.equal('41.32965489638783839821');
166
+
165
167
  Expect(_Parser.solve('((15000 * 2) / 4)^2 + 100 - 10 * (35 + 5)')).to.equal("56249700");
166
168
 
167
169
  Expect(_Parser.solve('1.5 * sqrt(8 * 2.423782342^2) / 10')).to.equal('1.02832375808904701855')
@@ -170,7 +172,7 @@ suite
170
172
  Expect(_Parser.solve('sin(rad(60))')).to.equal('0.8660254037844386');
171
173
 
172
174
  Expect(_Parser.solve('Result = 5+3 - sqrt(75 / (3 + Depth) * Width)^ 3', { "PR": 1.5, "Z": "20.036237", "C": -13, Depth: 100.203, Width: 10.5}))
173
- .to.equal('-436.298371634749698156043404501049817281022489463053365091209703125')
175
+ .to.equal('-13.078386362213538715906797395732300153182132216343566001917247')
174
176
 
175
177
  let tmpResult = _Parser.solve('Result = (160 * PR * Z) / (C / 100) * PR * Z + (160 * (1 - C / 100))', {C:-13,PR:1.5,Z:20.03})
176
178
  Expect(tmpResult).to.equal("-1110837.0769230769230769230307");
@@ -178,6 +180,23 @@ suite
178
180
  let tmpResultPrecise = _Parser.solve('Result = (160 * PR * Z) / (C / 100) * PR * Z + (160 * (1 - C / 100))', {C:"-13",PR:"1.5",Z:"20.03"})
179
181
  Expect(tmpResultPrecise).to.equal("-1110837.0769230769230769230307");
180
182
 
183
+ return fDone();
184
+ }
185
+ );
186
+ test
187
+ (
188
+ 'Exercise End-to-End Expression Parsing with Sets',
189
+ (fDone)=>
190
+ {
191
+ let _Parser = getExpressionParser();
192
+
193
+ Expect(_Parser.solve('1 + 1')).to.equal("2");
194
+ Expect(_Parser.solve("Volume = Width * Height * Depth", {"Width": 73.5, "Height": 28.8, "Depth": 200.5})).to.equal("424418.4");
195
+ Expect(_Parser.solve("TotalCost = SUM(ItemCosts)", {"ItemCosts": [100,200,50,45,5]})).to.equal("400");
196
+ Expect(_Parser.solve("TotalCost = MEAN(ItemCosts)", {"ItemCosts": [100,200,50,45,5]})).to.equal("80");
197
+ Expect(_Parser.solve("TotalCost = MEDIAN(ItemCosts)", {"ItemCosts": [100,200,50,45,5]})).to.equal("50");
198
+ Expect(_Parser.solve("TotalCost = COUNT(ItemCosts)", {"ItemCosts": [100,200,50,45,5]})).to.equal("5");
199
+
181
200
  return fDone();
182
201
  }
183
202
  );
package/test/Math_test.js CHANGED
@@ -6,10 +6,12 @@
6
6
  * @author Steven Velozo <steven@velozo.com>
7
7
  */
8
8
 
9
- var libFable = require('../source/Fable.js');
9
+ const libFable = require('../source/Fable.js');
10
10
 
11
- var Chai = require("chai");
12
- var Expect = Chai.expect;
11
+ const Chai = require("chai");
12
+ const Expect = Chai.expect;
13
+
14
+ const _ChocoData = require(`./data/chocodata.json`);
13
15
 
14
16
  suite
15
17
  (
@@ -116,6 +118,55 @@ suite
116
118
  }
117
119
  );
118
120
  test
121
+ (
122
+ 'Set Math Operations',
123
+ function(fDone)
124
+ {
125
+ let testFable = new libFable();
126
+ let testManyfest = testFable.newManyfest();
127
+
128
+ let tmpChocoSizes = testManyfest.getValueAtAddress(_ChocoData, 'files[].size');
129
+
130
+ Expect(testFable.Math.maxPrecise(tmpChocoSizes)).to.equal("31625216");
131
+ Expect(testFable.Math.minPrecise(tmpChocoSizes)).to.equal("620");
132
+ Expect(testFable.Math.sumPrecise(tmpChocoSizes)).to.equal("36431778");
133
+ Expect(testFable.Math.countSetElements(tmpChocoSizes)).to.equal(17);
134
+ Expect(testFable.Math.meanPrecise(tmpChocoSizes)).to.equal("2143045.76470588235294117647");
135
+ Expect(testFable.Math.medianPrecise(tmpChocoSizes)).to.equal("5993");
136
+ // Since the file sizes are all different, this is just the whole list.
137
+ Expect(testFable.Math.modePrecise(tmpChocoSizes)).to.deep.equal(["620","838","1371","3383","3503","4093","4951","5993","6843","7481","8388","31141","101114","2248166","2378677","31625216","NaN"]);
138
+
139
+ Expect(testFable.Math.maxPrecise([100, 101, 400, "20", "dog"])).to.equal("400");
140
+ Expect(testFable.Math.modePrecise([100, 20, 101, 400, "20", "dog"])).to.deep.equal(["20"]);
141
+ Expect(testFable.Math.modePrecise([100, 20, 101, 400, "20", "dog", 101])).to.deep.equal(["20", "101"]);
142
+
143
+ Expect(testFable.Math.maxPrecise([100, 101, 400, "20", "dog"])).to.equal("400");
144
+ Expect(testFable.Math.modePrecise([100, 20, 101, 400, "20", "dog"])).to.deep.equal(["20"]);
145
+ Expect(testFable.Math.modePrecise([100, 20, 101, 400, "20", "dog", 101])).to.deep.equal(["20", "101"]);
146
+
147
+ Expect(testFable.Math.sumPrecise([])).to.equal('0.0');
148
+ Expect(testFable.Math.countSetElements([])).to.equal(0);
149
+ Expect(testFable.Math.meanPrecise([])).to.equal('0.0');
150
+ Expect(testFable.Math.medianPrecise([])).to.equal('0.0');
151
+ Expect(testFable.Math.modePrecise([])).to.deep.equal([]);
152
+
153
+ Expect(testFable.Math.sumPrecise([1,2,3,4,5,6,7,8,9,10])).to.equal('55');
154
+ Expect(testFable.Math.countSetElements([1,2,3,4,5,6,7,8,9,10])).to.equal(10);
155
+ Expect(testFable.Math.meanPrecise([1,2,3,4,5,6,7,8,9,10])).to.equal('5.5');
156
+ Expect(testFable.Math.meanPrecise([0,1,2,3,4,5,6,7,8,9,10])).to.equal('5');
157
+ Expect(testFable.Math.medianPrecise([1,2,3,4,5,6,7,8,9,10])).to.equal('5.5');
158
+ Expect(testFable.Math.modePrecise([1,2,3,4,5,6,7,8,9,10])).to.deep.equal(['1','2','3','4','5','6','7','8','9','10']);
159
+
160
+ Expect(testFable.Math.sumPrecise([1,2,3,4,5,6,7,8,9,10,11])).to.equal('66');
161
+ Expect(testFable.Math.countSetElements([1,2,3,4,5,6,7,8,9,10,11])).to.equal(11);
162
+ Expect(testFable.Math.meanPrecise([1,2,3,4,5,6,7,8,9,10,11])).to.equal('6');
163
+ Expect(testFable.Math.medianPrecise([1,2,3,4,5,6,7,8,9,10,11])).to.equal('6');
164
+ Expect(testFable.Math.modePrecise([1,2,3,4,5,6,7,8,9,10,11])).to.deep.equal(['1','2','3','4','5','6','7','8','9','10','11']);
165
+
166
+ return fDone();
167
+ }
168
+ )
169
+ test
119
170
  (
120
171
  'Cast To Fixed Numbers',
121
172
  function(fDone)
@@ -0,0 +1,248 @@
1
+ {
2
+ "created": 1664830085,
3
+ "d1": "ia600202.us.archive.org",
4
+ "d2": "ia800202.us.archive.org",
5
+ "dir": "/7/items/FrankenberryCountChoculaTevevisionCommercial1971",
6
+ "files": [
7
+ {
8
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000001.jpg",
9
+ "source": "derivative",
10
+ "format": "Thumbnail",
11
+ "original": "frankerberry_countchockula_1971.0001.mpg",
12
+ "mtime": "1296336956",
13
+ "size": "838",
14
+ "md5": "e47269cd5a82db9594f265a65785ec12",
15
+ "crc32": "165c668b",
16
+ "sha1": "383303d9546c381267569ad4e33aff691f0bb8c7"
17
+ },
18
+ {
19
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000004.jpg",
20
+ "source": "derivative",
21
+ "format": "Thumbnail",
22
+ "original": "frankerberry_countchockula_1971.0001.mpg",
23
+ "mtime": "1296336957",
24
+ "size": "6843",
25
+ "md5": "c93fa52000ab4665e69b25c403e11aff",
26
+ "crc32": "9444e6f6",
27
+ "sha1": "716b4f9950b8147f51d3265f9c62ff86451308d5"
28
+ },
29
+ {
30
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000009.jpg",
31
+ "source": "derivative",
32
+ "format": "Thumbnail",
33
+ "original": "frankerberry_countchockula_1971.0001.mpg",
34
+ "mtime": "1296336957",
35
+ "size": "8388",
36
+ "md5": "30eb3eb4cbbdfa08d531a0a74da7c000",
37
+ "crc32": "be874a9e",
38
+ "sha1": "0c392d777609e967b6022be27edad678c5ae74e2"
39
+ },
40
+ {
41
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000014.jpg",
42
+ "source": "derivative",
43
+ "format": "Thumbnail",
44
+ "original": "frankerberry_countchockula_1971.0001.mpg",
45
+ "mtime": "1296336958",
46
+ "size": "5993",
47
+ "md5": "4e9ebc3d076bec8cf7dfe76795f8c769",
48
+ "crc32": "912ec98c",
49
+ "sha1": "01dc49c852e1bbb421199450dd902935c62b06de"
50
+ },
51
+ {
52
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000019.jpg",
53
+ "source": "derivative",
54
+ "format": "Thumbnail",
55
+ "original": "frankerberry_countchockula_1971.0001.mpg",
56
+ "mtime": "1296336958",
57
+ "size": "4951",
58
+ "md5": "59f190f0c5b0a048415b26412860b6dd",
59
+ "crc32": "a70a30b1",
60
+ "sha1": "a284af9757cb24d28f96ec88ec1b1c23a8cea9fe"
61
+ },
62
+ {
63
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000024.jpg",
64
+ "source": "derivative",
65
+ "format": "Thumbnail",
66
+ "original": "frankerberry_countchockula_1971.0001.mpg",
67
+ "mtime": "1296336959",
68
+ "size": "3383",
69
+ "md5": "be2a908acd563b896e7758b598295148",
70
+ "crc32": "ed467831",
71
+ "sha1": "94c001e72ebc86d837a78c61a004db9ab9d597bd"
72
+ },
73
+ {
74
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971.thumbs/frankerberry_countchockula_1971.0001_000029.jpg",
75
+ "source": "derivative",
76
+ "format": "Thumbnail",
77
+ "original": "frankerberry_countchockula_1971.0001.mpg",
78
+ "mtime": "1296336960",
79
+ "size": "3503",
80
+ "md5": "c82199d09be07633000fd07b363dd8a3",
81
+ "crc32": "a1fd79cb",
82
+ "sha1": "2bc8e761edb24a441fa5906dda1c424e1f98a47a"
83
+ },
84
+ {
85
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971_archive.torrent",
86
+ "source": "metadata",
87
+ "btih": "de6b371e7cc3c83db1cc08150500753eae533409",
88
+ "mtime": "1542761794",
89
+ "size": "4093",
90
+ "md5": "a275d3b4028cccb5bea8b47a88c838af",
91
+ "crc32": "5ffa7334",
92
+ "sha1": "af8222637b574cba1360d0ea77e231640ffd43c4",
93
+ "format": "Archive BitTorrent"
94
+ },
95
+ {
96
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971_files.xml",
97
+ "source": "metadata",
98
+ "format": "Metadata",
99
+ "md5": "3a7e87b08bed1e203a5858b31352c110"
100
+ },
101
+ {
102
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971_meta.xml",
103
+ "source": "metadata",
104
+ "format": "Metadata",
105
+ "mtime": "1542761793",
106
+ "size": "1371",
107
+ "md5": "0b9c9bf21b9a26aea43a2f735b404624",
108
+ "crc32": "41077288",
109
+ "sha1": "22e6f2c73bf63072f671d846355da2785db51dbd"
110
+ },
111
+ {
112
+ "name": "FrankenberryCountChoculaTevevisionCommercial1971_reviews.xml",
113
+ "source": "original",
114
+ "mtime": "1466898697",
115
+ "size": "620",
116
+ "md5": "260bfba5d696772445dcc7ff6e6d5bdb",
117
+ "crc32": "25ea3229",
118
+ "sha1": "7d541f18fcd5ad9c6e593afe5a80f18771f23b32",
119
+ "format": "Metadata"
120
+ },
121
+ {
122
+ "name": "__ia_thumb.jpg",
123
+ "source": "original",
124
+ "mtime": "1539115881",
125
+ "size": "7481",
126
+ "md5": "8cec324fa0016fd77cc04e6a4b2ebb00",
127
+ "crc32": "d9e1b316",
128
+ "sha1": "4dab42952fe0405a3b7f80146636b33d7b1bd01e",
129
+ "format": "Item Tile",
130
+ "rotation": "0",
131
+ "thumbnail": true
132
+ },
133
+ {
134
+ "name": "frankerberry_countchockula_1971.0001.gif",
135
+ "source": "derivative",
136
+ "format": "Animated GIF",
137
+ "original": "frankerberry_countchockula_1971.0001.mpg",
138
+ "mtime": "1296336965",
139
+ "size": "101114",
140
+ "md5": "b78a13094030f104900eb996bafe2b7d",
141
+ "crc32": "6650cd8",
142
+ "sha1": "669798c037205cac14f70592deef6f7831b3d4a1"
143
+ },
144
+ {
145
+ "name": "frankerberry_countchockula_1971.0001.mpg",
146
+ "source": "original",
147
+ "format": "MPEG2",
148
+ "mtime": "1296335803",
149
+ "size": "31625216",
150
+ "md5": "762ba18b026b85b3f074523e7fcb4db0",
151
+ "crc32": "42347f78",
152
+ "sha1": "41162dc2d1a91b618124c84628d0c231544a02be",
153
+ "length": "31.14",
154
+ "height": "480",
155
+ "width": "640",
156
+ "thumbnail": false
157
+ },
158
+ {
159
+ "name": "frankerberry_countchockula_1971.0001.mpg.idx",
160
+ "source": "derivative",
161
+ "format": "Video Index",
162
+ "original": "frankerberry_countchockula_1971.0001.mpg",
163
+ "mtime": "1296336956",
164
+ "size": "31141",
165
+ "md5": "49423e072726e4ea3cdd8ebdd26c7dfc",
166
+ "crc32": "ae969a68",
167
+ "sha1": "805782cd2d0f9002555816daadf3b8607e621f79"
168
+ },
169
+ {
170
+ "name": "frankerberry_countchockula_1971.0001.ogv",
171
+ "source": "derivative",
172
+ "format": "Ogg Video",
173
+ "original": "frankerberry_countchockula_1971.0001.mpg",
174
+ "mtime": "1296336994",
175
+ "size": "2248166",
176
+ "md5": "f1b933e97ce63594fb28a0a019ff3436",
177
+ "crc32": "a2a0e5e9",
178
+ "sha1": "a6bf0aec9f006baeca37c03f586686ebe685d59b",
179
+ "length": "31.15",
180
+ "height": "300",
181
+ "width": "400"
182
+ },
183
+ {
184
+ "name": "frankerberry_countchockula_1971.0001_512kb.mp4",
185
+ "source": "derivative",
186
+ "format": "512Kb MPEG4",
187
+ "original": "frankerberry_countchockula_1971.0001.mpg",
188
+ "mtime": "1296336977",
189
+ "size": "2378677",
190
+ "md5": "a7750839519c61ba3bb99fc66b32011d",
191
+ "crc32": "4dbd37c8",
192
+ "sha1": "3929314c192dec006fac2739bcb4730788e8c068",
193
+ "length": "31.13",
194
+ "height": "240",
195
+ "width": "320"
196
+ }
197
+ ],
198
+ "files_count": 17,
199
+ "item_last_updated": 1542761794,
200
+ "item_size": 36431778,
201
+ "metadata": {
202
+ "identifier": "FrankenberryCountChoculaTevevisionCommercial1971",
203
+ "title": "Franken Berry / Count Chocula : Tevevision Commercial 1971",
204
+ "creator": "General Mills",
205
+ "mediatype": "movies",
206
+ "collection": [
207
+ "classic_tv_commercials",
208
+ "television"
209
+ ],
210
+ "description": "Count Chocula and Franken Berry were both introduced in 1971. Boo Berry Cereal appeared in 1973 followed by Fruit Brute in 1974. Yummy Mummy appeared more than a decade later in 1988 - completing the the group known as the General Mills Monster Cereals.",
211
+ "subject": "Third Eye Cinema; Classic Television Commercials; animation; cartoons;General Mills",
212
+ "licenseurl": "http://creativecommons.org/publicdomain/mark/1.0/",
213
+ "publicdate": "2011-01-29 21:36:42",
214
+ "addeddate": "2011-01-29 21:35:38",
215
+ "uploader": "bolexman@msn.com",
216
+ "updater": [
217
+ "Bolexman",
218
+ "Bolexman",
219
+ "Jeff Kaplan"
220
+ ],
221
+ "updatedate": [
222
+ "2011-01-29 21:45:38",
223
+ "2011-01-29 21:55:46",
224
+ "2011-01-29 23:04:55"
225
+ ],
226
+ "sound": "sound",
227
+ "color": "color",
228
+ "runtime": "0:31",
229
+ "backup_location": "ia903608_22",
230
+ "ia_orig__runtime": "31 seconds"
231
+ },
232
+ "reviews": [
233
+ {
234
+ "reviewbody": "Sugar cereal cartoon Karloff and Lugosi argue self-importance pre Lorre ghost. Interesting how kids still know the voices without any idea of the origins.",
235
+ "reviewtitle": "pre booberry",
236
+ "reviewer": "outofthebox",
237
+ "reviewdate": "2016-06-25 23:51:36",
238
+ "createdate": "2016-06-25 23:51:36",
239
+ "stars": "4"
240
+ }
241
+ ],
242
+ "server": "ia800202.us.archive.org",
243
+ "uniq": 1957612749,
244
+ "workable_servers": [
245
+ "ia800202.us.archive.org",
246
+ "ia600202.us.archive.org"
247
+ ]
248
+ }