Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keplr-wallet/unit

Package Overview
Dependencies
Maintainers
1
Versions
616
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keplr-wallet/unit - npm Package Compare versions

Comparing version 0.8.6 to 0.9.0-alpha.0

jest.config.js

2

build/coin.spec.d.ts

@@ -1,1 +0,1 @@

import "mocha";
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
require("mocha");
const coin_1 = require("./coin");

@@ -12,12 +7,12 @@ describe("Test coin", () => {

let coin = coin_1.Coin.parse("1000test");
assert_1.default.strictEqual(coin.denom, "test");
assert_1.default.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("test");
expect(coin.amount.toString()).toBe("1000");
coin = coin_1.Coin.parse("1000tesT");
assert_1.default.strictEqual(coin.denom, "tesT");
assert_1.default.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("tesT");
expect(coin.amount.toString()).toBe("1000");
coin = coin_1.Coin.parse("1000TEST");
assert_1.default.strictEqual(coin.denom, "TEST");
assert_1.default.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("TEST");
expect(coin.amount.toString()).toBe("1000");
});
});
//# sourceMappingURL=coin.spec.js.map

@@ -1,1 +0,1 @@

import "mocha";
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
require("mocha");
const decimal_1 = require("./decimal");

@@ -13,27 +8,27 @@ const int_1 = require("./int");

let dec = new decimal_1.Dec("10.009");
assert_1.default.strictEqual(dec.toString(), "10.009000000000000000");
assert_1.default.strictEqual(dec.toString(2), "10.00");
expect(dec.toString()).toBe("10.009000000000000000");
expect(dec.toString(2)).toBe("10.00");
dec = new decimal_1.Dec("-123.45678900");
assert_1.default.strictEqual(dec.toString(), "-123.456789000000000000");
assert_1.default.strictEqual(dec.toString(3), "-123.456");
expect(dec.toString()).toBe("-123.456789000000000000");
expect(dec.toString(3)).toBe("-123.456");
dec = new decimal_1.Dec("10");
assert_1.default.strictEqual(dec.toString(), "10.000000000000000000");
assert_1.default.throws(() => {
expect(dec.toString()).toBe("10.000000000000000000");
expect(() => {
new decimal_1.Dec("");
});
assert_1.default.throws(() => {
}).toThrow();
expect(() => {
new decimal_1.Dec("0.-75");
});
assert_1.default.throws(() => {
}).toThrow();
expect(() => {
new decimal_1.Dec("0.489234893284938249348923849283408");
});
assert_1.default.throws(() => {
}).toThrow();
expect(() => {
new decimal_1.Dec("foobar");
});
assert_1.default.throws(() => {
}).toThrow();
expect(() => {
new decimal_1.Dec("0.foobar");
});
assert_1.default.throws(() => {
}).toThrow();
expect(() => {
new decimal_1.Dec("foobar.0");
});
}).toThrow();
});

