fable 3.1.64 → 3.1.66

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.
Files changed (24) hide show
  1. package/docs/services/expression-parser-functions/README.md +9 -0
  2. package/docs/services/expression-parser-functions/beziercurvefit.md +57 -0
  3. package/docs/services/expression-parser-functions/bezierpoint.md +55 -0
  4. package/docs/services/expression-parser-functions/intercept.md +59 -0
  5. package/docs/services/expression-parser-functions/setvalue.md +55 -0
  6. package/docs/services/expression-parser-functions/slope.md +51 -0
  7. package/docs/services/expression-parser-functions/ternary.md +180 -0
  8. package/docs/services/expression-parser.md +72 -0
  9. package/example_applications/mathematical_playground/Math-Solver-Harness.js +108 -0
  10. package/example_applications/mathematical_playground/TestSuite-AcidTest.json +178 -0
  11. package/example_applications/mathematical_playground/TestSuite-Identities.json +147 -0
  12. package/example_applications/mathematical_playground/TestSuite-Precision.json +127 -0
  13. package/example_applications/mathematical_playground/TestSuite-Spreadsheet.json +198 -0
  14. package/package.json +3 -3
  15. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer-DirectiveMutation.js +143 -0
  16. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js +1 -1
  17. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json +5 -4
  18. package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json +65 -1
  19. package/source/services/Fable-Service-ExpressionParser.js +1 -0
  20. package/source/services/Fable-Service-Logic.js +33 -0
  21. package/source/services/Fable-Service-Math.js +78 -0
  22. package/source/services/Fable-Service-RestClient.js +105 -0
  23. package/test/ExpressionParser_tests.js +290 -0
  24. package/test/RestClientBinaryUpload_test.js +537 -0
@@ -2155,3 +2155,293 @@ suite
2155
2155
  );
2156
2156
  }
2157
2157
  );
