Skip to content

Commit

Permalink
fix: use xValue instead of x in typed log10
Browse files Browse the repository at this point in the history
test: check equality not near in log10 tests
test: fix ceil tests for typed ud60x18 library
  • Loading branch information
PaulRBerg committed Jun 16, 2021
1 parent 77398e4 commit 17878fe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contracts/PRBMathUD60x18Typed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ library PRBMathUD60x18Typed {

// prettier-ignore
assembly {
switch x
switch xValue
case 1 { rValue := mul(SCALE, sub(0, 18)) }
case 10 { rValue := mul(SCALE, sub(1, 18)) }
case 100 { rValue := mul(SCALE, sub(2, 18)) }
Expand Down
4 changes: 2 additions & 2 deletions test/prbMathSd59x18/pure/log10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default function shouldBehaveLikeLog10(): void {

forEach(testSets).it("takes %e and returns the correct value", async function (x: string) {
const expected: BigNumber = fp(log10(x));
expect(expected).to.be.near(await this.contracts.prbMathSd59x18.doLog10(fp(x)));
expect(expected).to.be.near(await this.contracts.prbMathSd59x18Typed.doLog10(fp(x)));
expect(expected).to.equal(await this.contracts.prbMathSd59x18.doLog10(fp(x)));
expect(expected).to.equal(await this.contracts.prbMathSd59x18Typed.doLog10(fp(x)));
});
});

Expand Down
1 change: 1 addition & 0 deletions test/prbMathUd60x18/pure/ceil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function shouldBehaveLikeCeil(): void {

forEach(testSets).it("takes %e and reverts", async function (x: BigNumber) {
await expect(this.contracts.prbMathUd60x18.doCeil(x)).to.be.reverted;
await expect(this.contracts.prbMathUd60x18Typed.doCeil(x)).to.be.reverted;
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/prbMathUd60x18/pure/log10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default function shouldBehaveLikeLog10(): void {

forEach(testSets).it("takes %e and returns the correct value", async function (x: string) {
const expected: BigNumber = fp(log10(x));
expect(expected).to.be.near(await this.contracts.prbMathUd60x18.doLog10(fp(x)));
expect(expected).to.be.near(await this.contracts.prbMathUd60x18Typed.doLog10(fp(x)));
expect(expected).to.equal(await this.contracts.prbMathUd60x18.doLog10(fp(x)));
expect(expected).to.equal(await this.contracts.prbMathUd60x18Typed.doLog10(fp(x)));
});
});

Expand Down

0 comments on commit 17878fe

Please sign in to comment.