@@ -125,10 +120,14 @@ it("dec should be caculated properly", () => {

const resMulTruncate = test.d1.mulTruncate(test.d2);
assert_1.default.strictEqual(resAdd.toString(), test.expAdd.toString(), "invalid result of add");
assert_1.default.strictEqual(resSub.toString(), test.expSub.toString(), "invalid result of sub");
assert_1.default.strictEqual(resMul.toString(), test.expMul.toString(), "invalid result of mul");
assert_1.default.strictEqual(resMulTruncate.toString(), test.expMulTruncate.toString(), "invalid result of mul");
// invalid result of add
expect(resAdd.toString()).toBe(test.expAdd.toString());
// invalid result of sub
expect(resSub.toString()).toBe(test.expSub.toString());
// invalid result of mul
expect(resMul.toString()).toBe(test.expMul.toString());
// invalid result of mul
expect(resMulTruncate.toString()).toBe(test.expMulTruncate.toString());
if (test.d2.isZero()) {
assert_1.default.throws(() => {
expect(() => {
test.d1.quo(test.d2);
});
}).toThrow();
}

@@ -139,5 +138,8 @@ else {

const resQuoTruncate = test.d1.quoTruncate(test.d2);
assert_1.default.strictEqual(resQuo.toString(), test.expQuo.toString(), "invalid result of quo");
assert_1.default.strictEqual(resQuoRoundUp.toString(), test.expQuoRoundUp.toString(), "invalid result of quo round up");
assert_1.default.strictEqual(resQuoTruncate.toString(), test.expQuoTruncate.toString(), "invalid result of quo truncate");
// invalid result of quo
expect(resQuo.toString()).toBe(test.expQuo.toString());
// invalid result of quo round up
expect(resQuoRoundUp.toString()).toBe(test.expQuoRoundUp.toString());
// invalid result of quo truncate
expect(resQuoTruncate.toString()).toBe(test.expQuoTruncate.toString());
}

@@ -183,5 +185,5 @@ }

const resNeg = test.d1.neg().round();
assert_1.default.strictEqual(resNeg.toString(), test.exp.neg().toString());
expect(resNeg.toString()).toBe(test.exp.neg().toString());
const resPos = test.d1.round();
assert_1.default.strictEqual(resPos.toString(), test.exp.toString());
expect(resPos.toString()).toBe(test.exp.toString());
}

@@ -226,5 +228,5 @@ });

const resNeg = test.d1.neg().truncate();
assert_1.default.strictEqual(resNeg.toString(), test.exp.neg().toString());
expect(resNeg.toString()).toBe(test.exp.neg().toString());
const resPos = test.d1.truncate();
assert_1.default.strictEqual(resPos.toString(), test.exp.toString());
expect(resPos.toString()).toBe(test.exp.toString());
}

@@ -297,3 +299,3 @@ });

const res = test.d1.toString(test.precision);
assert_1.default.strictEqual(res, test.exp);
expect(res).toBe(test.exp);
}

@@ -300,0 +302,0 @@ });

{
"name": "@keplr-wallet/unit",
"version": "0.8.6",
"version": "0.9.0-alpha.0",
"main": "build/index.js",

@@ -15,3 +15,3 @@ "author": "chainapsis",

"dev": "tsc -w",
"test": "mocha -r ts-node/register 'src/**/*.spec.ts'",
"test": "jest --passWithNoTests",
"lint-test": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",

@@ -21,10 +21,7 @@ "lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""

"dependencies": {
"@keplr-wallet/types": "^0.8.6",
"@keplr-wallet/types": "^0.9.0-alpha.0",
"big-integer": "^1.6.48",
"utility-types": "^3.10.0"
},
"devDependencies": {
"mocha": "^8.2.1"
},
"gitHead": "2b9b577101b80b033bd98fcb50069813c7b4e209"
"gitHead": "9c1b2a92ed5730813877934906c9f16e17201bb6"
}

@@ -1,3 +0,1 @@

import assert from "assert";
import "mocha";
import { Coin } from "./coin";

@@ -9,15 +7,15 @@

assert.strictEqual(coin.denom, "test");
assert.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("test");
expect(coin.amount.toString()).toBe("1000");
coin = Coin.parse("1000tesT");
assert.strictEqual(coin.denom, "tesT");
assert.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("tesT");
expect(coin.amount.toString()).toBe("1000");
coin = Coin.parse("1000TEST");
assert.strictEqual(coin.denom, "TEST");
assert.strictEqual(coin.amount.toString(), "1000");
expect(coin.denom).toBe("TEST");
expect(coin.amount.toString()).toBe("1000");
});
});

@@ -1,3 +0,1 @@

import assert from "assert";
import "mocha";
import { Dec } from "./decimal";

@@ -9,30 +7,30 @@ import { Int } from "./int";

