We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2329a0a commit 275b594Copy full SHA for 275b594
4 files changed
src/core/Dish.mjs
@@ -292,11 +292,7 @@ class Dish {
292
and reinitialise it as a BigNumber object.
293
*/
294
if (Object.keys(this.value).sort().equals(["c", "e", "s"])) {
295
- const temp = new BigNumber();
296
- temp.c = this.value.c;
297
- temp.e = this.value.e;
298
- temp.s = this.value.s;
299
- this.value = temp;
+ this.value = new BigNumber({ s: this.value.s, e: this.value.e, c: this.value.c, _isBigNumber: true});
300
return true;
301
}
302
return false;
tests/browser/02_ops.js
@@ -346,8 +346,8 @@ module.exports = {
346
// testOp(browser, "Strip HTTP headers", "test input", "test_output");
347
// testOp(browser, "Subsection", "test input", "test_output");
348
// testOp(browser, "Substitute", "test input", "test_output");
349
- // testOp(browser, "Subtract", "test input", "test_output");
350
- // testOp(browser, "Sum", "test input", "test_output");
+ testOp(browser, "Subtract", "321,123,test", "198", ["Comma"]);
+ testOp(browser, "Sum", "321,123,test", "444", ["Comma"]);
351
// testOp(browser, "Swap endianness", "test input", "test_output");
352
// testOp(browser, "Symmetric Difference", "test input", "test_output");
353
testOpHtml(browser, "Syntax highlighter", "var a = [4,5,6]", ".hljs-selector-attr", "[4,5,6]");
tests/node/tests/Dish.mjs
@@ -9,4 +9,23 @@ TestRegister.addApiTests([
9
assert(dish.presentAs);
10
}),
11
12
+ it("Disk - should not error on serialized BigNumber (0)", () => {
13
+ const dish = new Dish({ s: 1, e: 0, c: [0] }, Dish.BIG_NUMBER);
14
+ assert.strictEqual(dish.value.toString(), "0");
15
+ }),
16
+
17
+ it("Dish - should not error on serialized BigNumber (1)", () => {
18
+ const dish = new Dish({ c: [1], e: 0, s: 1 }, Dish.BIG_NUMBER);
19
+ assert.strictEqual(dish.value.toString(), "1");
20
21
22
+ it("Dish - should not error on serialized BigNumber (-100)", () => {
23
+ const dish = new Dish({ s: -1, e: 2, c: [100] }, Dish.BIG_NUMBER);
24
+ assert.strictEqual(dish.value.toString(), "-100");
25
26
27
+ it("Dish - should not error on serialized BigNumber (NaN)", () => {
28
+ const dish = new Dish({ s: null, e: null, c: null }, Dish.BIG_NUMBER);
29
+ assert.strictEqual(dish.value.toString(), "NaN");
30
31
]);
tests/operations/tests/Arithmetic.mjs
@@ -0,0 +1,33 @@
1
+/**
2
+ * Tests for arithmetical operations
3
+ *
4
+ * @copyright Crown Copyright 2026
5
+ * @license Apache-2.0
6
+ */
7
8
+import TestRegister from "../../lib/TestRegister.mjs";
+TestRegister.addTests([
+ {
+ name: "Subtract",
+ input: "321,123,test",
+ expectedOutput: "198",
+ recipeConfig: [
+ "op": "Subtract",
+ "args": ["Comma"]
+ },
+ ],
+ name: "Subtract - no valid input",
+ input: "test",
+ expectedOutput: "NaN",
32
33
+]);
0 commit comments