2158
+
2159
+ suite
2160
+ (
2161
+ 'Comparison Operators',
2162
+ function ()
2163
+ {
2164
+ suite
2165
+ (
2166
+ 'Greater Than',
2167
+ function ()
2168
+ {
2169
+ test
2170
+ (
2171
+ 'Basic greater than comparisons.',
2172
+ (fDone) =>
2173
+ {
2174
+ let _Parser = getExpressionParser();
2175
+ Expect(_Parser.solve('Result = 5 > 3')).to.equal('1');
2176
+ Expect(_Parser.solve('Result = 3 > 5')).to.equal('0');
2177
+ Expect(_Parser.solve('Result = 5 > 5')).to.equal('0');
2178
+ return fDone();
2179
+ }
2180
+ );
2181
+ }
2182
+ );
2183
+ suite
2184
+ (
2185
+ 'Greater Than or Equal',
2186
+ function ()
2187
+ {
2188
+ test
2189
+ (
2190
+ 'Basic greater than or equal comparisons.',
2191
+ (fDone) =>
2192
+ {
2193
+ let _Parser = getExpressionParser();
2194
+ Expect(_Parser.solve('Result = 5 >= 3')).to.equal('1');
2195
+ Expect(_Parser.solve('Result = 3 >= 5')).to.equal('0');
2196
+ Expect(_Parser.solve('Result = 5 >= 5')).to.equal('1');
2197
+ return fDone();
2198
+ }
2199
+ );
2200
+ }
2201
+ );
2202
+ suite
2203
+ (
2204
+ 'Less Than',
2205
+ function ()
2206
+ {
2207
+ test
2208
+ (
2209
+ 'Basic less than comparisons.',
2210
+ (fDone) =>
2211
+ {
2212
+ let _Parser = getExpressionParser();
2213
+ Expect(_Parser.solve('Result = 3 < 5')).to.equal('1');
2214
+ Expect(_Parser.solve('Result = 5 < 3')).to.equal('0');
2215
+ Expect(_Parser.solve('Result = 5 < 5')).to.equal('0');
2216
+ return fDone();
2217
+ }
2218
+ );
2219
+ }
2220
+ );
2221
+ suite
2222
+ (
2223
+ 'Less Than or Equal',
2224
+ function ()
2225
+ {
2226
+ test
2227
+ (
2228
+ 'Basic less than or equal comparisons.',
2229
+ (fDone) =>
2230
+ {
2231
+ let _Parser = getExpressionParser();
2232
+ Expect(_Parser.solve('Result = 3 <= 5')).to.equal('1');
2233
+ Expect(_Parser.solve('Result = 5 <= 3')).to.equal('0');
2234
+ Expect(_Parser.solve('Result = 5 <= 5')).to.equal('1');
2235
+ return fDone();
2236
+ }
2237
+ );
2238
+ }
2239
+ );
2240
+ suite
2241
+ (
2242
+ 'Equal',
2243
+ function ()
2244
+ {
2245
+ test
2246
+ (
2247
+ 'Basic equality comparisons.',
2248
+ (fDone) =>
2249
+ {
2250
+ let _Parser = getExpressionParser();
2251
+ Expect(_Parser.solve('Result = 5 == 5')).to.equal('1');
2252
+ Expect(_Parser.solve('Result = 5 == 3')).to.equal('0');
2253
+ return fDone();
2254
+ }
2255
+ );
2256
+ }
2257
+ );
2258
+ suite
2259
+ (
2260
+ 'Not Equal',
2261
+ function ()
2262
+ {
2263
+ test
2264
+ (
2265
+ 'Basic inequality comparisons.',
2266
+ (fDone) =>
2267
+ {
2268
+ let _Parser = getExpressionParser();
2269
+ Expect(_Parser.solve('Result = 5 != 3')).to.equal('1');
2270
+ Expect(_Parser.solve('Result = 5 != 5')).to.equal('0');
2271
+ return fDone();
2272
+ }
2273
+ );
2274
+ }
2275
+ );
2276
+ suite
2277
+ (
2278
+ 'Comparison with Arithmetic',
2279
+ function ()
2280
+ {
2281
+ test
2282
+ (
2283
+ 'Arithmetic is evaluated before comparison.',
2284
+ (fDone) =>
2285
+ {
2286
+ let _Parser = getExpressionParser();
2287
+ // 2 + 3 = 5, 1 + 2 = 3, so 5 > 3 = 1
2288
+ Expect(_Parser.solve('Result = 2 + 3 > 1 + 2')).to.equal('1');
2289
+ // 1 + 1 = 2, 3 + 1 = 4, so 2 > 4 = 0
2290
+ Expect(_Parser.solve('Result = 1 + 1 > 3 + 1')).to.equal('0');
2291
+ // 10 - 5 = 5, 2 * 3 = 6, so 5 < 6 = 1
2292
+ Expect(_Parser.solve('Result = 10 - 5 < 2 * 3')).to.equal('1');
2293
+ return fDone();
2294
+ }
2295
+ );
2296
+ test
2297
+ (
2298
+ 'Comparison with variables.',
2299
+ (fDone) =>
2300
+ {
2301
+ let _Parser = getExpressionParser();
2302
+ let tmpData = { Height: 10, Width: 5 };
2303
+ let tmpDestination = {};
2304
+ _Parser.solve('Result = Height > Width', tmpData, {}, false, tmpDestination);
2305
+ Expect(tmpDestination.Result).to.equal('1');
2306
+ _Parser.solve('Result = Width > Height', tmpData, {}, false, tmpDestination);
2307
+ Expect(tmpDestination.Result).to.equal('0');
2308
+ _Parser.solve('Result = Height == Width', tmpData, {}, false, tmpDestination);
2309
+ Expect(tmpDestination.Result).to.equal('0');
2310
+ _Parser.solve('Result = Height != Width', tmpData, {}, false, tmpDestination);
2311
+ Expect(tmpDestination.Result).to.equal('1');
2312
+ return fDone();
2313
+ }
2314
+ );
2315
+ }
2316
+ );
2317
+ }
2318
+ );
2319
+
2320
+ suite
2321
+ (
2322
+ 'Ternary Operator',
2323
+ function ()
2324
+ {
2325
+ suite
2326
+ (
2327
+ 'Basic Ternary',
2328
+ function ()
2329
+ {
2330
+ test
2331
+ (
2332
+ 'True branch is selected when condition is truthy.',
2333
+ (fDone) =>
2334
+ {
2335
+ let _Parser = getExpressionParser();
2336
+ Expect(_Parser.solve('Result = 5 > 3 ? 100 :: 200')).to.equal('100');
2337
+ return fDone();
2338
+ }
2339
+ );
2340
+ test
2341
+ (
2342
+ 'False branch is selected when condition is falsy.',
2343
+ (fDone) =>
2344
+ {
2345
+ let _Parser = getExpressionParser();
2346
+ Expect(_Parser.solve('Result = 3 > 5 ? 100 :: 200')).to.equal('200');
2347
+ return fDone();
2348
+ }
2349
+ );
2350
+ test
2351
+ (
2352
+ 'Ternary with equality comparison.',
2353
+ (fDone) =>
2354
+ {
2355
+ let _Parser = getExpressionParser();
2356
+ Expect(_Parser.solve('Result = 5 == 5 ? 10 :: 20')).to.equal('10');
2357
+ Expect(_Parser.solve('Result = 5 == 3 ? 10 :: 20')).to.equal('20');
2358
+ return fDone();
2359
+ }
2360
+ );
2361
+ }
2362
+ );
2363
+ suite
2364
+ (
2365
+ 'Ternary with Variables',
2366
+ function ()
2367
+ {
2368
+ test
2369
+ (
2370
+ 'Ternary selects based on variable comparison.',
2371
+ (fDone) =>
2372
+ {
2373
+ let _Parser = getExpressionParser();
2374
+ let tmpData = { Height: 10, Width: 5, A: 42, B: 99 };
2375
+ let tmpDestination = {};
2376
+ _Parser.solve('SomeValue = Height > Width ? A :: B', tmpData, {}, false, tmpDestination);
2377
+ Expect(tmpDestination.SomeValue).to.equal('42');
2378
+ _Parser.solve('SomeValue = Width > Height ? A :: B', tmpData, {}, false, tmpDestination);
2379
+ Expect(tmpDestination.SomeValue).to.equal('99');
2380
+ return fDone();
2381
+ }
2382
+ );
2383
+ }
2384
+ );
2385
+ suite
2386
+ (
2387
+ 'Ternary with Arithmetic in Branches',
2388
+ function ()
2389
+ {
2390
+ test
2391
+ (
2392
+ 'Arithmetic expressions work in ternary branches.',
2393
+ (fDone) =>
2394
+ {
2395
+ let _Parser = getExpressionParser();
2396
+ let tmpData = { A: 10, B: 5 };
2397
+ let tmpDestination = {};
2398
+ // A > B is true, so A + 1 = 11
2399
+ _Parser.solve('Result = A > B ? A + 1 :: B + 1', tmpData, {}, false, tmpDestination);
2400
+ Expect(tmpDestination.Result).to.equal('11');
2401
+ // B > A is false, so B + 1 = 6
2402
+ _Parser.solve('Result = B > A ? A + 1 :: B + 1', tmpData, {}, false, tmpDestination);
2403
+ Expect(tmpDestination.Result).to.equal('6');
2404
+ return fDone();
2405
+ }
2406
+ );
2407
+ test
2408
+ (
2409
+ 'Arithmetic expressions work in the ternary condition.',
2410
+ (fDone) =>
2411
+ {
2412
+ let _Parser = getExpressionParser();
2413
+ // 2 + 3 = 5, 1 + 2 = 3, so 5 > 3 = true, result is 100
2414
+ Expect(_Parser.solve('Result = 2 + 3 > 1 + 2 ? 100 :: 200')).to.equal('100');
2415
+ // 1 + 1 = 2, 3 + 1 = 4, so 2 > 4 = false, result is 200
2416
+ Expect(_Parser.solve('Result = 1 + 1 > 3 + 1 ? 100 :: 200')).to.equal('200');
2417
+ return fDone();
2418
+ }
2419
+ );
2420
+ }
2421
+ );
2422
+ suite
2423
+ (
2424
+ 'Nested Ternary',
2425
+ function ()
2426
+ {
2427
+ test
2428
+ (
2429
+ 'Nested ternary with parenthesized inner ternary.',
2430
+ (fDone) =>
2431
+ {
2432
+ let _Parser = getExpressionParser();
2433
+ let tmpData = { A: 5, B: 3 };
2434
+ let tmpDestination = {};
2435
+ // A > 0 is true, then B > 0 is true, so result is 1
2436
+ _Parser.solve('Result = A > 0 ? (B > 0 ? 1 :: 2) :: 3', tmpData, {}, false, tmpDestination);
2437
+ Expect(tmpDestination.Result).to.equal('1');
2438
+ // A > 0 is true, then B > 10 is false, so result is 2
2439
+ _Parser.solve('Result = A > 0 ? (B > 10 ? 1 :: 2) :: 3', tmpData, {}, false, tmpDestination);
2440
+ Expect(tmpDestination.Result).to.equal('2');
2441
+ return fDone();
2442
+ }
2443
+ );
2444
+ }
2445
+ );
2446
+ }
2447
+ );