let dec = new Dec("10.009");
assert.strictEqual(dec.toString(), "10.009000000000000000");
assert.strictEqual(dec.toString(2), "10.00");
expect(dec.toString()).toBe("10.009000000000000000");
expect(dec.toString(2)).toBe("10.00");
dec = new Dec("-123.45678900");
assert.strictEqual(dec.toString(), "-123.456789000000000000");
assert.strictEqual(dec.toString(3), "-123.456");
expect(dec.toString()).toBe("-123.456789000000000000");
expect(dec.toString(3)).toBe("-123.456");
dec = new Dec("10");
assert.strictEqual(dec.toString(), "10.000000000000000000");
expect(dec.toString()).toBe("10.000000000000000000");
assert.throws(() => {
expect(() => {
new Dec("");
});
assert.throws(() => {
}).toThrow();
expect(() => {
new Dec("0.-75");
});
assert.throws(() => {
}).toThrow();
expect(() => {
new Dec("0.489234893284938249348923849283408");
});
assert.throws(() => {
}).toThrow();
expect(() => {
new Dec("foobar");
});
assert.throws(() => {
}).toThrow();
expect(() => {
new Dec("0.foobar");
});
assert.throws(() => {
}).toThrow();
expect(() => {
new Dec("foobar.0");
});
}).toThrow();
});

@@ -137,27 +135,15 @@

assert.strictEqual(
resAdd.toString(),
test.expAdd.toString(),
"invalid result of add"
);
assert.strictEqual(
resSub.toString(),
test.expSub.toString(),
"invalid result of sub"
);
assert.strictEqual(
resMul.toString(),
test.expMul.toString(),
"invalid result of mul"
);
assert.strictEqual(
resMulTruncate.toString(),
test.expMulTruncate.toString(),
"invalid result of mul"
);
// invalid result of add
expect(resAdd.toString()).toBe(test.expAdd.toString());
// invalid result of sub
expect(resSub.toString()).toBe(test.expSub.toString());
// invalid result of mul
expect(resMul.toString()).toBe(test.expMul.toString());
// invalid result of mul
expect(resMulTruncate.toString()).toBe(test.expMulTruncate.toString());
if (test.d2.isZero()) {
assert.throws(() => {
expect(() => {
test.d1.quo(test.d2);
});
}).toThrow();
} else {

@@ -168,17 +154,8 @@ const resQuo = test.d1.quo(test.d2);

assert.strictEqual(
resQuo.toString(),
test.expQuo.toString(),
"invalid result of quo"
);
assert.strictEqual(
resQuoRoundUp.toString(),
test.expQuoRoundUp.toString(),
"invalid result of quo round up"
);
assert.strictEqual(
resQuoTruncate.toString(),
test.expQuoTruncate.toString(),
"invalid result of quo truncate"
);
// invalid result of quo
expect(resQuo.toString()).toBe(test.expQuo.toString());
// invalid result of quo round up
expect(resQuoRoundUp.toString()).toBe(test.expQuoRoundUp.toString());
// invalid result of quo truncate
expect(resQuoTruncate.toString()).toBe(test.expQuoTruncate.toString());
}

@@ -229,6 +206,6 @@ }

const resNeg = test.d1.neg().round();
assert.strictEqual(resNeg.toString(), test.exp.neg().toString());
expect(resNeg.toString()).toBe(test.exp.neg().toString());
const resPos = test.d1.round();
assert.strictEqual(resPos.toString(), test.exp.toString());
expect(resPos.toString()).toBe(test.exp.toString());
}

@@ -278,6 +255,6 @@ });

const resNeg = test.d1.neg().truncate();
assert.strictEqual(resNeg.toString(), test.exp.neg().toString());
expect(resNeg.toString()).toBe(test.exp.neg().toString());
const resPos = test.d1.truncate();
assert.strictEqual(resPos.toString(), test.exp.toString());
expect(resPos.toString()).toBe(test.exp.toString());
}

@@ -356,5 +333,5 @@ });

const res = test.d1.toString(test.precision);
assert.strictEqual(res, test.exp);
expect(res).toBe(test.exp);
}
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc